Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
shalousun committed May 9, 2021
2 parents 52811aa + d9c97b9 commit 8a09d51
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## smart-doc版本
版本小于1.0都属于试用,正式1.0起始发布将会等到文中提到的问题解决后才发布。
#### 版本号:2.1.6
- 更新日期: 2020-05-10
- 更新内容:
1. 修复不允许List中放文件上传对象错误的bug。
2. 添加推送接口作者信息到torna。
3. 添加推送queryParams参数到torna(需要使用torna 1.6.0+)
#### 版本号:2.1.5
- 更新日期: 2020-05-05
- 更新内容:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>smart-doc</artifactId>
<packaging>jar</packaging>
<version>2.1.5</version>
<version>2.1.6</version>

<name>smart-doc</name>
<url>https://github.com/smart-doc-group/smart-doc.git</url>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/power/doc/builder/TornaBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public static void buildTorna(List<ApiDoc> apiDocs, ApiConfig apiConfig) {
api.setName(StringUtils.isBlank(a.getDesc()) ? a.getName() : a.getDesc());
api.setItems(buildApis(a.getList(), TornaUtil.setDebugEnv(apiConfig,tornaApi)));
api.setIsFolder(TornaConstants.YES);
api.setAuthor(apiConfig.getAuthor());
apisList.add(api);
}
tornaApi.setApis(apisList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static void buildTorna(List<RpcApiDoc> apiDocs, ApiConfig apiConfig) {
TornaUtil.setDebugEnv(apiConfig,tornaApi);
api.setItems(buildDubboApis(a.getList()));
api.setIsFolder(TornaConstants.YES);
api.setAuthor(apiConfig.getAuthor());
api.setDubboInfo(new DubboInfo().builder()
.setAuthor(a.getAuthor())
.setProtocol(a.getProtocol())
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/power/doc/model/ApiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,14 @@ public class ApiConfig {
/**
* 是否为dubbo
*/
private boolean isDubbo;
private String author;

public boolean isDubbo() {
return isDubbo;
public String getAuthor() {
return author;
}

public void setDubbo(boolean dubbo) {
this.isDubbo = dubbo;
public void setAuthor(String author) {
this.author = author;
}

public boolean isTornaDebug() {
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/power/doc/model/torna/Apis.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,24 @@ public class Apis {
private String isFolder;
private String parentId;
private String isShow;
private String author;
private DubboInfo dubboInfo;
private List<HttpParam> headerParams;
private List<HttpParam> pathParams;
private List<HttpParam> queryParams;
private List<HttpParam> requestParams;
private List<HttpParam> responseParams;
private String errorCodeParams;
private List<Apis> items;

public String getAuthor() {
return author;
}

public void setAuthor(String author) {
this.author = author;
}

public String getName() {
return name;
}
Expand Down Expand Up @@ -108,6 +118,13 @@ public void setIsShow(String isShow) {
this.isShow = isShow;
}

public List<HttpParam> getQueryParams() {
return queryParams;
}

public void setQueryParams(List<HttpParam> queryParams) {
this.queryParams = queryParams;
}

public List<HttpParam> getRequestParams() {
return requestParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@

import static com.power.doc.constants.DocGlobalConstants.FILE_CONTENT_TYPE;
import static com.power.doc.constants.DocGlobalConstants.JSON_CONTENT_TYPE;
import static com.power.doc.constants.DocTags.*;
import static com.power.doc.constants.DocTags.IGNORE;
import static com.power.doc.constants.DocTags.IGNORE_REQUEST_BODY_ADVICE;

/**
* @author yu 2019/12/21.
Expand Down Expand Up @@ -371,7 +372,7 @@ private ApiRequestExample buildReqJson(DocJavaMethod javaMethod, ApiMethodDoc ap
typeName = configBuilder.getApiConfig().getRequestBodyAdvice().getClassName();
gicTypeName = requestBodyAdvice + "<" + gicTypeName + ">";

}
}

if (JavaClassValidateUtil.isPrimitive(simpleTypeName)) {
StringBuilder builder = new StringBuilder();
Expand Down Expand Up @@ -420,7 +421,7 @@ private ApiRequestExample buildReqJson(DocJavaMethod javaMethod, ApiMethodDoc ap
gicName = gicName.substring(0, gicName.indexOf("["));
}
if (!JavaClassValidateUtil.isPrimitive(gicName)
&&!configBuilder.getJavaProjectBuilder().getClassByName(gicName).isEnum()) {
&& !configBuilder.getJavaProjectBuilder().getClassByName(gicName).isEnum()) {
throw new RuntimeException("Spring MVC can't support binding Collection on method "
+ method.getName() + "Check it in " + method.getDeclaringClass().getCanonicalName());
}
Expand Down Expand Up @@ -602,7 +603,7 @@ private ApiMethodReqParam requestParams(final DocJavaMethod docJavaMethod, Proje
.setId(paramList.size() + 1).setQueryParam(true)
.setRequired(true).setVersion(DocGlobalConstants.DEFAULT_VERSION)
.setDesc(comment);
if (typeName.contains("[]")) {
if (typeName.contains("[]") || typeName.endsWith(">")) {
comment = comment + "(array of file)";
param.setDesc(comment);
param.setHasItems(true);
Expand Down Expand Up @@ -661,7 +662,7 @@ private ApiMethodReqParam requestParams(final DocJavaMethod docJavaMethod, Proje
if (Objects.nonNull(builder.getApiConfig().getRequestBodyAdvice())
&& Objects.isNull(javaMethod.getTagByName(IGNORE_REQUEST_BODY_ADVICE))) {
String requestBodyAdvice = builder.getApiConfig().getRequestBodyAdvice().getClassName();
fullTypeName = typeName = requestBodyAdvice + "<" + typeName + ">";
fullTypeName = typeName = requestBodyAdvice + "<" + typeName + ">";

}
requestBodyCounter++;
Expand All @@ -683,7 +684,7 @@ private ApiMethodReqParam requestParams(final DocJavaMethod docJavaMethod, Proje
gicName = gicName.substring(0, gicName.indexOf("["));
}
JavaClass gicJavaClass = builder.getJavaProjectBuilder().getClassByName(gicName);
if(gicJavaClass.isEnum()){
if (gicJavaClass.isEnum()) {
Object value = JavaClassUtil.getEnumValue(gicJavaClass, Boolean.TRUE);
ApiParam param = ApiParam.of().setField(paramName).setDesc(comment + ",[array of enum]")
.setRequired(required)
Expand All @@ -704,7 +705,7 @@ private ApiMethodReqParam requestParams(final DocJavaMethod docJavaMethod, Proje
.setQueryParam(queryParam)
.setId(paramList.size() + 1)
.setType("array")
.setValue(DocUtil.getValByTypeAndFieldName(gicName,paramName));
.setValue(DocUtil.getValByTypeAndFieldName(gicName, paramName));
paramList.add(param);
if (requestBodyCounter > 0) {
Map<String, Object> map = OpenApiSchemaUtil.arrayTypeSchema(gicName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ public static boolean isFile(String typeName){
case "org.springframework.web.multipart.MultipartFile[]":
case "org.springframework.web.multipart.commons.CommonsMultipartFile":
case "org.springframework.web.multipart.commons.CommonsMultipartFile[]":
case "java.util.List<org.springframework.web.multipart.MultipartFile>":
return true;
default:
return false;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/power/doc/utils/TornaUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public static List<Apis> buildApis(List<ApiMethodDoc> apiMethodDocs, boolean has
methodApi.setContentType(apiMethodDoc.getContentType());
methodApi.setDescription(apiMethodDoc.getDetail());
methodApi.setIsShow(TornaConstants.YES);
methodApi.setAuthor(apiMethodDoc.getAuthor());

/**
* {
Expand Down Expand Up @@ -129,7 +130,7 @@ public static List<Apis> buildApis(List<ApiMethodDoc> apiMethodDocs, boolean has
}
//formData
if (CollectionUtil.isNotEmpty(apiMethodDoc.getQueryParams())) {
methodApi.setRequestParams(buildParams(apiMethodDoc.getQueryParams()));
methodApi.setQueryParams(buildParams(apiMethodDoc.getQueryParams()));
}
//Json
if (CollectionUtil.isNotEmpty(apiMethodDoc.getRequestParams())) {
Expand Down Expand Up @@ -167,6 +168,7 @@ public static List<Apis> buildDubboApis(List<JavaMethodDoc> apiMethodDocs) {
methodApi.setName(apiMethodDoc.getDesc());
methodApi.setDescription(apiMethodDoc.getDetail());
methodApi.setIsShow(TornaConstants.YES);
methodApi.setAuthor(apiMethodDoc.getAuthor());
methodApi.setUrl(apiMethodDoc.getMethodDefinition());

/**
Expand Down

0 comments on commit 8a09d51

Please sign in to comment.