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 013c93c81bec6e85e73037f81faac5eb88e2f1bd..ae219b6a62add410d48a7649943635bb83b8d8fd 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 11a385e26d7cf6913746e1d0b66fe81c332e24ae..ea249855a4b79c58051d230cbdbc66947b2d1c3c 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 e3e2f67811abba7ae97e90c10f3e80427ee08089..2eb38757f8057a4b53d67e08d55e86a1730c60a3 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 23b6e0d983d6a4de9e38c0b0e3ec12366c68f807..824168dc587a2d69e3c03bd4eed31e6601f1ec2d 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);