OpenAPITools / OpenAPITools/openapi-generator

[BUG][JAVA][JAXRS-SPEC] Multiple javadoc @return tags generated

Open
#20,537 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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.

https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator-gradle-plugin/samples/local-spec/petstore-v3.0.yaml

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.