compile 'io.springfox:springfox-swagger2:2.9.2' compile 'io.springfox:springfox-swagger-ui:2.9.2'
/** See https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api */ @Configuration @EnableSwagger2 public class SwaggerConfig { @Value("${enable.swagger}") //You may want to disabled it in PROD boolean enableSwagger; @Bean public Docket api() { Docket api = new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage("your.package")) .paths(PathSelectors.any()) .build(); ApiInfo apiInfo = new ApiInfoBuilder() .version("xxx") .description("xxx") .termsOfServiceUrl("xxx") .title("Xxx Doc") .build(); api.useDefaultResponseMessages(false).apiInfo(apiInfo); api.enable(enableSwagger); return api; } }