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 77718981988483b159d28fe8dcdf57bc73848610..16ff69a780040ce7b6be5e6a33005c7563123b99 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 @@ -94,7 +94,7 @@ public abstract class TypeDescription { condition.append("required=").append(required); } - return Lists.newArrayList(new Row(key, type, condition.toString(), def, remark)); + return Lists.newArrayList(new Row(key, type,false, condition.toString(), def, remark)); } } diff --git a/apidoc-core/src/main/java/com/kim/apidoc/core/schema/Row.java b/apidoc-core/src/main/java/com/kim/apidoc/core/schema/Row.java index ed47a68ac560dc08d03eeae109f420fba6011548..22bdbd6d5c215caad1f966714909407eff119dbf 100644 --- a/apidoc-core/src/main/java/com/kim/apidoc/core/schema/Row.java +++ b/apidoc-core/src/main/java/com/kim/apidoc/core/schema/Row.java @@ -23,16 +23,20 @@ public class Row { * The Type. */ String type; + /** + * 是否必填. + */ + Boolean required; /** * The Condition. */ String condition; /** - * The Def. + * 默认值. */ String def; /** - * The Remark. + * 说明. */ String remark; diff --git a/apidoc-core/src/main/resources/templates/markdown.ftl b/apidoc-core/src/main/resources/templates/markdown.ftl index 421b1b812f1fe53e8096225d9f4d21cd3e5c9ab3..f1571b49b651c2ccf7da851932a095014d6305ba 100644 --- a/apidoc-core/src/main/resources/templates/markdown.ftl +++ b/apidoc-core/src/main/resources/templates/markdown.ftl @@ -12,24 +12,25 @@ # ${bookValue.name} <#-- ---------- BEGIN 循环遍历chapter ----------> - <#list bookValue.chapters> - <#items as chapter> - - + <#assign chapterIndex=0> + <#list bookValue.chapters as chapter> + <#if !chapter.isIgnore()> +<#assign chapterIndex++> <#-- 章节名称--> -## ${chapter?counter}. ${chapter.name} +## ${chapterIndex}. ${chapter.name} <#-- 章节描述--> <#if chapter.description??> ${chapter.description} <#-- ---------- BEGIN 循环遍历section ----------> - <#list chapter.sections> - <#items as section> - + <#assign sectionIndex=0> + <#list chapter.sections as section> + <#if !section.isIgnore()> +<#assign sectionIndex++/> <#-- 接口名称--> -### ${chapter?counter}.${section?counter} ${section.name} +### ${chapterIndex}.${sectionIndex} ${section.name} <#-- 接口描述--> <#if section.description??> @@ -56,10 +57,10 @@ ${section.getParameterString()} <#if section.requestRows?? && (section.requestRows?size>0)> **Query** -| Field | Type | Condition | Default | Description | -| :------- | :----- | :-------- | :------ | :---------- | +| Field | Type | Required | Condition | Default | Description | +| :------- | :----- | :-------- |:-------- | :------ | :---------- | <#list section.requestRows as rowKey,rowValue> -| ${rowValue.key!''} | ${rowValue.type!''} | ${rowValue.condition!''} | ${rowValue.def!''} | ${rowValue.remark!''} | +| ${rowValue.key!''} | ${rowValue.type!''} | ${rowValue.required?string('true','false')} | ${rowValue.condition!''} | ${rowValue.def!''} | ${rowValue.remark!''} | <#-- 响应--> @@ -78,10 +79,10 @@ ${section.getResponseString()} | ${rowValue.key!''} | ${rowValue.type!''} | ${rowValue.remark!''} | - + <#------------ END 循环遍历section ----------> - + <#------------ END 循环遍历chapter ----------> 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 58a7e1aa30897159b7bf8ee0de0f407544e7419b..0f4fc8ebbbb1c9076291ba8d3307d8065b071f2e 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 @@ -159,6 +159,8 @@ public class SpringParser implements ParserStrategy { Row row = new Row(); row.setKey(parameter.getNameAsString()); row.setType(parameter.getType().toString()); + // 路径参数必填 + row.setRequired(true); section.getParamTag(row.getKey()).ifPresent(tag -> row.setRemark(tag.getContent())); section.addRequestRow(row); } diff --git a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/User.java b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/User.java index 97b50a38ec6e42846ce9f103ad083b060c3c85bc..115ce7a7e8748ba2976c2cbe6ae3347d289e8b99 100644 --- a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/User.java +++ b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/User.java @@ -10,17 +10,35 @@ import javax.validation.constraints.NotNull; import java.util.Date; import java.util.List; +/** + * The type User. + */ @Setter @Getter public class User { + /** + * 用户编号. + */ int id; + /** + * 用户名称. + */ @NotBlank String name; + /** + * 用户年龄. + */ @Min(1) @NotNull Integer age; + /** + * 创建时间. + */ Date createAt; + /** + * 性别. + */ @NotBlank @JsonProperty("Sex") String sex; diff --git a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/AuthController.java b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/AuthController.java index 4c7e733368df8f5e0117c1799925470f9a840cd0..8926ca5a2284f98e00741b8b61ca6f1fbd3a26a4 100644 --- a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/AuthController.java +++ b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/AuthController.java @@ -6,6 +6,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; /** + * @ignore * @index 3 */ @Controller diff --git a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/EmptyController.java b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/EmptyController.java index d99b49dcc5ce1ff8694643ff3369331baebe5ae0..be7f38f2355a25ce3f6ba3db5c6a5a33ec6dd67e 100644 --- a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/EmptyController.java +++ b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/EmptyController.java @@ -4,6 +4,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** + * @ignore * will be ignore */ @RestController diff --git a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/PageController.java b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/PageController.java index e77340c7bacaecac3e6cb3a0ef6d1b4c5ba8d6de..22e593a8220b0307e24dea8e93f130ab901041ff 100644 --- a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/PageController.java +++ b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/PageController.java @@ -14,6 +14,7 @@ import java.util.List; import java.util.Map; /** + * @ignore * @index 4 */ @Controller diff --git a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/UserController.java b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/UserController.java index b8746a27663efb93b6fbe2e2f6ab409022d31ca0..c86d7d8a71da069f7a348414b8a2fdd51f2e13ca 100644 --- a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/UserController.java +++ b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/UserController.java @@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; /** + * @ignore * 用户模块(标题) * 用户示例模块文字描述(详情) * 支持多行文字 diff --git a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/hello/GreetingController.java b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/hello/GreetingController.java index 9a74535349e7d3231530afd9693c2dd30e7b06f8..67694132c3b6c6d1843a71e7728e9eef23d8065f 100644 --- a/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/hello/GreetingController.java +++ b/apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/hello/GreetingController.java @@ -8,7 +8,7 @@ import java.util.concurrent.atomic.AtomicLong; /** * 欢迎使用Apiggs - * + * @ignore * @author fengyuchenglun * @version 1.0.0 * @index 1