|
@@ -7,13 +7,19 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import springfox.documentation.builders.ApiInfoBuilder;
|
|
import springfox.documentation.builders.ApiInfoBuilder;
|
|
|
|
+import springfox.documentation.builders.ParameterBuilder;
|
|
import springfox.documentation.builders.PathSelectors;
|
|
import springfox.documentation.builders.PathSelectors;
|
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
|
|
|
+import springfox.documentation.schema.ModelRef;
|
|
import springfox.documentation.service.ApiInfo;
|
|
import springfox.documentation.service.ApiInfo;
|
|
|
|
+import springfox.documentation.service.Parameter;
|
|
import springfox.documentation.spi.DocumentationType;
|
|
import springfox.documentation.spi.DocumentationType;
|
|
import springfox.documentation.spring.web.plugins.Docket;
|
|
import springfox.documentation.spring.web.plugins.Docket;
|
|
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
|
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
@EnableSwagger2WebMvc
|
|
@EnableSwagger2WebMvc
|
|
@Configuration
|
|
@Configuration
|
|
@ConditionalOnProperty(name = "scancentral.swagger.enable", havingValue = "true")
|
|
@ConditionalOnProperty(name = "scancentral.swagger.enable", havingValue = "true")
|
|
@@ -24,9 +30,18 @@ public class SwaggerConfig {
|
|
@Bean
|
|
@Bean
|
|
public Docket buildDocket(SysProperty sysProperty) {
|
|
public Docket buildDocket(SysProperty sysProperty) {
|
|
log.info("swagger init...");
|
|
log.info("swagger init...");
|
|
- return new Docket(DocumentationType.SWAGGER_2).groupName("default").apiInfo(buildApiInfo(sysProperty))
|
|
|
|
|
|
+
|
|
|
|
+ List<Parameter> parameters = new ArrayList<>();
|
|
|
|
+ parameters.add(new ParameterBuilder().name("Authorization").modelRef(new ModelRef("String")).parameterType("header").required(false).build());
|
|
|
|
+ parameters.add(new ParameterBuilder().name("time").modelRef(new ModelRef("String")).parameterType("header").required(false).build());
|
|
|
|
+
|
|
|
|
+ return new Docket(DocumentationType.SWAGGER_2)
|
|
|
|
+ .groupName("default")
|
|
|
|
+ .apiInfo(buildApiInfo(sysProperty))
|
|
|
|
+ .globalOperationParameters(parameters)
|
|
.useDefaultResponseMessages(false).select()
|
|
.useDefaultResponseMessages(false).select()
|
|
- .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)).paths(PathSelectors.any())
|
|
|
|
|
|
+ .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
|
|
|
+ .paths(PathSelectors.any())
|
|
.build();
|
|
.build();
|
|
}
|
|
}
|
|
|
|
|