OpenAPITools / OpenAPITools/openapi-generator
[BUG][SPRING] Bug using webflux with router functions, duplicated swagger-ui api doc
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue? Y
- Have you validated the input using an OpenAPI validator (example)? Y
- Have you tested with the latest master to confirm the issue still exists? Y
- Have you searched for related issues/PRs? Y
- What's the actual output vs expected output? the actual output is showing the doc twice (check the screenshot)
- [] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I have duplicated endpoints in swagger-ui. all the api is shown twice in
http://localhost:8080/webjars/swagger-ui/index.html
see attached

openapi-generator version
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.0.0-SNAPSHOT</version>
OpenAPI declaration file content or url
Generation Details
<generatorName>spring</generatorName>
<openApiNullable>false</openApiNullable>
<performBeanValidation>true</performBeanValidation>
<library>spring-boot</library>
<reactive>true</reactive>
<interfaceOnly>true</interfaceOnly>
<dateLibrary>java8</dateLibrary>
<useSpringController>false</useSpringController>
<documentationProvider>springdoc</documentationProvider>
<skipDefaultInterface>true</skipDefaultInterface>
Steps to reproduce
i have commited my test project in this location
https://github.com/influence160/openapi-generator-springdoc-boot-webflux-fonctionnal-example
to reproduce : build the project and run the WebfluxFunctionalDemoApplication class and go to http://localhost:8080/webjars/swagger-ui/index.html
note that to create this project i have started from the project from springdocs demo https://github.com/springdoc/springdoc-openapi-demos/tree/master/springdoc-openapi-spring-boot-2-webflux-functional
i have generated the yaml file of that demo project and wanted to recreated it using openapi-generator
i just used the module users in my code and havent used the employees and coffee modules
and because i wanted to have a webflux with routing functions project i had to convert all the Mono<ResponseEntity> to Mono<ServerResponse> using the method https://github.com/influence160/openapi-generator-springdoc-boot-webflux-fonctionnal-example/blob/master/src/main/java/othmen/test/openapigenerator/springdoc/demo/app4/user/Util.java
Suggest a fix
in "modules/openapi-generator/src/main/resources/JavaSpring/api.mustache"
correct this block
{{#swagger2AnnotationLibrary}}
@Tag(name = "{{{baseName}}}", description = "the {{{baseName}}} API")
{{/swagger2AnnotationLibrary}}
by taking all Tags in the operation of the current class
As an enhacement or another fix we my have to search each tag in the list of {{tags}} and use the description externalDocs of each tag to have the correct values of the attributes description and externalDocs
Example
https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Annotations#tag
``
openapi: 3.0.1
tags:
- name: Fourth Tag Full
description: desc
externalDocs:
description: docs desc
``
should generate this
@Tag(name = "Fourth Tag Full", description = "desc class", externalDocs = @ExternalDocumentation(description = "docs desc class"))
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with modules/openapi-generator/src/main/resources/JavaSpring/api.mustache and compare its generated annotations with the linked WebFlux functional reproduction project. Run WebfluxFunctionalDemoApplication and inspect the Swagger UI at /webjars/swagger-ui/index.html to confirm the duplicated endpoints. Done means the generated API documentation no longer shows each endpoint twice while preserving the intended tag metadata.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100