How do you configure the title, description and license in Springfox Swagger UI?

2k views Asked by At

When you start Swagger UI with Springfox in a Spring Boot app, it looks like this:

enter image description here

How do you configure the title and description ("Api Documentation") and the license (Apache 2.0).

2

There are 2 answers

0
Daniel Olszewski On BEST ANSWER

You can set these values by passing the ApiInfo object to your docket.

new Docket(DocumentationType.SWAGGER_2)
    ...
    .apiInfo(new ApiInfo(...))
    ...

ApiInfo's constructor accepts several details about your API. In you case, you should look at title, description, and license parameters.

0
CamelTM On

Swagger config class (Spring boot):

@Configuration
public class SpringFoxConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }

    ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Demo Test API")
                .description("Demo test API task")
                .license("© 2021 by my")
                .build();
    }

}