0

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

2 Answers2

1

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.

Veronika
  • 11
  • 3
0

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

Nanotron
  • 554
  • 5
  • 16