fix github #16

This commit is contained in:
oppofind 2019-12-19 12:36:54 +08:00
parent 53e003d3a0
commit 28aee05a54
2 changed files with 9 additions and 5 deletions

View File

@ -4,7 +4,6 @@ package com.power.doc.builder;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.power.common.util.FileUtil;
import com.power.common.util.ValidateUtil;
import com.power.doc.constants.DocGlobalConstants;
import com.power.doc.model.ApiConfig;
import com.power.doc.model.ApiDoc;
@ -17,6 +16,7 @@ import com.power.doc.model.postman.request.RequestBean;
import com.power.doc.model.postman.request.body.BodyBean;
import com.power.doc.model.postman.request.header.HeaderBean;
import com.thoughtworks.qdox.JavaProjectBuilder;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
@ -36,7 +36,7 @@ public class PostmanJsonBuilder {
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
builderTemplate.checkAndInit(config);
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
SourceBuilder sourceBuilder = new SourceBuilder(config,javaProjectBuilder);
SourceBuilder sourceBuilder = new SourceBuilder(config, javaProjectBuilder);
List<ApiDoc> apiDocList = sourceBuilder.getControllerApiData();
RequestItem requestItem = new RequestItem();
@ -97,7 +97,8 @@ public class PostmanJsonBuilder {
if (apiMethodDoc.getType().equals(DocGlobalConstants.HTTP_POST)) {
requestBean.setBody(buildBodyBean(apiMethodDoc));
} else {
if (!ValidateUtil.isNotUrl(apiMethodDoc.getRequestUsage())) {
if (StringUtils.isNotBlank(apiMethodDoc.getRequestUsage()) &&
apiMethodDoc.getRequestUsage().startsWith("http")) {
requestBean.setUrl(apiMethodDoc.getRequestUsage());
}
}

View File

@ -285,7 +285,10 @@ public class SourceBuilder {
List<ApiParam> requestParams = requestParams(method, DocTags.PARAM, cls.getCanonicalName());
apiMethodDoc.setRequestParams(requestParams);
String requestJson = buildReqJson(method, apiMethodDoc, isPostMethod);
apiMethodDoc.setRequestUsage(JsonFormatUtil.formatJson(requestJson));
if (StringUtil.isNotEmpty(requestJson) && !requestJson.startsWith("http")) {
requestJson = JsonFormatUtil.formatJson(requestJson);
}
apiMethodDoc.setRequestUsage(requestJson);
apiMethodDoc.setResponseUsage(buildReturnJson(method, this.fieldMap));
List<ApiParam> responseParams = buildReturnApiParams(method, cls.getGenericFullyQualifiedName());
@ -1099,7 +1102,7 @@ public class SourceBuilder {
} else {
url = DocUtil.formatAndRemove(uri, paramsMapTemp);
url = UrlUtil.urlJoin(url, paramsMapTemp);
if (uriCounter == 0) {
if (uriCounter == 0 && urls.length > 1) {
urlBuilder.append(url).append(";\t");
} else {
urlBuilder.append(url);