From 14f303d4128f2c65fd3691fc69afbc78b482bf75 Mon Sep 17 00:00:00 2001 From: duanledexianxianxian Date: Thu, 9 Apr 2020 18:27:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90markdown=20api=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/kim/apidoc/core/schema/Project.java | 2 +- .../java/com/kim/apidoc/springmvc/SpringParser.java | 12 +++++++----- .../example/spring/advanced/KimUserController.java | 1 + .../java/com/kim/apidoc/springmvc/SpringTest.java | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/apidoc-core/src/main/java/com/kim/apidoc/core/schema/Project.java b/apidoc-core/src/main/java/com/kim/apidoc/core/schema/Project.java index 013c93c..ae219b6 100644 --- a/apidoc-core/src/main/java/com/kim/apidoc/core/schema/Project.java +++ b/apidoc-core/src/main/java/com/kim/apidoc/core/schema/Project.java @@ -32,7 +32,7 @@ public class Project extends Node { */ List appendices = new LinkedList<>(); /** - * resultData + * 统一结果 */ ClassOrInterfaceDeclaration resultDataClassOrInterfaceDeclaration; diff --git a/apidoc-springmvc/src/main/java/com/kim/apidoc/springmvc/SpringParser.java b/apidoc-springmvc/src/main/java/com/kim/apidoc/springmvc/SpringParser.java index 11a385e..ea24985 100644 --- a/apidoc-springmvc/src/main/java/com/kim/apidoc/springmvc/SpringParser.java +++ b/apidoc-springmvc/src/main/java/com/kim/apidoc/springmvc/SpringParser.java @@ -308,11 +308,13 @@ public class SpringParser implements ParserStrategy { * @param section the section */ private void visitReturn(MethodDeclaration n, Chapter chapter, Section section) { - ClassOrInterfaceType returnType = new ClassOrInterfaceType(); - returnType.setName(ApiDoc.getInstance().getProject().getResultDataClassOrInterfaceDeclaration().getName()); - returnType.setTypeArguments(n.getType()); - n.setType(returnType); - + ClassOrInterfaceDeclaration resultDataClassOrInterfaceDeclaration = ApiDoc.getInstance().getProject().getResultDataClassOrInterfaceDeclaration(); + if (null != resultDataClassOrInterfaceDeclaration) { + ClassOrInterfaceType returnType = new ClassOrInterfaceType(); + returnType.setName(resultDataClassOrInterfaceDeclaration.getName()); + returnType.setTypeArguments(n.getType()); + n.setType(returnType); + } TypeDescription description = ApiDoc.getInstance().getTypeResolvers().resolve(n.getType()); if (description.isAvailable()) { if (description.isPrimitive()) { 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 e3e2f67..2eb3875 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 @@ -41,6 +41,7 @@ public class KimUserController { * Add integer. * * @return the integer + * @return */ @PostMapping public Integer add() { diff --git a/apidoc-springmvc/src/test/java/com/kim/apidoc/springmvc/SpringTest.java b/apidoc-springmvc/src/test/java/com/kim/apidoc/springmvc/SpringTest.java index 23b6e0d..824168d 100644 --- a/apidoc-springmvc/src/test/java/com/kim/apidoc/springmvc/SpringTest.java +++ b/apidoc-springmvc/src/test/java/com/kim/apidoc/springmvc/SpringTest.java @@ -17,7 +17,7 @@ public class SpringTest { Context context = new Context(); context.setId("test"); context.setName("测试项目"); - context.addSource(Paths.get("K:\\@project-dianli@\\tool\\apidoc\\apidoc-springmvc\\src\\test\\java")); + context.addSource(Paths.get("F:\\@project@\\@dianli@\\tool\\apidoc\\apidoc-springmvc\\src\\test\\java")); // context.setCss("https://darshandsoni.com/asciidoctor-skins/css/monospace.css"); ApiDoc apigcc = new ApiDoc(context); -- GitLab