Skip to content

Commit

Permalink
upgrade smart-doc to 1.8.9
Browse files Browse the repository at this point in the history
  • Loading branch information
shalousun committed Jul 3, 2020
1 parent 9e56cce commit b9f5a1b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ When you need to use smart-doc to generate more API document information, you ca
"version":"1.0.0"
}
],
"apiConstants": [{//Configure your own constant class, smart-doc automatically replaces with a specific value when parsing to a constant
"constantsClassName": "com.power.doc.constants.RequestParamConstant"
}],
  "requestHeaders": [// Set global request headers, no need to set
    {
      "name": "token",
Expand Down
4 changes: 3 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ subprojects{
"since": "-"
}
],
"apiConstants": [{//从1.8.9开始配置自己的常量类,smart-doc在解析到常量时自动替换为具体的值
"constantsClassName": "com.power.doc.constants.RequestParamConstant"
}],
"sourceCodePaths": [ //设置代码路径,默认加载src/main/java, 没有需求可以不设置
{
"path": "src/main/java",
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ plugins {
}

group 'com.github.shalousun'
version '1.1.0'
version '1.1.1'

sourceCompatibility = 1.8

Expand Down
14 changes: 10 additions & 4 deletions src/main/java/com/smartdoc/gradle/util/GradleUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.power.common.util.FileUtil;
import com.power.doc.model.ApiConfig;
import com.power.doc.model.ApiDataDictionary;
import com.power.doc.model.ApiErrorCodeDictionary;
import com.power.doc.model.SourceCodePath;
import com.power.doc.model.*;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
Expand Down Expand Up @@ -77,6 +74,7 @@ public static ApiConfig buildConfig(File configFile, Project project, Logger log
ApiConfig apiConfig = GSON.fromJson(data, ApiConfig.class);
List<ApiDataDictionary> apiDataDictionaries = apiConfig.getDataDictionaries();
List<ApiErrorCodeDictionary> apiErrorCodes = apiConfig.getErrorCodeDictionaries();
List<ApiConstant> apiConstants = apiConfig.getApiConstants();
if (apiErrorCodes != null) {
apiErrorCodes.forEach(
apiErrorCode -> {
Expand All @@ -93,6 +91,14 @@ public static ApiConfig buildConfig(File configFile, Project project, Logger log
}
);
}
if (apiConstants != null) {
apiConstants.forEach(
apiConstant -> {
String className = apiConstant.getConstantsClassName();
apiConstant.setConstantsClass(getClassByClassName(className, classLoader));
}
);
}
addSourcePaths(project, apiConfig, log);
return apiConfig;
} catch (FileNotFoundException e) {
Expand Down

0 comments on commit b9f5a1b

Please sign in to comment.