Pablo Fernandez
Pablo Fernandez

Reputation: 287830

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

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).

Upvotes: 2

Views: 2240

Answers (2)

CamelTM
CamelTM

Reputation: 1250

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();
    }

}

Upvotes: 1

Daniel Olszewski
Daniel Olszewski

Reputation: 14411

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.

Upvotes: 6

Related Questions