Search code examples
javarestspring-mvcswagger-uiswagger-2.0

spingfox-swagger2 description in @Tag not honored


I am using the following version of springfox-swagger2 libraries in my Spring MVC project:

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.8.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.8.0</version>
        </dependency>

And I would like to add description to my REST Controller using the following according swagger documentation:

@RestController
@RequestMapping("/admin")
@Api(tags = {"Admin API"})
@SwaggerDefinition(tags = {
    @Tag(name = "Admin API", description = "Admin interface to manage users")
})
public class AdminController {

However the description in tags is not reflected in swagger-ui.

It says the following:

Admin API Admin Controller

Instead of:

Admin API Admin interface to manage users

What I am missing?


Solution

  • I found I had to configure the docket to see tag descriptions in generated docs:

    @Bean
    public Docket docket() {
        return new Docket(SWAGGER_2)
            ...
            .tags(
                new Tag("Admin API", "Admin interface to manage users")
            );
    }