Skip to content

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

Closed
@jamesatmarble

Description

@jamesatmarble

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions