I create a springboot+mybatis+swagger project, I want to use swagger to export the project api, I did write swagger annotation in my code.
How Can I to export api as html or doc or chm?
I create a springboot+mybatis+swagger project, I want to use swagger to export the project api, I did write swagger annotation in my code.
How Can I to export api as html or doc or chm?
To bring Swagger in, we need the following dependency declaration in our Maven POM
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
<scope>compile</scope>
</dependency>
Configuring Swagger 2 in the Application
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select() .apis(RequestHandlerSelectors.basePackage("com.springframework.example"))
.paths("/")
.build();
}
}
At this point, you should be able to test the configuration by starting the app and pointing your browser to http://localhost:8080/v2/api-docs
On pointing your browser to http://localhost:8080/swagger-ui.html
, you will see the generated documentation rendered by Swagger UI.