微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

OpenAPI Maven 生成器为 Spring Boot 生成不存在的“@OptionsMapping”注释

如何解决OpenAPI Maven 生成器为 Spring Boot 生成不存在的“@OptionsMapping”注释

使用'openapi-generator-maven-plugin'基于jar生成客户端时。

这是我重要的 pom.xml 部分:

 <dependency>
            <groupId>org.camunda.bpm</groupId>
            <artifactId>camunda-engine-rest-openapi</artifactId>
            <version>${camunda.version}</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.openapitools</groupId>
            <artifactId>jackson-databind-nullable</artifactId>
            <version>0.2.1</version>
        </dependency>

<repositories>
        <repository>
            <id>camunda-bpm-nexus</id>
            <name>camunda-bpm-nexus</name>
            <url>https://app.camunda.com/nexus/content/groups/public</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.1.2</version>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.camunda.bpm</groupId>
                                    <artifactId>camunda-engine-rest-openapi</artifactId>
                                    <version>${camunda.version}</version>
                                    <outputDirectory>${basedir}/target/openapi</outputDirectory>
                                    <includes>openapi.json</includes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>5.1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/target/openapI/Openapi.json</inputSpec>
                            <skipIfSpecIsUnchanged>true</skipIfSpecIsUnchanged>
                            <generatorName>spring</generatorName>
                            <configOptions>
                                <dateLibrary>java8</dateLibrary>
                                <java8>true</java8>
                                <library>spring-boot</library>
                                <interfaceOnly>true</interfaceOnly>
                            </configOptions>
                            <output>${project.build.directory}/camunda-openapi-client</output>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

出于某种原因,生成器创建了一个在任何地方都不存在的“@OptionsMapping”注释。例如:

@ApiOperation(value = "Tenant Resource Options",nickname = "availableTenantResourceOperations",notes = "The `/tenant` resource supports two custom OPTIONS requests,this one for the resource as such and one for individual tenant instances. The OPTIONS request allows checking for the set of available operations that the currently authenticated user can perform on the `/tenant` resource. If the user can perform an operation or not may depend on varIoUs things,including the users authorizations to interact with this resource and the internal configuration of the process engine.",response = ResourceOptionsDto.class,tags={ "Tenant",})
@ApiResponses(value = { 
    @ApiResponse(code = 200,message = "Request successful.",response = ResourceOptionsDto.class) })
@OptionsMapping(
    value = "/tenant",produces = { "application/json" }
)
default ResponseEntity<ResourceOptionsDto> availableTenantResourceOperations() {

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。