Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][JavaSpring] description values for @Operation annotation are not generated from OpenAPI definition #13994

Open
5 of 6 tasks
ziegler-daniel opened this issue Nov 11, 2022 · 0 comments

Comments

@ziegler-daniel
Copy link
Contributor

ziegler-daniel commented Nov 11, 2022

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When I run code generation for a Java Spring Api, the description is missing in the @Operation annotation.

openapi-generator version

The bug occurs with the latest openapi-generator version.

OpenAPI declaration file content or url

The bug can be reproduced for example with this file: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/java/petstore-group-parameter.yaml

Generation Details

Command to generate the code: java -jar openapi-generator-cli-6.3.0-20221110.220613-11.jar generate -i modules/openapi-generator/src/test/resources/3_0/java/petstore-group-parameter.yaml -g spring -o test

Steps to reproduce

Run the code generation command from above.

Output:

...
    @Operation(
        operationId = "findPetsByStatus",
        summary = "Finds Pets by status",
        tags = { "pet" },
        responses = {
            @ApiResponse(responseCode = "200", description = "successful operation", content = {
                @Content(mediaType = "application/xml", schema = @Schema(implementation = Pet.class)),
                @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))
            }),
            @ApiResponse(responseCode = "400", description = "Invalid status value")
        },
        security = {
            @SecurityRequirement(name = "petstore_auth", scopes={ "read:pets" })
        }
    )
...

Expected output:

...
    @Operation(
        operationId = "findPetsByStatus",
        summary = "Finds Pets by status",
        description = "Multiple status values can be provided with comma separated strings",
        tags = { "pet" },
        responses = {
            @ApiResponse(responseCode = "200", description = "successful operation", content = {
                @Content(mediaType = "application/xml", schema = @Schema(implementation = Pet.class)),
                @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))
            }),
            @ApiResponse(responseCode = "400", description = "Invalid status value")
        },
        security = {
            @SecurityRequirement(name = "petstore_auth", scopes={ "read:pets" })
        }
    )
...
Related issues/PRs

The bug has already been reported with the closed issue #11779, but the fix was not correct as mentioned in the discussion.

Suggest a fix

PR with a fix: #13995

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant