diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/ArrayTypeDescription.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/ArrayTypeDescription.java index d4cebc35e60e7931d2193b422bb0dec3f446b382..b6b014b40b2d3d4e9d73bbbeaa12e6c3939c23d8 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/ArrayTypeDescription.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/ArrayTypeDescription.java @@ -3,6 +3,7 @@ package com.github.fengyuchenglun.apidoc.core.common.description; import com.github.fengyuchenglun.apidoc.core.common.ObjectMappers; import com.github.fengyuchenglun.apidoc.core.schema.Row; import com.fasterxml.jackson.databind.node.ArrayNode; +import lombok.Data; import java.util.ArrayList; import java.util.Collection; @@ -10,6 +11,7 @@ import java.util.Collection; /** * 数组类型描述 */ +@Data public class ArrayTypeDescription extends TypeDescription { protected ArrayNode value; diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/ObjectTypeDescription.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/ObjectTypeDescription.java index 4b6fd05141f9be488ab85763287338f4fa348a40..c138f6232c8704c26e68c530749114081cb0ba5b 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/ObjectTypeDescription.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/ObjectTypeDescription.java @@ -4,6 +4,7 @@ import com.github.fengyuchenglun.apidoc.core.common.ObjectMappers; import com.github.fengyuchenglun.apidoc.core.schema.Row; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.collect.Lists; +import lombok.Data; import lombok.Getter; import lombok.Setter; @@ -16,8 +17,7 @@ import java.util.List; * @author fengyuchenglun * @version 1.0.0 */ -@Setter -@Getter +@Data public class ObjectTypeDescription extends TypeDescription { /** @@ -29,6 +29,12 @@ public class ObjectTypeDescription extends TypeDescription { */ private ObjectNode value = ObjectMappers.instance.createObjectNode(); + @Override + public void setRequired(Boolean required) { + this.required = required; + this.members.get(0).setRequired(required); + } + /** * Merge. * diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/PrimitiveTypeDescription.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/PrimitiveTypeDescription.java index 71d36d2264abf9eda06d6b8b33b8f9314f0a9fea..5b641749a19ed67257caba987e268bd3e5a0a9c7 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/PrimitiveTypeDescription.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/PrimitiveTypeDescription.java @@ -2,10 +2,12 @@ package com.github.fengyuchenglun.apidoc.core.common.description; import com.github.javaparser.resolution.types.ResolvedPrimitiveType; import com.github.javaparser.resolution.types.ResolvedReferenceType; +import lombok.Data; /** * 原始类型描述 */ +@Data public class PrimitiveTypeDescription extends TypeDescription { /** diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/StringTypeDescription.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/StringTypeDescription.java index 597be892c0e5f8440839321a0c5d9d0056819c7d..d866428d2642187e393119f76ac9f997a7eb7bc7 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/StringTypeDescription.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/StringTypeDescription.java @@ -1,8 +1,11 @@ package com.github.fengyuchenglun.apidoc.core.common.description; +import lombok.Data; + /** * 字符串类型 */ +@Data public class StringTypeDescription extends TypeDescription { /** diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/TypeDescription.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/TypeDescription.java index 690c3f74748234858999220915b1060c3d8b31c4..ff53410b5dc48b79016aa552b57b9ae18a6dd566 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/TypeDescription.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/TypeDescription.java @@ -6,6 +6,7 @@ import com.github.fengyuchenglun.apidoc.core.schema.Row; import com.github.javaparser.ast.comments.Comment; import com.github.javaparser.javadoc.Javadoc; import com.google.common.collect.Lists; +import lombok.Data; import lombok.Getter; import lombok.Setter; @@ -13,9 +14,9 @@ import java.util.Collection; /** * The type Type description. + * @author duanledexianxianxian */ -@Setter -@Getter +@Data public abstract class TypeDescription { /** @@ -46,10 +47,11 @@ public abstract class TypeDescription { * 默认值. */ protected Object defaultValue; + /** * 是否必填. */ - protected Boolean required; + protected Boolean required=false; /** * Is available boolean. @@ -185,11 +187,11 @@ public abstract class TypeDescription { def = ""; } - if (required != null) { - condition.append("required=").append(required); - } +// if (required != null) { +// condition.append("required=").append(required); +// } - return Lists.newArrayList(new Row(key, type, false, condition.toString(), def, remark, requestParameterType)); + return Lists.newArrayList(new Row(key, type, required, condition.toString(), def, remark, requestParameterType)); } diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/UnAvailableTypeDescription.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/UnAvailableTypeDescription.java index 4261239d4d6e5a66837d170e6fdcaf63434cdfa6..28567997dc98e4cf29eb0446ee327a52b17a7745 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/UnAvailableTypeDescription.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/common/description/UnAvailableTypeDescription.java @@ -1,12 +1,15 @@ package com.github.fengyuchenglun.apidoc.core.common.description; import com.github.fengyuchenglun.apidoc.core.schema.Row; +import lombok.Data; import java.util.Collection; /** * 未知类型,应该忽略 + * @author duanledexianxianxian */ +@Data public class UnAvailableTypeDescription extends TypeDescription { public UnAvailableTypeDescription() { diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/render/MarkdownRender.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/render/MarkdownRender.java index 6e95f2a931dfecba635397e3144e9472af652d18..a587fdfcf7695d72f943840197e259cb7496b5c5 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/render/MarkdownRender.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/render/MarkdownRender.java @@ -43,6 +43,7 @@ public class MarkdownRender implements ProjectRender { } private void build(Project project) throws Exception { + System.out.println(project); String templatePath = ApiDoc.getInstance().getContext().getMarkdownTemplate(); String id = ApiDoc.getInstance().getContext().getId(); Path buildPath = ApiDoc.getInstance().getContext().getBuildPath(); diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Appendix.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Appendix.java index 058765d779ce971454a18001febb9c38474633f0..4a8d39691c16dcda3981fa069300a22ed020dd3d 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Appendix.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Appendix.java @@ -5,6 +5,8 @@ import com.github.javaparser.ast.comments.JavadocComment; import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName; import com.github.fengyuchenglun.apidoc.core.common.helper.EnumHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.FieldHelper; +import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -15,8 +17,8 @@ import java.util.List; /** * 附录 */ -@Setter -@Getter +@Data +@EqualsAndHashCode(callSuper=true) public class Appendix extends Node { /** diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Book.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Book.java index 20045d3bb21451b4c70fdc41cfea0ee5b27ea5b9..6222b98672a3717333597e41b7ad8c4ab2358845 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Book.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Book.java @@ -1,5 +1,7 @@ package com.github.fengyuchenglun.apidoc.core.schema; +import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -12,8 +14,8 @@ import java.util.TreeSet; * @author fengyuchenglun * @version 1.0.0 */ -@Setter -@Getter +@Data +@EqualsAndHashCode(callSuper=true) public class Book extends Node { /** diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Cell.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Cell.java index b2fee045f936731539b3217daeffdfb5af174948..e364c746f7c10c7f18f667d87bd23fcb2b2e3c23 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Cell.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Cell.java @@ -1,6 +1,7 @@ package com.github.fengyuchenglun.apidoc.core.schema; import com.google.common.collect.Lists; +import lombok.Data; import java.util.List; @@ -9,6 +10,7 @@ import java.util.List; * * @param the type parameter */ +@Data public class Cell { /** diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Chapter.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Chapter.java index 9b7da8eaaef07574938b23ad038366d1661b344c..745a55438e2c1f5dcd8fe42b05c14a40845ef856 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Chapter.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Chapter.java @@ -1,5 +1,7 @@ package com.github.fengyuchenglun.apidoc.core.schema; +import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -12,15 +14,14 @@ import java.util.TreeSet; * @author fengyuchenglun * @version 1.0.0 */ -@Setter -@Getter +@Data +@EqualsAndHashCode(callSuper = true) public class Chapter extends Node { /** * The Book name. */ String bookName; - Project project; /** * The Sections. diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Header.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Header.java index 481bb49d39a64908abe9851621b75cc78150f849..1b0778e5cbec9e0b1eea7ad9dabb982dd10623c6 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Header.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Header.java @@ -1,5 +1,6 @@ package com.github.fengyuchenglun.apidoc.core.schema; +import lombok.Data; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -10,8 +11,7 @@ import lombok.Setter; * @author fengyuchenglun * @version 1.0.0 */ -@Setter -@Getter +@Data @NoArgsConstructor public class Header { diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Node.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Node.java index aeaf8ea45d468f38bfd1637b06230f545e1a1d7f..3e29c128adba608b3b8658acad87fed3e514ba4e 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Node.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Node.java @@ -5,6 +5,8 @@ import com.github.javaparser.ast.comments.Comment; import com.github.javaparser.javadoc.Javadoc; import com.github.fengyuchenglun.apidoc.core.common.helper.CommentHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.StringHelper; +import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -19,8 +21,7 @@ import java.util.Optional; * @author fengyuchenglun * @version 1.0.0 */ -@Setter -@Getter +@Data public class Node implements Comparable { /** * 节点类型 diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Project.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Project.java index 43609d4ffef2a02b86fc52e4271e478bbf297116..9036a1a4a2d0194045395a91b53dbd6ca7f8903e 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Project.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Project.java @@ -1,6 +1,8 @@ package com.github.fengyuchenglun.apidoc.core.schema; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -13,8 +15,8 @@ import java.util.*; * @author fengyuchenglun * @version 1.0.0 */ -@Setter -@Getter +@Data +@EqualsAndHashCode(callSuper = true) public class Project extends Node { /** @@ -42,7 +44,6 @@ public class Project extends Node { * @param chapter the chapter */ public void addChapter(Chapter chapter) { - chapter.setProject(this); if (Objects.isNull(chapter.getBookName())) { chapter.setBookName(Book.DEFAULT); } diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Row.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Row.java index 13adc2446f58bc0223edbb4c47eb66afd9d1d490..22956b919fcb757ad66e1df5b47f8a6d9fae6017 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Row.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Row.java @@ -11,8 +11,7 @@ import lombok.*; @EqualsAndHashCode @NoArgsConstructor @AllArgsConstructor -@Setter -@Getter +@Data public class Row { /** diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Section.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Section.java index 6d6937490d93e286cbbda28faaf48a4cfa3260cd..1d83c6551e79db9cd1f0557c1a59648c520ec59b 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Section.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Section.java @@ -5,6 +5,8 @@ import com.github.fengyuchenglun.apidoc.core.common.QueryStringBuilder; import com.github.fengyuchenglun.apidoc.core.common.helper.StringHelper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; +import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.StringUtils; @@ -17,8 +19,8 @@ import java.util.*; * @author fengyuchenglun * @version 1.0.0 */ -@Setter -@Getter +@Data +@EqualsAndHashCode(callSuper=true) public class Section extends Node { /** diff --git a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Tag.java b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Tag.java index 51223322f163a8eff4fc71b3c9b0217ad1128098..d00bbd33535430071b610e9186d0ce9f2ddb609d 100644 --- a/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Tag.java +++ b/apidoc-core/src/main/java/com/github/fengyuchenglun/apidoc/core/schema/Tag.java @@ -1,5 +1,6 @@ package com.github.fengyuchenglun.apidoc.core.schema; +import lombok.Data; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -14,8 +15,7 @@ import java.util.Objects; * @version 1.0.0 */ @Slf4j -@Setter -@Getter +@Data public class Tag { /** diff --git a/apidoc-springmvc/src/main/java/com/github/fengyuchenglun/apidoc/springmvc/SpringParser.java b/apidoc-springmvc/src/main/java/com/github/fengyuchenglun/apidoc/springmvc/SpringParser.java index 6a634900e3b4e2c546075ae010219ef1e06c7081..9f4d0668f587e4ee92e331f61c21cbc30a897a05 100644 --- a/apidoc-springmvc/src/main/java/com/github/fengyuchenglun/apidoc/springmvc/SpringParser.java +++ b/apidoc-springmvc/src/main/java/com/github/fengyuchenglun/apidoc/springmvc/SpringParser.java @@ -265,6 +265,8 @@ public class SpringParser implements ParserStrategy { Optional optional = parameter.getAnnotationByName(ParameterHelper.ANNOTATION_REQUEST_PARAM); if (optional.isPresent()) { + // 如果有RequestParam注解,则参数必填 + required = true; Optional valueOptional = AnnotationHelper.getAnyAttribute(optional.get(), "value", "name"); if (valueOptional.isPresent()) { key = String.valueOf(ExpressionHelper.getValue(valueOptional.get())); diff --git a/apidoc-springmvc/src/test/java/com/github/fengyuchenglun/example/spring/advanced/UserController.java b/apidoc-springmvc/src/test/java/com/github/fengyuchenglun/example/spring/advanced/UserController.java index ab2765b4c5bed97c234538db0be970119b9f4464..046aba5a991f4f2998578fb6cd6714cbc8f5c9cd 100644 --- a/apidoc-springmvc/src/test/java/com/github/fengyuchenglun/example/spring/advanced/UserController.java +++ b/apidoc-springmvc/src/test/java/com/github/fengyuchenglun/example/spring/advanced/UserController.java @@ -3,6 +3,7 @@ package com.github.fengyuchenglun.example.spring.advanced; import com.github.fengyuchenglun.example.annotation.KimController; import com.github.fengyuchenglun.example.common.Query; import com.github.fengyuchenglun.example.common.User; +import com.github.fengyuchenglun.example.common.UserQuery; import lombok.Data; import org.springframework.web.bind.annotation.*; @@ -42,7 +43,7 @@ public class UserController { * @return 用户对象 user */ @GetMapping(value = "/detail1") - public User detail1( Query query) { + public User detail1(Query query) { User user = new User(); return user; } @@ -59,6 +60,65 @@ public class UserController { return user; } + /** + * 查看用户详情 + * + * @param query 过滤条件 + * @return 用户对象 user + */ + @GetMapping(value = "/detail4") + public User detail4(@RequestParam(required = false) Query query) { + User user = new User(); + return user; + } + + /** + * 查看用户详情 + * + * @return 用户对象 user + */ + @GetMapping(value = "/detail5") + public User detail5() { + User user = new User(); + return user; + } + + /** + * 查看用户详情 + * + * @param userName the user name + * @param age the age + * @param query the query + * @return 用户对象 user + */ + @GetMapping(value = "/detail6") + public User detail6(String userName, Integer age, UserQuery query) { + User user = new User(); + return user; + } + + /** + * 查看用户详情 + * + * @return 用户对象 user + */ + @GetMapping(value = "/detail7") + public void detail7() { + } + + + /** + * 删除用户 + * + * @param userId the user id + * @return boolean 是否成功 + */ + @DeleteMapping(value = "/{userId}") + public Boolean deleteUser(@PathVariable("userId") Long userId) { + return true; + } + + /** * 用户表单对象. * @@ -86,7 +146,7 @@ public class UserController { * 添加用户 * * @param form 用户表单对象 - * @return integer integer + * @return integer 返回记录 */ @PostMapping public Integer add(@RequestBody UserForm form) {