1. Dependency Packages
<dependency> <groupId>io.springfox</groupId> <artifactid>springfox-swagger-ui </artifactId> <version>2.6.1</version></dependency><dependency> < groupid>io.springfox</groupid> <artifactId>springfox-swagger2</artifactId> < Version>2.6.1</version></dependency>
2. Configuration Classes
PackageCom.shinyway.workflow;ImportOrg.springframework.context.annotation.Bean;Importorg.springframework.context.annotation.Configuration;ImportSpringfox.documentation.builders.ApiInfoBuilder;Importspringfox.documentation.builders.PathSelectors;Importspringfox.documentation.builders.RequestHandlerSelectors;ImportSpringfox.documentation.service.ApiInfo;ImportSpringfox.documentation.spi.DocumentationType;ImportSpringfox.documentation.spring.web.plugins.Docket;ImportSpringfox.documentation.swagger2.annotations.EnableSwagger2, @Configuration @enableswagger2 Public classswagger2configuration {@Bean PublicDocket Createrestapi () {return NewDocket (documentationtype.swagger_2). Apiinfo (Apiinfo ()). Select (). APIs (Requesthandlerselectors.basepackage ("Com.shinyway"). Paths (Pathselectors.any ()). build (); } Privateapiinfo Apiinfo () {return NewApiinfobuilder (). Title ("Approval Platform API"). Description ("Approval Platform API"). Version ("1.0"). build (); }}
Add annotations to the methods in 3.controller
@ApiOperation (value= "Get approval list (HTML format)", notes= "get a comment list by business number") @ApiImplicitParams ({ True , DataType = "string"), true, DataType = "string") })
4. If a method or a whole class does not need to provide documentation, you can add @apiignore annotations to the method or class
Use swagger to generate interface documentation in spring boot