openapi codegen-maven-plugin消除生成方法中的UsingGET后缀



我试图用openapi codegen-maven-plugin从yaml文件生成接口,一切都很好,除了生成的方法具有后缀UsingGET,你可以在下面这个例子中看到:

ResponseEntity<ApicatControl> retrieveRepeatedProductOfferingUsingGET(
@Parameter(name = "category.id", description = "category.id", schema = @Schema(description = "")) @Valid @RequestParam(value = "category.id", required = false) String categoryId,
@Parameter(name = "type", description = "type", schema = @Schema(description = "")) @Valid @RequestParam(value = "type", required = false) String type
);

这是我在pom.xml中对codegen-maven-plugin的配置。

<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.4.0</version>
<executions>
<execution>
<id>openapi-codegen-java-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/swagger/swagger.yaml</inputSpec>
<generatorName>spring</generatorName>
<generateApiTests>false</generateApiTests>
<modelPackage>com.groupe.apicat.gu.api.resources.model</modelPackage>
<apiPackage>com.groupe.apicat.gu.api</apiPackage>
<output>${generated-sources-path}</output>
<templateDirectory>src/templates/service</templateDirectory>
<generateSupportingFiles>false</generateSupportingFiles>
<generateModels>true</generateModels>
<configOptions>
<skipDefaultInterface>true</skipDefaultInterface>
<interfaceOnly>true</interfaceOnly>
<sourceFolder>generated-sources</sourceFolder>
<dateLibrary>legacy</dateLibrary>
<returnResponse>true</returnResponse>
<library>spring-boot</library>
<useTags>true</useTags>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<useSwaggerAnnotations>true</useSwaggerAnnotations>
<serializableModel>true</serializableModel>
<delegatePattern>false</delegatePattern>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>

请您有任何解决方案!!由于

方法名称" retriverepeatedproductofferingusingget";在swagger.yaml中创建。应该有一个名为operationid的参数;在其中指定此名称。所以只要把它修改一下,然后重新构建项目。

您必须使用spring-fox来生成规范,因为它们是自动配置为使用该约定后缀的OperationBuilderPlugin

查看其中一个维护者的答案,看看如何自己定制它

最新更新