Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apidoc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
apidoc
Commits
8208ecbc
Commit
8208ecbc
authored
Mar 27, 2020
by
duanledexianxianxian
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
生成markdown api文档
parent
a5e6d864
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
47 additions
and
18 deletions
+47
-18
apidoc-core/src/main/java/com/kim/apidoc/core/common/description/TypeDescription.java
...m/kim/apidoc/core/common/description/TypeDescription.java
+1
-1
apidoc-core/src/main/java/com/kim/apidoc/core/schema/Row.java
...oc-core/src/main/java/com/kim/apidoc/core/schema/Row.java
+6
-2
apidoc-core/src/main/resources/templates/markdown.ftl
apidoc-core/src/main/resources/templates/markdown.ftl
+15
-14
apidoc-springmvc/src/main/java/com/kim/apidoc/springmvc/SpringParser.java
.../src/main/java/com/kim/apidoc/springmvc/SpringParser.java
+2
-0
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/User.java
...mvc/src/test/java/com/kim/apidoc/example/common/User.java
+18
-0
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/AuthController.java
...om/kim/apidoc/example/spring/advanced/AuthController.java
+1
-0
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/EmptyController.java
...m/kim/apidoc/example/spring/advanced/EmptyController.java
+1
-0
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/PageController.java
...om/kim/apidoc/example/spring/advanced/PageController.java
+1
-0
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/UserController.java
...om/kim/apidoc/example/spring/advanced/UserController.java
+1
-0
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/hello/GreetingController.java
...m/kim/apidoc/example/spring/hello/GreetingController.java
+1
-1
No files found.
apidoc-core/src/main/java/com/kim/apidoc/core/common/description/TypeDescription.java
View file @
8208ecbc
...
@@ -94,7 +94,7 @@ public abstract class TypeDescription {
...
@@ -94,7 +94,7 @@ public abstract class TypeDescription {
condition
.
append
(
"required="
).
append
(
required
);
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
));
}
}
}
}
apidoc-core/src/main/java/com/kim/apidoc/core/schema/Row.java
View file @
8208ecbc
...
@@ -23,16 +23,20 @@ public class Row {
...
@@ -23,16 +23,20 @@ public class Row {
* The Type.
* The Type.
*/
*/
String
type
;
String
type
;
/**
* 是否必填.
*/
Boolean
required
;
/**
/**
* The Condition.
* The Condition.
*/
*/
String
condition
;
String
condition
;
/**
/**
*
The Def
.
*
默认值
.
*/
*/
String
def
;
String
def
;
/**
/**
*
The Remark
.
*
说明
.
*/
*/
String
remark
;
String
remark
;
...
...
apidoc-core/src/main/resources/templates/markdown.ftl
View file @
8208ecbc
...
@@ -12,24 +12,25 @@
...
@@ -12,24 +12,25 @@
# ${bookValue.name}
# ${bookValue.name}
</#if>
</#if>
<#-- ---------- BEGIN 循环遍历chapter ---------->
<#-- ---------- BEGIN 循环遍历chapter ---------->
<#list bookValue.chapters>
<#assign chapterIndex=0>
<#items as chapter>
<#list bookValue.chapters as chapter>
<#if !chapter.isIgnore()>
<#assign chapterIndex++>
<#-- 章节名称-->
<#-- 章节名称-->
## ${chapter
?counter
}. ${chapter.name}
## ${chapter
Index
}. ${chapter.name}
<#-- 章节描述-->
<#-- 章节描述-->
<#if chapter.description??>
<#if chapter.description??>
${chapter.description}
${chapter.description}
</#if>
</#if>
<#-- ---------- BEGIN 循环遍历section ---------->
<#-- ---------- BEGIN 循环遍历section ---------->
<#list chapter.sections>
<#assign sectionIndex=0>
<#items as section>
<#list chapter.sections as section>
<#if !section.isIgnore()>
<#assign sectionIndex++/>
<#-- 接口名称-->
<#-- 接口名称-->
### ${chapter
?counter}.${section?counter
} ${section.name}
### ${chapter
Index}.${sectionIndex
} ${section.name}
<#-- 接口描述-->
<#-- 接口描述-->
<#if section.description??>
<#if section.description??>
...
@@ -56,10 +57,10 @@ ${section.getParameterString()}
...
@@ -56,10 +57,10 @@ ${section.getParameterString()}
<#if section.requestRows?? && (section.requestRows?size>0)>
<#if section.requestRows?? && (section.requestRows?size>0)>
**Query**
**Query**
| Field | Type | Condition | Default | Description |
| Field | Type |
Required |
Condition | Default | Description |
| :------- | :----- | :-------- | :------ | :---------- |
| :------- | :----- | :-------- |
:-------- |
:------ | :---------- |
<#list section.requestRows as rowKey,rowValue>
<#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!''} |
</#list>
</#list>
</#if>
</#if>
<#-- 响应-->
<#-- 响应-->
...
@@ -78,10 +79,10 @@ ${section.getResponseString()}
...
@@ -78,10 +79,10 @@ ${section.getResponseString()}
| ${rowValue.key!''} | ${rowValue.type!''} | ${rowValue.remark!''} |
| ${rowValue.key!''} | ${rowValue.type!''} | ${rowValue.remark!''} |
</#list>
</#list>
</#if>
</#if>
</#items
>
</#if
>
</#list>
</#list>
<#------------ END 循环遍历section ---------->
<#------------ END 循环遍历section ---------->
</#items
>
</#if
>
</#list>
</#list>
<#------------ END 循环遍历chapter ---------->
<#------------ END 循环遍历chapter ---------->
</#list>
</#list>
...
...
apidoc-springmvc/src/main/java/com/kim/apidoc/springmvc/SpringParser.java
View file @
8208ecbc
...
@@ -159,6 +159,8 @@ public class SpringParser implements ParserStrategy {
...
@@ -159,6 +159,8 @@ public class SpringParser implements ParserStrategy {
Row
row
=
new
Row
();
Row
row
=
new
Row
();
row
.
setKey
(
parameter
.
getNameAsString
());
row
.
setKey
(
parameter
.
getNameAsString
());
row
.
setType
(
parameter
.
getType
().
toString
());
row
.
setType
(
parameter
.
getType
().
toString
());
// 路径参数必填
row
.
setRequired
(
true
);
section
.
getParamTag
(
row
.
getKey
()).
ifPresent
(
tag
->
row
.
setRemark
(
tag
.
getContent
()));
section
.
getParamTag
(
row
.
getKey
()).
ifPresent
(
tag
->
row
.
setRemark
(
tag
.
getContent
()));
section
.
addRequestRow
(
row
);
section
.
addRequestRow
(
row
);
}
}
...
...
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/User.java
View file @
8208ecbc
...
@@ -10,17 +10,35 @@ import javax.validation.constraints.NotNull;
...
@@ -10,17 +10,35 @@ import javax.validation.constraints.NotNull;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
/**
* The type User.
*/
@Setter
@Setter
@Getter
@Getter
public
class
User
{
public
class
User
{
/**
* 用户编号.
*/
int
id
;
int
id
;
/**
* 用户名称.
*/
@NotBlank
@NotBlank
String
name
;
String
name
;
/**
* 用户年龄.
*/
@Min
(
1
)
@Min
(
1
)
@NotNull
@NotNull
Integer
age
;
Integer
age
;
/**
* 创建时间.
*/
Date
createAt
;
Date
createAt
;
/**
* 性别.
*/
@NotBlank
@NotBlank
@JsonProperty
(
"Sex"
)
@JsonProperty
(
"Sex"
)
String
sex
;
String
sex
;
...
...
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/AuthController.java
View file @
8208ecbc
...
@@ -6,6 +6,7 @@ import org.springframework.stereotype.Controller;
...
@@ -6,6 +6,7 @@ import org.springframework.stereotype.Controller;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
/**
/**
* @ignore
* @index 3
* @index 3
*/
*/
@Controller
@Controller
...
...
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/EmptyController.java
View file @
8208ecbc
...
@@ -4,6 +4,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -4,6 +4,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
/**
/**
* @ignore
* will be ignore
* will be ignore
*/
*/
@RestController
@RestController
...
...
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/PageController.java
View file @
8208ecbc
...
@@ -14,6 +14,7 @@ import java.util.List;
...
@@ -14,6 +14,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
* @ignore
* @index 4
* @index 4
*/
*/
@Controller
@Controller
...
...
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/UserController.java
View file @
8208ecbc
...
@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
import
java.util.List
;
import
java.util.List
;
/**
/**
* @ignore
* 用户模块(标题)
* 用户模块(标题)
* 用户示例模块文字描述(详情)
* 用户示例模块文字描述(详情)
* 支持多行文字
* 支持多行文字
...
...
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/hello/GreetingController.java
View file @
8208ecbc
...
@@ -8,7 +8,7 @@ import java.util.concurrent.atomic.AtomicLong;
...
@@ -8,7 +8,7 @@ import java.util.concurrent.atomic.AtomicLong;
/**
/**
* 欢迎使用Apiggs
* 欢迎使用Apiggs
*
*
@ignore
* @author fengyuchenglun
* @author fengyuchenglun
* @version 1.0.0
* @version 1.0.0
* @index 1
* @index 1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment