|
@@ -8,6 +8,7 @@ import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
import com.fjs.scenic.utils.Cons;
|
|
|
|
|
|
+import org.springframework.context.annotation.Profile;
|
|
|
import springfox.documentation.builders.ApiInfoBuilder;
|
|
|
import springfox.documentation.builders.ParameterBuilder;
|
|
|
import springfox.documentation.builders.PathSelectors;
|
|
@@ -21,18 +22,19 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
|
|
|
|
@Configuration
|
|
|
@EnableSwagger2
|
|
|
+@Profile({"dev"})
|
|
|
public class Swagger2 {
|
|
|
|
|
|
@Bean
|
|
|
public Docket createRestApi() {
|
|
|
- //添加head参数start
|
|
|
- ParameterBuilder tokenPar = new ParameterBuilder();
|
|
|
- List<Parameter> pars = new ArrayList<Parameter>();
|
|
|
+ //添加head参数start
|
|
|
+ ParameterBuilder tokenPar = new ParameterBuilder();
|
|
|
+ List<Parameter> pars = new ArrayList<Parameter>();
|
|
|
tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
|
|
|
- pars.add(tokenPar.build());
|
|
|
-
|
|
|
+ pars.add(tokenPar.build());
|
|
|
+
|
|
|
return new Docket(DocumentationType.SWAGGER_2)
|
|
|
- .enable(true)
|
|
|
+ .enable(false)
|
|
|
.apiInfo(apiInfo())
|
|
|
.select()
|
|
|
.apis(RequestHandlerSelectors.basePackage("com.fjs.scenic"))
|
|
@@ -40,7 +42,7 @@ public class Swagger2 {
|
|
|
.build()
|
|
|
.globalOperationParameters(pars);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private ApiInfo apiInfo() {
|
|
|
return new ApiInfoBuilder()
|
|
|
.title("RESULTful API")
|
|
@@ -49,5 +51,5 @@ public class Swagger2 {
|
|
|
.version("1.0")
|
|
|
.build();
|
|
|
}
|
|
|
-
|
|
|
-}
|
|
|
+
|
|
|
+}
|