我正在使用 Open-API 使用 yaml 文件生成 java 类。当我跑步时
mvn 全新安装
我收到此错误:
unexpected error in Open-API generation
org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
| Error count: 3, Warning count: 6
Errors:
-attribute paths.'/path/{id}'(delete).operationId is repeated
-attribute paths.'/path/name'(get).operationId is repeated
我如何才能继续进行此验证?
对我来说,
validateSpec
的正确位置是configuration
而不是configOptions
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.2.1</version>
<executions>
<execution>
<id>abc-api</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
...
<validateSpec>false</validateSpec>
<skipValidateSpec>true</skipValidateSpec>
<configOptions>
<developerOrganization>ABC</developerOrganization>
...
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
注意:我必须根据未解决的错误中的建议为版本 6.2.1 添加
validateSpec
和 skipValidateSpec
https://github.com/OpenAPITools/openapi-generator/issues/9815
试试这个:
在你的 POM.xml 中 -> 插件 -> 找到 openAPI 生成插件 -> 配置 -> configOptions ->
<validateSpec>false</validateSpec>
这应该会有效! :)
尝试添加语法 "schema": {"type": "string"} 到 *.Json 文件。
我也遇到了这样的错误:
规范存在问题。可以通过 validateSpec (Maven/Gradle) 或 --skip-validate-spec (CLI) 禁用该选项。 |错误计数:12,警告计数:20 错误: -attribute paths.'/.../items'(get).responses.304.ETag.type 是意外的 -attribute paths.'/.../items'(get).responses.304.Last-Modified.type 是意外的 -属性路径。'/.../items'(get).responses.200.ETag.type 是意外的
"headers": {
"ETag": {
"description": "Used as caching key for future requests.",
"schema": {
"type": "string",
"example": "33a64df551425fcc55e4d42a1466666666666666666"
}
},
"Cache-Control": {
"description": "The Cache-Control header.",
"schema": {
"type": "string",
"example": "max-age=1000000"
}
},
"Last-Modified": {
"description": "The last modified the response.",
"schema": {
"type": "string",
"example": "Sun, 11 Nov 2021 15:30:51 ICT"
}
}
}
希望这篇文章能帮到你。您无法在此处阅读带有响应标头的更多文档:https://swagger.io/docs/specification/describing-responses/
适用于版本 7.1.0
<skipValidateSpec>true</skipValidateSpec>
成功了
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.1.0</version>
<executions>
<execution>
<id>generate-client-code</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<skipValidateSpec>true</skipValidateSpec>
(....)
</configuration>
</execution>