添加 apiNote 解析方法的描述

This commit is contained in:
chenhaitian 2019-10-16 18:05:33 +08:00
parent 360aabe9e7
commit f1253468d6
9 changed files with 32 additions and 2 deletions

View File

@ -46,6 +46,8 @@ public class SourceBuilder {
private static final String NO_COMMENTS_FOUND = "No comments found.";
private static final String METHOD_DESCRIPTION = "apiNote";
private Map<String, JavaClass> javaFilesMap = new HashMap<>();
private Map<String, CustomRespField> fieldMap = new HashMap<>();
@ -185,6 +187,12 @@ public class SourceBuilder {
ApiMethodDoc apiMethodDoc = new ApiMethodDoc();
apiMethodDoc.setOrder(methodOrder);
apiMethodDoc.setDesc(method.getComment());
Map<String,String> comment = DocUtil.getParamsComments(method,METHOD_DESCRIPTION,cls.getName());
String methodDesc = comment.get(METHOD_DESCRIPTION);
if(StringUtil.isEmpty(methodDesc)){
methodDesc = method.getComment();
}
apiMethodDoc.setDescription(methodDesc);
List<JavaAnnotation> annotations = method.getAnnotations();
String url = null;
String methodType = null;

View File

@ -22,6 +22,11 @@ public class ApiMethodDoc implements Serializable {
*/
private String desc;
/**
* detailed introduction of the method
*/
private String description;
/**
* controller method url
*/
@ -157,4 +162,12 @@ public class ApiMethodDoc implements Serializable {
public void setRequestHeaders(List<ApiReqHeader> requestHeaders) {
this.requestHeaders = requestHeaders;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@ -271,7 +271,7 @@ public class DocUtil {
String value = docletTag.getValue();
if (StringUtil.isEmpty(value)) {
throw new RuntimeException("ERROR: #" + javaMethod.getName()
+ "() - bad @param javadoc from " + className);
+ "() - bad @"+tagName+" javadoc from " + className);
}
String pName;
String pValue;

View File

@ -25,6 +25,8 @@ for(doc in api.list){
*Type:* ${doc.type}
*Description:* ${doc.description}
*Content-Type:* ${doc.contentType}
<%if(isNotEmpty(doc.headers)){%>

View File

@ -24,6 +24,8 @@ for(doc in api.list){
**Content-Type:** ${doc.contentType}
**Description:** ${doc.description}
<%if(isNotEmpty(doc.headers)){%>
**Request-headers:**

File diff suppressed because one or more lines are too long

View File

@ -10,6 +10,8 @@ for(doc in list){
*Content-Type:* `${doc.contentType}`
*Description:* ${doc.description}
<%if(isNotEmpty(doc.headers)){%>
*Request-headers:*

View File

@ -10,6 +10,8 @@ for(doc in list){
**Content-Type:** `${doc.contentType}`
**Description:** ${doc.description}
<%if(isNotEmpty(doc.headers)){%>
**Request-headers:**

View File

@ -58,6 +58,7 @@
<p><strong>URL:</strong>${doc.url}</p>
<p><strong>Type:</strong>${doc.type}</p>
<p><strong>Content-Type:</strong> ${doc.contentType}</p>
<p><strong>Description:</strong> ${doc.description}</p>
<%if(isNotEmpty(doc.requestHeaders)){%>
<p><strong>Request-headers:</strong></p>