maven Openapi操作ID重复

x8goxv8g  于 2022-11-22  发布在  Maven
关注(0)|答案(2)|浏览(142)

我正在使用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

我怎样才能保持这种验证?

sirbozc5

sirbozc51#

试试这个:

在POM.xml中-〉插件-〉查找openAPI生成插件-〉配置-〉配置选项-〉

<validateSpec>false</validateSpec>

希望这能起作用!:)

jv4diomz

jv4diomz2#

对我来说,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>

注意:我必须根据公开错误https://github.com/OpenAPITools/openapi-generator/issues/9815中的建议为版本6.2.1添加validateSpecskipValidateSpec

相关问题