Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #13994
Closed
Open
Issue created Nov 11, 2022 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

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

Created by: ziegler-daniel

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 https://github.com/OpenAPITools/openapi-generator/issues/11779, but the fix was not correct as mentioned in the discussion.

Suggest a fix

PR with a fix: https://github.com/OpenAPITools/openapi-generator/pull/13995

Assignee
Assign to
Time tracking