Skip to content

Commit

Permalink
update swagger 3.0.0、hutool 5.7.9
Browse files Browse the repository at this point in the history
  • Loading branch information
theshy9999 committed Aug 29, 2021
1 parent e3e3a94 commit 56ffe58
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 555 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<jedis.version>2.9.0</jedis.version>
<swagger.version>2.9.2</swagger.version>
<swagger.version>3.0.0</swagger.version>
<fastjson.version>1.2.75</fastjson.version>
<druid.version>1.1.10</druid.version>
<hutool.version>5.2.5</hutool.version>
<hutool.version>5.7.9</hutool.version>
<commons-pool2.version>2.5.0</commons-pool2.version>
<mapstruct.version>1.2.0.Final</mapstruct.version>
</properties>
Expand Down Expand Up @@ -127,13 +127,13 @@
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.21</version>
<version>1.5.24</version>
</dependency>
<!--单应用-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.1</version>
<version>3.0.3</version>
</dependency>
<!--Mysql依赖包-->
<dependency>
Expand Down
25 changes: 12 additions & 13 deletions yshop-common/src/main/java/co/yixiang/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
import org.springframework.data.domain.Pageable;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.builders.RequestParameterBuilder;
import springfox.documentation.schema.AlternateTypeRule;
import springfox.documentation.schema.AlternateTypeRuleConvention;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.schema.ScalarType;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.Parameter;
import springfox.documentation.service.ParameterType;
import springfox.documentation.service.RequestParameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
Expand Down Expand Up @@ -71,23 +72,21 @@ public class SwaggerConfig {
@Bean
@SuppressWarnings("all")
public Docket createRestApi() {
ParameterBuilder ticketPar = new ParameterBuilder();
List<Parameter> pars = new ArrayList<>();
ticketPar.name(tokenHeader).description("token")
.modelRef(new ModelRef("string"))
.parameterType("header")
.defaultValue(tokenStartWith + " ")
.required(true)
.build();
RequestParameterBuilder ticketPar = new RequestParameterBuilder();
List<RequestParameter> pars = new ArrayList<>();
ticketPar.description("token").name(tokenHeader)
.in(ParameterType.HEADER).required(true)
.query(param -> param.model(model -> model.scalarModel(ScalarType.STRING)));
pars.add(ticketPar.build());

return new Docket(DocumentationType.SWAGGER_2)
.enable(enabled)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("co.yixiang.modules"))
.paths(Predicates.not(PathSelectors.regex("/error.*")))
.paths(PathSelectors.regex("/error.*").negate())
.build()
.globalOperationParameters(pars);
.globalRequestParameters(pars);
}

private ApiInfo apiInfo() {
Expand Down
Loading

0 comments on commit 56ffe58

Please sign in to comment.