OpenAPI Codegen-Maven-Plugin在生成方法中消除了使用后缀

发布于 2025-02-06 20:21:04 字数 3506 浏览 2 评论 0原文

我正在尝试使用openapi codegen-maven-plugin从yaml文件生成

  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。

<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>

请您有任何解决方案!谢谢

I'm trying to generate interfaces from yaml file with openapi codegen-maven-plugin every thing is good except the generated methods having the suffix UsingGET as you can see in this exemple bellow :

  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
);

And this is my configuration for codegen-maven-plugin within pom.xml.

<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>

Please do you have any solutions!! thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

今天小雨转甜 2025-02-13 20:21:04

方法名称“ retrieverePeatedProductoductingUsingsget”是在您的Swagger.yaml中创建的。您应该有一个称为“ aperipID”的参数,您可以在其中指定此名称。因此,只需在那里更改并再次构建项目。

The method name "retrieveRepeatedProductOfferingUsingGET" is created within your swagger.yaml. There should be a parameter called "operationId" where you specify this name. So just change it there and build the project again.

苏大泽ㄣ 2025-02-13 20:21:04

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

查看此答案来自其中一位维护者,看看如何自己自定义它

You must be using spring-fox to generate the spec as they an OperationBuilderPlugin configured automatically to suffix using that convention.

Check out this answer from one of the maintainers to see how you can customize it yourself

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文