修复当无请求参数时 requestExample无数据;生成example时忽略static和final字段

This commit is contained in:
xingzi 2019-12-31 17:32:57 +08:00
parent dde85485ca
commit 2df41667db
3 changed files with 9 additions and 2 deletions

View File

@ -118,4 +118,8 @@ public class DocGlobalConstants {
public static final String CURL_POST_JSON = "curl -X POST -H 'Content-Type: application/json; charset=utf-8' -i ";
public static final String ENMPTY = "";
public static final String STATIC = "static";
public static final String FINAL = "final";
}

View File

@ -137,7 +137,10 @@ public class JsonBuildHelper {
for (JavaField field : fields) {
String subTypeName = field.getType().getFullyQualifiedName();
String fieldName = field.getName();
if ("this$0".equals(fieldName) ||
boolean ignoreField = field.getModifiers().stream()
.anyMatch(str -> str.equals(DocGlobalConstants.STATIC) || str.equals(DocGlobalConstants.FINAL));
if (ignoreField || "this$0".equals(fieldName) ||
"serialVersionUID".equals(fieldName) ||
JavaClassValidateUtil.isIgnoreFieldTypes(subTypeName)) {
continue;

View File

@ -131,7 +131,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate {
String requestJson = requestExample.getExampleBody();
// set request example detail
apiMethodDoc.setRequestExample(requestExample);
apiMethodDoc.setRequestUsage(requestJson);
apiMethodDoc.setRequestUsage(requestJson==null?requestExample.getUrl():requestJson);
// build response usage
apiMethodDoc.setResponseUsage(JsonBuildHelper.buildReturnJson(method, projectBuilder));
// build response params