This commit is contained in:
oppofind 2020-11-14 13:22:35 +08:00
parent 9f35c0630f
commit c6f290579f
3 changed files with 42 additions and 44 deletions

View File

@ -5,7 +5,8 @@
- 更新内容:
1. 修改1.9.8启用严格检查注释模式下的bug。
2. 修改使用泛型数组参数时解析错误。
3. 修复ResponseEntity中的数组解析错误
3. 修复ResponseEntity中的数组解析错误。
4. 修复controller方法标注ignore后文档序号错误。
#### 版本号1.9.8
- 更新日期: 2020-11-10
- 更新内容:

View File

@ -54,6 +54,7 @@ public class RpcDocBuildTemplate implements IDocBuildTemplate<RpcApiDoc> {
*/
private final AtomicInteger atomicInteger = new AtomicInteger(1);
@Override
public List<RpcApiDoc> getApiData(ProjectDocConfigBuilder projectBuilder) {
ApiConfig apiConfig = projectBuilder.getApiConfig();
List<RpcApiDoc> apiDocList = new ArrayList<>();

View File

@ -147,7 +147,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
int methodOrder = 0;
for (DocJavaMethod docJavaMethod : docJavaMethods) {
JavaMethod method = docJavaMethod.getJavaMethod();
if (method.isPrivate()) {
if (method.isPrivate() || Objects.nonNull(method.getTagByName(IGNORE))) {
continue;
}
if (StringUtil.isEmpty(method.getComment()) && apiConfig.isStrict()) {
@ -155,8 +155,8 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
}
methodOrder++;
ApiMethodDoc apiMethodDoc = new ApiMethodDoc();
apiMethodDoc.setOrder(methodOrder);
apiMethodDoc.setName(method.getName());
apiMethodDoc.setOrder(methodOrder);
String comment = DocUtil.getEscapeAndCleanComment(method.getComment());
apiMethodDoc.setDesc(comment);
String methodUid = DocUtil.generateId(clazName + method.getName());
@ -179,49 +179,45 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
.handle(projectBuilder.getServerUrl(), baseUrl, method, constantsMap);
//handle headers
List<ApiReqHeader> apiReqHeaders = new SpringMVCRequestHeaderHandler().handle(method);
if (Objects.nonNull(requestMapping)) {
if (null != method.getTagByName(IGNORE)) {
continue;
}
apiMethodDoc.setType(requestMapping.getMethodType());
apiMethodDoc.setUrl(requestMapping.getUrl());
apiMethodDoc.setServerUrl(projectBuilder.getServerUrl());
apiMethodDoc.setPath(requestMapping.getShortUrl());
apiMethodDoc.setDeprecated(requestMapping.isDeprecated());
// build request params
List<ApiParam> requestParams = requestParams(docJavaMethod, projectBuilder);
if (paramsDataToTree) {
requestParams = ApiParamTreeUtil.apiParamToTree(requestParams);
}
apiMethodDoc.setRequestParams(requestParams);
List<ApiReqHeader> allApiReqHeaders;
if (this.headers != null) {
allApiReqHeaders = Stream.of(this.headers, apiReqHeaders)
.flatMap(Collection::stream).distinct().collect(Collectors.toList());
} else {
allApiReqHeaders = apiReqHeaders;
}
//reduce create in template
apiMethodDoc.setHeaders(this.createDocRenderHeaders(allApiReqHeaders, apiConfig.isAdoc()));
apiMethodDoc.setRequestHeaders(allApiReqHeaders);
// build request json
ApiRequestExample requestExample = buildReqJson(docJavaMethod, apiMethodDoc, requestMapping.getMethodType(),
projectBuilder);
String requestJson = requestExample.getExampleBody();
// set request example detail
apiMethodDoc.setRequestExample(requestExample);
apiMethodDoc.setRequestUsage(requestJson == null ? requestExample.getUrl() : requestJson);
// build response usage
apiMethodDoc.setResponseUsage(JsonBuildHelper.buildReturnJson(docJavaMethod, projectBuilder));
// build response params
List<ApiParam> responseParams = buildReturnApiParams(docJavaMethod, projectBuilder);
if (paramsDataToTree) {
responseParams = ApiParamTreeUtil.apiParamToTree(responseParams);
}
apiMethodDoc.setResponseParams(responseParams);
methodDocList.add(apiMethodDoc);
apiMethodDoc.setType(requestMapping.getMethodType());
apiMethodDoc.setUrl(requestMapping.getUrl());
apiMethodDoc.setServerUrl(projectBuilder.getServerUrl());
apiMethodDoc.setPath(requestMapping.getShortUrl());
apiMethodDoc.setDeprecated(requestMapping.isDeprecated());
// build request params
List<ApiParam> requestParams = requestParams(docJavaMethod, projectBuilder);
if (paramsDataToTree) {
requestParams = ApiParamTreeUtil.apiParamToTree(requestParams);
}
apiMethodDoc.setRequestParams(requestParams);
List<ApiReqHeader> allApiReqHeaders;
if (this.headers != null) {
allApiReqHeaders = Stream.of(this.headers, apiReqHeaders)
.flatMap(Collection::stream).distinct().collect(Collectors.toList());
} else {
allApiReqHeaders = apiReqHeaders;
}
//reduce create in template
apiMethodDoc.setHeaders(this.createDocRenderHeaders(allApiReqHeaders, apiConfig.isAdoc()));
apiMethodDoc.setRequestHeaders(allApiReqHeaders);
// build request json
ApiRequestExample requestExample = buildReqJson(docJavaMethod, apiMethodDoc, requestMapping.getMethodType(),
projectBuilder);
String requestJson = requestExample.getExampleBody();
// set request example detail
apiMethodDoc.setRequestExample(requestExample);
apiMethodDoc.setRequestUsage(requestJson == null ? requestExample.getUrl() : requestJson);
// build response usage
apiMethodDoc.setResponseUsage(JsonBuildHelper.buildReturnJson(docJavaMethod, projectBuilder));
// build response params
List<ApiParam> responseParams = buildReturnApiParams(docJavaMethod, projectBuilder);
if (paramsDataToTree) {
responseParams = ApiParamTreeUtil.apiParamToTree(responseParams);
}
apiMethodDoc.setResponseParams(responseParams);
methodDocList.add(apiMethodDoc);
}
return methodDocList;
}