Search code examples
javaspring-bootmavenspringdoc-openapi-uiopenapi-generator-maven-plugin

openapi-generator duplicates the endpoint in swagger-ui


The openapi-generator-maven-plugin (version 6.3.0) is configured as follows in a Spring-Boot 3 application:

          <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>${openapi-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/src/main/resources/openApi.yaml</inputSpec>
                            <generatorName>spring</generatorName>
                            <apiPackage>com.company.api.v1</apiPackage>
                            <modelPackage>com.company.model.v1</modelPackage>
                            <supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
                            <configOptions>
                                <delegatePattern>true</delegatePattern>
                                <useSpringBoot3>true</useSpringBoot3>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

and in the Swagger/OpenAPI Yaml file is only one endpoint configured:

paths:
  /table:
    get:
      summary: get all trains
      operationId: trainsList
      tags:
        - zuege

The issue here is in the Swagger-Ui; the endpoint is duplicated:

enter image description here

When I remove the tag in the yaml then only the first endpoint is visible but actually this is the ugly one with the generated description. When I configure it with <useTags>true</useTags> (cf. config) the two endpoints are still there but both with name zuege.

Any idea how to reduce it to only one endpoint but consider the tag?

When I add a global tag description as follows:

tags:
  - name: zuege
    description: "Zuege details"

together with <useTags>true</useTags it looks as follows:

enter image description here

So it is still duplicated.


Solution

  • There seems to be an issue with the opeanapi-generator-maven-plugin 6.3.0 because it converts the tag name from the yaml file, e.g.

    tags:
      - name: zuege
    

    into a slightly deviated annotation tag within the generated code, namely:

    @Tag(name = "Zuege", description = "Zuege details")
    public interface ZuegeApi {
    
    }
    

    So when you change the tag within the yaml file into the same style (first character is always in upper case), then the issue is gone:

    enter image description here