diff --git a/apidoc-core/src/main/java/com/kim/apidoc/core/common/description/ObjectTypeDescription.java b/apidoc-core/src/main/java/com/kim/apidoc/core/common/description/ObjectTypeDescription.java index cdb571fd1909100c38ea6f6d57cb67f52d5136c0..746ab04de500d76231be666f3265d58126a76473 100644 --- a/apidoc-core/src/main/java/com/kim/apidoc/core/common/description/ObjectTypeDescription.java +++ b/apidoc-core/src/main/java/com/kim/apidoc/core/common/description/ObjectTypeDescription.java @@ -104,4 +104,15 @@ public class ObjectTypeDescription extends TypeDescription { } return rows; } + + @Override + public Collection rows(String requestParameterType) { + Collection rows = super.rows(null); + for (TypeDescription member : members) { + if (member.isAvailable()) { + rows.addAll(member.rows(requestParameterType)); + } + } + return rows; + } } diff --git a/apidoc-core/src/main/java/com/kim/apidoc/core/common/description/TypeDescription.java b/apidoc-core/src/main/java/com/kim/apidoc/core/common/description/TypeDescription.java index 9aecef016635c447d5f4b279cb8852a7eee8b463..0727e22e15469b20bc6a4de103d0035c783a7996 100644 --- a/apidoc-core/src/main/java/com/kim/apidoc/core/common/description/TypeDescription.java +++ b/apidoc-core/src/main/java/com/kim/apidoc/core/common/description/TypeDescription.java @@ -199,7 +199,7 @@ public abstract class TypeDescription { * @return the collection */ public Collection rows() { - return rows(null); + return this.rows(null); } public void accept(Comment comment) { diff --git a/apidoc-core/src/main/java/com/kim/apidoc/core/parser/VisitorParser.java b/apidoc-core/src/main/java/com/kim/apidoc/core/parser/VisitorParser.java index cb4176b78e09ba91e2451b4eea156bd3baf8757a..ca7691ef32a0b9eff2f5c098259a9660fbe2de55 100644 --- a/apidoc-core/src/main/java/com/kim/apidoc/core/parser/VisitorParser.java +++ b/apidoc-core/src/main/java/com/kim/apidoc/core/parser/VisitorParser.java @@ -1,5 +1,6 @@ package com.kim.apidoc.core.parser; +import com.github.javaparser.ast.comments.JavadocComment; import com.kim.apidoc.core.schema.Chapter; import com.kim.apidoc.core.schema.Node; import com.kim.apidoc.core.schema.Project; @@ -30,13 +31,14 @@ public class VisitorParser extends VoidVisitorAdapter { /** * 类或者接口声明 + * * @param classOrInterfaceDeclaration * @param arg */ @Override public void visit(final ClassOrInterfaceDeclaration classOrInterfaceDeclaration, final Node arg) { - if (arg instanceof Project && parserStrategy.accept(classOrInterfaceDeclaration)) { + if (arg instanceof Project) { Project project = (Project) arg; // 章节 Chapter chapter = new Chapter(); @@ -44,17 +46,25 @@ public class VisitorParser extends VoidVisitorAdapter { chapter.setName(classOrInterfaceDeclaration.getNameAsString()); classOrInterfaceDeclaration.getComment().ifPresent(chapter::accept); - OptionalHelper.any(chapter.getTag("book"),chapter.getTag("group")) + OptionalHelper.any(chapter.getTag("book"), chapter.getTag("group")) .ifPresent(tag -> chapter.setBookName(tag.getContent())); - parserStrategy.visit(classOrInterfaceDeclaration, chapter); + if (parserStrategy.accept(classOrInterfaceDeclaration)) { + parserStrategy.visit(classOrInterfaceDeclaration, chapter); + } project.addChapter(chapter); super.visit(classOrInterfaceDeclaration, chapter); } } + @Override + public void visit(JavadocComment n, Node arg) { + super.visit(n, arg); + } + /** * 方法声明 + * * @param methodDeclaration * @param arg */ diff --git a/apidoc-core/src/main/resources/templates/markdown.ftl b/apidoc-core/src/main/resources/templates/markdown.ftl index 1d669039fae9ce0c5cd44e3d30b215661861a5bb..a6b25abd846b6f5aa66948026be6ce6aead2fd82 100644 --- a/apidoc-core/src/main/resources/templates/markdown.ftl +++ b/apidoc-core/src/main/resources/templates/markdown.ftl @@ -60,7 +60,7 @@ ${section.getParameterString()} | Field | Type | Request Type | Required | Condition | Default | Description | | :------- | :----- | :----- |:-------- |:-------- | :------ | :---------- | <#list section.requestRows as rowKey,rowValue> -| ${rowValue.key!''} | ${rowValue.type!''} | ${rowValue.requestParameterType!''} |${rowValue.required?string('true','false')} | ${rowValue.condition!''} | ${rowValue.def!''} | ${rowValue.remark!''} | +| ${rowValue.key!''} | ${rowValue.type!''} | **${rowValue.requestParameterType!''}** |${rowValue.required?string('true','false')} | ${rowValue.condition!''} | ${rowValue.def!''} | ${rowValue.remark!''} | <#-- 响应--> diff --git a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/ResultData.java b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/ResultData.java index b3f033fa79b0136a4449723be07baa4db53cc304..bfeb26b10bf4c42c08a633fbcddaff1f376fe6b8 100644 --- a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/ResultData.java +++ b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/ResultData.java @@ -3,6 +3,14 @@ package com.kim.apidoc.example.common; import lombok.Getter; import lombok.Setter; +/** + * The type Result data. + * + * @param the type parameter + * @author fengyuchenglun + * @version 1.0.0 + * @resultData + */ @Setter @Getter public class ResultData { @@ -11,13 +19,33 @@ public class ResultData { * 返回码 */ int code; - //返回信息 + /** + * The Msg. + */ +//返回信息 String msg; + /** + * The Data. + */ T data; + /** + * Ok result data. + * + * @param the type parameter + * @return the result data + */ public static ResultData ok(){ return ok(null); } + + /** + * Ok result data. + * + * @param the type parameter + * @param data the data + * @return the result data + */ public static ResultData ok(T data){ ResultData resultData = new ResultData<>(); resultData.code = 0; diff --git a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/KimUserController.java b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/KimUserController.java index 5a01cb0972232dc9e05415d63977e4cfadfef64f..e3e2f67811abba7ae97e90c10f3e80427ee08089 100644 --- a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/KimUserController.java +++ b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/KimUserController.java @@ -1,10 +1,11 @@ package com.kim.apidoc.example.spring.advanced; import com.kim.apidoc.example.annotation.KimController; +import com.kim.apidoc.example.common.Query; import com.kim.apidoc.example.common.ResultData; import com.kim.apidoc.example.common.User; -import com.kim.apidoc.example.common.UserQuery; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -25,11 +26,12 @@ public class KimUserController { * 用户详情信息 * 主动根据id获取用户的信息 * - * @param userQuery the user query + * @param id the id + * @param query the query * @return result data */ @GetMapping(value = "/{id}") - public ResultData detail(UserQuery userQuery) { + public ResultData detail(@PathVariable String id, Query query) { User user = new User(); return ResultData.ok(user); }