update
This commit is contained in:
@@ -58,28 +58,12 @@ public class Swagger2Config {
|
|||||||
.globalOperationParameters(pars);
|
.globalOperationParameters(pars);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Docket createDocketByPath (String groupName, String... paths){
|
|
||||||
List<Parameter> pars = getParameters();
|
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
|
||||||
.enable(Boolean.TRUE)
|
|
||||||
.apiInfo(this.getApiInfo())
|
|
||||||
.groupName(groupName)
|
|
||||||
.select()
|
|
||||||
.paths(this.scanPath(paths))
|
|
||||||
.build()
|
|
||||||
.globalOperationParameters(pars);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Parameter> getParameters() {
|
private List<Parameter> getParameters() {
|
||||||
List<Parameter> pars = new ArrayList<>();
|
List<Parameter> pars = new ArrayList<>();
|
||||||
pars.add(new ParameterBuilder().name("accessToken").description("令牌").required(true)
|
pars.add(new ParameterBuilder().name("accessToken").description("令牌").required(true)
|
||||||
.modelRef(new ModelRef("string"))
|
.modelRef(new ModelRef("string"))
|
||||||
.defaultValue("{{accessToken}}")
|
.defaultValue("{{accessToken}}")
|
||||||
.parameterType("query").build());
|
.parameterType("query").build());
|
||||||
pars.add(new ParameterBuilder().name("enterpriseId").required(true)
|
|
||||||
.modelRef(new ModelRef("string"))
|
|
||||||
.defaultValue("45f92210375346858b6b6694967f44de")
|
|
||||||
.parameterType("path").build());
|
|
||||||
return pars;
|
return pars;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,17 +78,6 @@ public class Swagger2Config {
|
|||||||
return predicate;
|
return predicate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Predicate<String> scanPath(final String... paths) {
|
|
||||||
Predicate<String> predicate = null;
|
|
||||||
for (String path : paths) {
|
|
||||||
if(StringUtils.isNotBlank(path)){
|
|
||||||
Predicate<String> tempPredicate = PathSelectors.ant(path);
|
|
||||||
predicate = predicate == null ? tempPredicate : Predicates.or(tempPredicate,predicate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Docket allApi() {
|
public Docket allApi() {
|
||||||
|
|||||||
@@ -58,28 +58,12 @@ public class Swagger2Config {
|
|||||||
.globalOperationParameters(pars);
|
.globalOperationParameters(pars);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Docket createDocketByPath (String groupName, String... paths){
|
|
||||||
List<Parameter> pars = getParameters();
|
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
|
||||||
.enable(Boolean.TRUE)
|
|
||||||
.apiInfo(this.getApiInfo())
|
|
||||||
.groupName(groupName)
|
|
||||||
.select()
|
|
||||||
.paths(this.scanPath(paths))
|
|
||||||
.build()
|
|
||||||
.globalOperationParameters(pars);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Parameter> getParameters() {
|
private List<Parameter> getParameters() {
|
||||||
List<Parameter> pars = new ArrayList<>();
|
List<Parameter> pars = new ArrayList<>();
|
||||||
pars.add(new ParameterBuilder().name("accessToken").description("令牌").required(true)
|
pars.add(new ParameterBuilder().name("accessToken").description("令牌").required(true)
|
||||||
.modelRef(new ModelRef("string"))
|
.modelRef(new ModelRef("string"))
|
||||||
.defaultValue("{{accessToken}}")
|
.defaultValue("{{accessToken}}")
|
||||||
.parameterType("query").build());
|
.parameterType("query").build());
|
||||||
pars.add(new ParameterBuilder().name("enterpriseId").required(true)
|
|
||||||
.modelRef(new ModelRef("string"))
|
|
||||||
.defaultValue("45f92210375346858b6b6694967f44de")
|
|
||||||
.parameterType("path").build());
|
|
||||||
return pars;
|
return pars;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,17 +78,6 @@ public class Swagger2Config {
|
|||||||
return predicate;
|
return predicate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Predicate<String> scanPath(final String... paths) {
|
|
||||||
Predicate<String> predicate = null;
|
|
||||||
for (String path : paths) {
|
|
||||||
if(StringUtils.isNotBlank(path)){
|
|
||||||
Predicate<String> tempPredicate = PathSelectors.ant(path);
|
|
||||||
predicate = predicate == null ? tempPredicate : Predicates.or(tempPredicate,predicate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Docket allApi() {
|
public Docket allApi() {
|
||||||
|
|||||||
Reference in New Issue
Block a user