Add depend in pom file
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
Create a similar start in the class Swagger2 directory
package com.medicalpay.platform;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@ EnableSwagger2
@ConditionalOnExpression ( "$ {swagger.enable}") // open access to interface documentation permissions
public class Swagger2 {
@Bean
public Docket userRestApi () {
return new new Docket (DocumentationType.SWAGGER_2)
.groupName ( "clearing platform") // module name
.apiInfo (apiInfo ())
.Select ()
.apis (RequestHandlerSelectors.basePackage ( "com.medicalpay .platform.v1.admin.rest ")) // scan path controller
.paths (PathSelectors.any ())
.build ();
}
Private ApiInfo apiInfo () {
return new new ApiInfoBuilder ()
.title (" clearing platform development interface documentation ") // interface documentation title
.description (" this document is for developers, testers ") // description
.termsOfServiceUrl (" ") // URL associated
.contact (" ") // author mailbox et
.version ( "") // version
.build ();
}
}
In the profile configuration
swagger.enable =true
In the control layer
Class annotation: @Api (tags = "Description interface class")
Methods Note:
@ApiOperation (value = "Interface action", notes = "method described in", response = String.class)
After starting the project visit http: // localhost: port /swagger-ui.html