|
@ -3,12 +3,18 @@ package com.yihu.wlyy.config;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.web.context.request.async.DeferredResult;
|
|
|
import springfox.documentation.builders.ParameterBuilder;
|
|
|
import springfox.documentation.builders.PathSelectors;
|
|
|
import springfox.documentation.schema.ModelRef;
|
|
|
import springfox.documentation.service.ApiInfo;
|
|
|
import springfox.documentation.service.Parameter;
|
|
|
import springfox.documentation.spi.DocumentationType;
|
|
|
import springfox.documentation.spring.web.plugins.Docket;
|
|
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static com.google.common.base.Predicates.or;
|
|
|
import static springfox.documentation.builders.PathSelectors.regex;
|
|
|
|
|
@ -49,6 +55,8 @@ public class SwaggerConfig {
|
|
|
}
|
|
|
@Bean
|
|
|
public Docket publicAPI() {
|
|
|
List<Parameter> pars = addUseragent();
|
|
|
|
|
|
return new Docket(DocumentationType.SWAGGER_2)
|
|
|
.groupName(Doctor_API)
|
|
|
.genericModelSubstitutes(DeferredResult.class)
|
|
@ -59,9 +67,18 @@ public class SwaggerConfig {
|
|
|
.paths(or(regex("/doctor/.*"),
|
|
|
regex("/PC/.*")))
|
|
|
.build()
|
|
|
.globalOperationParameters(pars)
|
|
|
.apiInfo(publicApiInfo());
|
|
|
}
|
|
|
|
|
|
private List<Parameter> addUseragent() {
|
|
|
ParameterBuilder tokenPar = new ParameterBuilder();
|
|
|
List<Parameter> pars = new ArrayList<Parameter>();
|
|
|
tokenPar.name("userAgent").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
|
|
|
pars.add(tokenPar.build());
|
|
|
return pars;
|
|
|
}
|
|
|
|
|
|
private ApiInfo publicApiInfo() {
|
|
|
ApiInfo apiInfo = new ApiInfo("三师平台API",
|
|
|
"向PC端,微信、App等应用提供功能与数据接口。",
|
|
@ -77,6 +94,7 @@ public class SwaggerConfig {
|
|
|
|
|
|
@Bean
|
|
|
public Docket patientAPI() {
|
|
|
List<Parameter> pars = addUseragent();
|
|
|
return new Docket(DocumentationType.SWAGGER_2)
|
|
|
.groupName(Patient_API)
|
|
|
.genericModelSubstitutes(DeferredResult.class)
|
|
@ -86,6 +104,7 @@ public class SwaggerConfig {
|
|
|
.select()
|
|
|
.paths(PathSelectors.regex("/patient/.*"))
|
|
|
.build()
|
|
|
.globalOperationParameters(pars)
|
|
|
.apiInfo(patientApiInfo());
|
|
|
}
|
|
|
|