4 changed files with 60 additions and 60 deletions
@ -1,5 +1,5 @@ |
|||
spring: |
|||
profiles: |
|||
active: prod |
|||
include: util-prod,common |
|||
active: dev |
|||
include: util-dev,common |
|||
|
|||
|
@ -1,56 +1,56 @@ |
|||
package com.ccsens.wechatutil.config; |
|||
|
|||
import com.ccsens.util.WebConstant; |
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import springfox.documentation.builders.ParameterBuilder; |
|||
import springfox.documentation.builders.RequestHandlerSelectors; |
|||
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; |
|||
|
|||
@Configuration |
|||
@EnableSwagger2 |
|||
@ConditionalOnExpression("${swagger.enable}") |
|||
//public class SwaggerConfigure extends WebMvcConfigurationSupport {
|
|||
public class SwaggerConfigure /*implements WebMvcConfigurer*/ { |
|||
@Bean |
|||
public Docket customDocket() { |
|||
//
|
|||
return new Docket(DocumentationType.SWAGGER_2) |
|||
.apiInfo(apiInfo()) |
|||
.select() |
|||
.apis(RequestHandlerSelectors |
|||
.basePackage("com.ccsens.signin.api")) |
|||
.build() |
|||
.globalOperationParameters(setHeaderToken()); |
|||
} |
|||
|
|||
private ApiInfo apiInfo() { |
|||
return new ApiInfo("Swagger Tall-game",//大标题 title
|
|||
"This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",//小标题
|
|||
"1.0.0",//版本
|
|||
"http://swagger.io/terms/",//termsOfServiceUrl
|
|||
"zhangsan",//作者
|
|||
"Apache 2.0",//链接显示文字
|
|||
"http://www.apache.org/licenses/LICENSE-2.0.html"//网站链接
|
|||
); |
|||
} |
|||
|
|||
private List<Parameter> setHeaderToken() { |
|||
ParameterBuilder tokenPar = new ParameterBuilder(); |
|||
List<Parameter> pars = new ArrayList<>(); |
|||
tokenPar.name(WebConstant.HEADER_KEY_TOKEN).description("token") |
|||
.defaultValue(WebConstant.HEADER_KEY_TOKEN_PREFIX) |
|||
.modelRef(new ModelRef("string")).parameterType("header").required(false).build(); |
|||
pars.add(tokenPar.build()); |
|||
return pars; |
|||
} |
|||
} |
|||
//package com.ccsens.wechatutil.config;
|
|||
//
|
|||
//import com.ccsens.util.WebConstant;
|
|||
//import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
|||
//import org.springframework.context.annotation.Bean;
|
|||
//import org.springframework.context.annotation.Configuration;
|
|||
//import springfox.documentation.builders.ParameterBuilder;
|
|||
//import springfox.documentation.builders.RequestHandlerSelectors;
|
|||
//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;
|
|||
//
|
|||
//@Configuration
|
|||
//@EnableSwagger2
|
|||
//@ConditionalOnExpression("${swagger.enable}")
|
|||
////public class SwaggerConfigure extends WebMvcConfigurationSupport {
|
|||
//public class SwaggerConfigure /*implements WebMvcConfigurer*/ {
|
|||
// @Bean
|
|||
// public Docket customDocket() {
|
|||
// //
|
|||
// return new Docket(DocumentationType.SWAGGER_2)
|
|||
// .apiInfo(apiInfo())
|
|||
// .select()
|
|||
// .apis(RequestHandlerSelectors
|
|||
// .basePackage("com.ccsens.signin.api"))
|
|||
// .build()
|
|||
// .globalOperationParameters(setHeaderToken());
|
|||
// }
|
|||
//
|
|||
// private ApiInfo apiInfo() {
|
|||
// return new ApiInfo("Swagger Tall-game",//大标题 title
|
|||
// "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",//小标题
|
|||
// "1.0.0",//版本
|
|||
// "http://swagger.io/terms/",//termsOfServiceUrl
|
|||
// "zhangsan",//作者
|
|||
// "Apache 2.0",//链接显示文字
|
|||
// "http://www.apache.org/licenses/LICENSE-2.0.html"//网站链接
|
|||
// );
|
|||
// }
|
|||
//
|
|||
// private List<Parameter> setHeaderToken() {
|
|||
// ParameterBuilder tokenPar = new ParameterBuilder();
|
|||
// List<Parameter> pars = new ArrayList<>();
|
|||
// tokenPar.name(WebConstant.HEADER_KEY_TOKEN).description("token")
|
|||
// .defaultValue(WebConstant.HEADER_KEY_TOKEN_PREFIX)
|
|||
// .modelRef(new ModelRef("string")).parameterType("header").required(false).build();
|
|||
// pars.add(tokenPar.build());
|
|||
// return pars;
|
|||
// }
|
|||
//}
|
|||
|
Loading…
Reference in new issue