Complete the code to add the Swagger UI dependency in Maven's <dependencies> section.
<dependency>
<groupId>io.springfox</groupId>
<artifactId>[1]</artifactId>
<version>3.0.0</version>
</dependency>The correct artifactId for Swagger UI integration with Spring Boot using Springfox is springfox-swagger-ui.
Complete the code to enable Swagger UI in a Spring Boot configuration class.
@Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.[1]("com.example")) .paths(PathSelectors.any()) .build(); } }
The method basePackage is used to specify the package to scan for API controllers.
Fix the error in the Swagger UI URL path to access the documentation.
http://localhost:8080/[1]
The default Swagger UI page is accessed at /swagger-ui.html in Springfox 3.0.0.
Fill both blanks to configure Swagger to only document APIs with paths starting with '/api'.
return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage("com.example")) .paths(PathSelectors.[1]("[2]")) .build();
Using ant with the pattern /api/** filters paths starting with '/api'.
Fill all three blanks to customize the Swagger API info with title, description, and version.
return new Docket(DocumentationType.SWAGGER_2) .apiInfo(new ApiInfoBuilder() .title("[1]") .description("[2]") .version("[3]") .build()) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build();
The title, description, and version fields customize the API info shown in Swagger UI.