Bo Master is very lazy ...
Swagger Official website: Http://swagger.io
GitHub Address: Https://github.com/swagger-api
Official Note document: http://docs.swagger.io/swagger-core/apidocs/index.html
Swagger-ui Address: Https://github.com/swagger-api/swagger-ui
Swagger final
Well, start by saying how spring configures Swagger 1.pom.xml to introduce the required jar packages
<!--Building a restful API I'm 2.6.1 this version . -<Dependency> <groupId>Io.springfox</groupId> <Artifactid>Springfox-swagger2</Artifactid> <version>${swagger2.version}</version></Dependency><Dependency> <groupId>Io.springfox</groupId> <Artifactid>Springfox-swagger-ui</Artifactid> <version>${swagger2.version}</version></Dependency>
2. Scan the package where your Swagger2config.java is located
<!---<Context:component-scan base-package = "Com.nickwilde.microtrain.common.config.swagger"/>
3.swagger2config.java[class name Customization]
PackageCom.nickwilde.microtrain.common.config.swagger2;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.service.Contact;ImportSpringfox.documentation.spi.DocumentationType;ImportSpringfox.documentation.spring.web.plugins.Docket;ImportSpringfox.documentation.swagger2.annotations.EnableSwagger2;/** * @authorNickwilde *@version2018/1/18 10:23 * @description: Swagger2config * TODO in a sentence description*/@Configuration @enableswagger2 Public classswagger2config{@Bean PublicDocket API () {return NewDocket (documentationtype.swagger_2). Forcodegeneration (true). Select (). APIs (Requesthandlerselectors.any ())//Filter Build Links. paths (Pathselectors.any ()). Build (). Apiinfo (Apiinfo ()); } //API Interface Author related information Privateapiinfo Apiinfo () { Contact Contact=NewContact ("Nickwilde", "", "[email protected]"); Apiinfo Apiinfo=NewApiinfobuilder (). License ("Apache License Version 2.0"). Title ("Unexpectedly system"). Description ("Interface Documentation"). Contact. Version ("1.0"). build (); returnApiinfo; }}
4. Add additional annotations to your controller (not added)
// Httpmehtod if not defined, then swagger will have to enumerate all the request methods of the interface. true //Parameter definition: Type.. Kind of, this is basic simple, the rest of the Look API bar ~
Spring Integrated Swagger,java Auto-Generate API documentation