Skip to content

Class level @Tag overwrites method level @Operation.tags #1475

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

Closed
jamesatmarble opened this issue Jan 26, 2022 · 0 comments
Closed

Class level @Tag overwrites method level @Operation.tags #1475

jamesatmarble opened this issue Jan 26, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@jamesatmarble
Copy link

jamesatmarble commented Jan 26, 2022

When an operation has tags applied at both the class and method level, only the class level tags are applied.

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?

    • 2.6.2
  • What modules and versions of springdoc-openapi are you using?

    • springdoc-openapi-ui 1.6.3
  • Provide with a sample code (HelloController) or Test that reproduces the problem

    @RestController
    @RequestMapping("/api/v1/hello")
    @Tag(name = "SomeTag")
      public class HelloController {
    
      @GetMapping(produces = "application/json")
      @Operation(
          description = "Get a hello message",
          tags = {"SomeOtherTag"},
          responses = {
              @ApiResponse(responseCode = "200", description = "A hello message"),
          }
      )
      public ResponseEntity<String> getHelloMessage() {
          return ResponseEntity.ok("Hello World");
      }
    }
    

Expected behavior
The following json is produced

  {
    "tags" : ["SomeTag", "SomeOtherTag"],
    "paths" : {
      "/api/v1/hello": {
        "get": {
          "tags" : ["SomeTag", "SomeOtherTag"]
        }
      }
    }
  }

What is actually produced:

  {
    "tags" : ["SomeTag"],
    "paths" : {
      "/api/v1/hello": {
        "get": {
          "tags" : ["SomeTag"]
        }
      }
    }
  }

Additional context
When the class level @Tag is removed the tag on the @Operation appears.
The desired behaviour was observed in version 1.2.22

@bnasslahsen bnasslahsen added the bug Something isn't working label Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants