OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA][JAXRS-SPEC] Multiple javadoc @return tags generated
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
Generator jaxrs-spec generates invalid javadoc: It generates multiple @return tags: one for each possible response of the operation call. However, this is invalid (javadoc complains), since only a single instance of @return tag is expected.
openapi-generator version
open-api-generator-maven-plugin 7.11.0
OpenAPI declaration file content or url
The issue is reproducible with any OpenAPI declaration file declaring at least 2 responses for an operation, e.g.
generates multiple @return tags for any method in PetsApi.java
Generation Details
Use the following spec in pom.xml
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.11.0</version>
<executions>
<execution>
<id>multipleResponses</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator-gradle-plugin/samples/local-spec/petstore-v3.0.yaml</inputSpec>
<output>${project.build.directory}/generated-sources/cxf-rest/multiple-responses</output>
<generatorName>jaxrs-spec</generatorName>
<configOptions>
<apiPackage>com.multipleresponses.service</apiPackage>
<modelPackage>com.multipleresponses.data</modelPackage>
<sourceFolder>.</sourceFolder>
<useSwaggerAnnotations>false</useSwaggerAnnotations>
<generatePom>false</generatePom>
<interfaceOnly>true</interfaceOnly>
<useBeanValidation>true</useBeanValidation>
<useTags>true</useTags>
<dateLibrary>java8</dateLibrary>
<openApiSpecFileLocation />
<legacyDiscriminatorBehavior>false</legacyDiscriminatorBehavior>
<useJakartaEe>true</useJakartaEe>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Steps to reproduce
Run mvn generate-sources
Related issues/PRs
Suggest a fix
Multiple responses should be covered by a single @return tag (e.g. as a list).
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
Reproduce the issue with the Maven configuration and sample OpenAPI document, then inspect the generated PetsApi.java output after mvn generate-sources. Locate the jaxrs-spec generator template or entry point responsible for operation Javadocs and verify that generation produces one @return tag per method while preserving the response information and valid Javadoc.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100