Skip to content

Commit

Permalink
ignore swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
shalousun committed Dec 3, 2020
1 parent 633da51 commit ebf9eee
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public boolean ignoreArtifactById(CustomArtifact artifact) {
case "gson":
case "annotations":
case "spring-aop":
case "springdoc-openapi-ui":
return true;
default:
return this.ignore(filterChain, artifact);
Expand Down
117 changes: 59 additions & 58 deletions src/main/java/com/smartdoc/gradle/chain/ContainsFilterChain.java
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
/*
* smart-doc https://github.com/shalousun/smart-doc
*
* Copyright (C) 2018-2020 smart-doc
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.smartdoc.gradle.chain;

import com.smartdoc.gradle.model.CustomArtifact;

import java.util.HashSet;
import java.util.Set;

/**
* @author yu 2020/1/13.
*/
public class ContainsFilterChain implements FilterChain {

private final static Set<String> CONTAINS_SET = new HashSet<>();

private FilterChain filterChain;

static {
CONTAINS_SET.add("log4j");
CONTAINS_SET.add("logback");
CONTAINS_SET.add("slf4j");
}

@Override
public void setNext(FilterChain nextInChain) {
this.filterChain = nextInChain;
}

@Override
public boolean ignoreArtifactById(CustomArtifact artifact) {
String artifactId = artifact.getArtifactId();
if (CONTAINS_SET.stream().anyMatch(artifactId::contains)) {
return true;
}
return this.ignore(filterChain, artifact);
}
}
/*
* smart-doc https://github.com/shalousun/smart-doc
*
* Copyright (C) 2018-2020 smart-doc
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.smartdoc.gradle.chain;

import com.smartdoc.gradle.model.CustomArtifact;

import java.util.HashSet;
import java.util.Set;

/**
* @author yu 2020/1/13.
*/
public class ContainsFilterChain implements FilterChain {

private final static Set<String> CONTAINS_SET = new HashSet<>();

private FilterChain filterChain;

static {
CONTAINS_SET.add("log4j");
CONTAINS_SET.add("logback");
CONTAINS_SET.add("slf4j");
CONTAINS_SET.add("swagger");
}

@Override
public void setNext(FilterChain nextInChain) {
this.filterChain = nextInChain;
}

@Override
public boolean ignoreArtifactById(CustomArtifact artifact) {
String artifactId = artifact.getArtifactId();
if (CONTAINS_SET.stream().anyMatch(artifactId::contains)) {
return true;
}
return this.ignore(filterChain, artifact);
}
}
11 changes: 8 additions & 3 deletions src/main/java/com/smartdoc/gradle/util/GradleUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.power.common.util.FileUtil;
import com.power.common.util.StringUtil;
import com.power.doc.model.*;
import org.gradle.api.Project;
import org.gradle.api.logging.Logger;
Expand Down Expand Up @@ -71,30 +72,34 @@ public static ApiConfig buildConfig(File configFile, Project project, Logger log
List<ApiDataDictionary> apiDataDictionaries = apiConfig.getDataDictionaries();
List<ApiErrorCodeDictionary> apiErrorCodes = apiConfig.getErrorCodeDictionaries();
List<ApiConstant> apiConstants = apiConfig.getApiConstants();
if (apiErrorCodes != null) {
ResponseBodyAdvice responseBodyAdvice = apiConfig.getResponseBodyAdvice();
if (Objects.nonNull(apiErrorCodes)) {
apiErrorCodes.forEach(
apiErrorCode -> {
String className = apiErrorCode.getEnumClassName();
apiErrorCode.setEnumClass(getClassByClassName(className, classLoader));
}
);
}
if (apiDataDictionaries != null) {
if (Objects.nonNull(apiDataDictionaries)) {
apiDataDictionaries.forEach(
apiDataDictionary -> {
String className = apiDataDictionary.getEnumClassName();
apiDataDictionary.setEnumClass(getClassByClassName(className, classLoader));
}
);
}
if (apiConstants != null) {
if (Objects.nonNull(apiConstants)) {
apiConstants.forEach(
apiConstant -> {
String className = apiConstant.getConstantsClassName();
apiConstant.setConstantsClass(getClassByClassName(className, classLoader));
}
);
}
if (Objects.nonNull(responseBodyAdvice) && StringUtil.isNotEmpty(responseBodyAdvice.getClassName())) {
responseBodyAdvice.setWrapperClass(getClassByClassName(responseBodyAdvice.getClassName(), classLoader));
}
addSourcePaths(project, apiConfig, log);
return apiConfig;
} catch (FileNotFoundException e) {
Expand Down

0 comments on commit ebf9eee

Please sign in to comment.