springdoc / springdoc-openapi

Library for OpenAPI 3 with spring-boot
https://springdoc.org
Apache License 2.0
3.26k stars 493 forks source link

Global tags are not populated from Tag at type level #2612

Closed piotrooo closed 3 months ago

piotrooo commented 4 months ago

Describe the bug

Following example:

@RestController
@Tag(name = "web")
public class WebController {
    //clean for brevity
}

doesn't produce a global tag because it lacks a description attribute.

When I define a:

@OpenAPIDefinition(tags = {
        @Tag(name = "web")
})

the global tags are generated correctly.

To Reproduce

Expected behavior

The @Tag annotation at the type level should generate global tags as well.

Additional context

In the @OpenAPIDefinition generation method, the AnnotationsUtils.getTags(apiDef.tags(), false) method is used with a false flag, which allows registering tags without a description. For type handling, the same method is used with true flag.

bnasslahsen commented 3 months ago

@piotrooo,

This is related to https://docs.swagger.io/swagger-core/v2.2.22/apidocs/io/swagger/v3/oas/annotations/tags/Tag.html

image

When applied at method or class level, if only a name is provided, the tag will be added to operation only; if additional fields are also defined, like description or externalDocs, the Tag will also be added to openAPI.tags field