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
a5e6d864
Commit
a5e6d864
authored
Mar 27, 2020
by
duanledexianxianxian
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
生成markdown api文档
parent
2e5785bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
62 deletions
+68
-62
apidoc-core/src/main/java/com/kim/apidoc/core/schema/Section.java
...ore/src/main/java/com/kim/apidoc/core/schema/Section.java
+4
-4
apidoc-core/src/main/resources/templates/markdown.ftl
apidoc-core/src/main/resources/templates/markdown.ftl
+63
-57
apidoc-springmvc/src/test/java/com/kim/apidoc/springmvc/SpringTest.java
...vc/src/test/java/com/kim/apidoc/springmvc/SpringTest.java
+1
-1
No files found.
apidoc-core/src/main/java/com/kim/apidoc/core/schema/Section.java
View file @
a5e6d864
...
@@ -21,19 +21,19 @@ import java.util.*;
...
@@ -21,19 +21,19 @@ import java.util.*;
public
class
Section
extends
Node
{
public
class
Section
extends
Node
{
/**
/**
*
The Method
.
*
请求方法
.
*/
*/
Method
method
;
Method
method
;
/**
/**
*
The Uri
.
*
请求url
.
*/
*/
String
uri
;
String
uri
;
/**
/**
*
The In headers
.
*
请求头
.
*/
*/
Map
<
String
,
Header
>
inHeaders
=
new
LinkedHashMap
<>();
Map
<
String
,
Header
>
inHeaders
=
new
LinkedHashMap
<>();
/**
/**
*
The Path variable
.
*
路径变量
.
*/
*/
ObjectNode
pathVariable
=
ObjectMappers
.
instance
.
createObjectNode
();
ObjectNode
pathVariable
=
ObjectMappers
.
instance
.
createObjectNode
();
/**
/**
...
...
apidoc-core/src/main/resources/templates/markdown.ftl
View file @
a5e6d864
...
@@ -6,78 +6,84 @@
...
@@ -6,78 +6,84 @@
<#-- ---------- BEGIN 循环遍历book ---------->
<#-- ---------- BEGIN 循环遍历book ---------->
<#if books??>
<#if books??>
<#list books as bookKey,bookValue>
<#list books as bookKey,bookValue>
${bookKey}
<#if bookValue.name??>
<#if bookValue.name??>
<#--book名称-->
# ${bookValue.name}
# ${bookValue.name}
</#if>
</#if>
<#-- ---------- BEGIN 循环遍历chapter ---------->
<#list bookValue.chapters>
<#list bookValue.chapters>
<#items as chapter>
<#items as chapter>
<#-- 章节名称-->
## ${chapter?counter}. ${chapter.name}
## ${chapter?counter}. ${chapter.name}
<#-- 章节描述-->
<#if chapter.description??>
${chapter.description}
${chapter.description}
</#if>
<#-- ---------- BEGIN 循环遍历section ---------->
<#list chapter.sections>
<#list chapter.sections>
<#items as section>
<#items as section>
### ${chapter?counter}.${section?counter} ${section.name}
${section.description}
**request**
```HTTP
<#-- 接口名称-->
POST /api/v1/users HTTP/1.1
### ${chapter?counter}.${section?counter} ${section.name}
<#-- 接口描述-->
{
<#if section.description??>
"loginId":"admin",
"userName":"123456",
${section.description}
"passwords":"123456"
</#if>
}
```
<#-- 请求-->
**Request**
**header**
<#-- 请求示例-->
| Field | Type | Condition | Default | Description |
```HTTP
| :------- | :----- | :-------- | :------ | :---------- |
${section.method} ${section.uri!''} HTTP/1.1
| loginId | String | | | 用户编号 |
<#if section.inHeaders??>
| userName | String | | | 用户名 |
<#list section.inHeaders as inHeaderKey,inHeaderValue>
| password | String | | | 密码 |
${inHeaderValue!''}
</#list>
**query**
</#if>
<#if section.hasRequestBody()>
| Field | Type | Condition | Default | Description |
| :------- | :----- | :-------- | :------ | :---------- |
${section.getParameterString()}
<#list section.requestRows as rowKey,rowValue>
</#if>
| rowValue.key | rowValue.type | rowValue.condition | rowValue.def | rowValue.remark |
```
<#-- 请求参数table列表-->
<#if section.requestRows?? && (section.requestRows?size>0)>
**Query**
| Field | Type | Condition | Default | Description |
| :------- | :----- | :-------- | :------ | :---------- |
<#list section.requestRows as rowKey,rowValue>
| ${rowValue.key!''} | ${rowValue.type!''} | ${rowValue.condition!''} | ${rowValue.def!''} | ${rowValue.remark!''} |
</#list>
</#if>
<#-- 响应-->
<#if section.hasResponseBody()>
**Response**
```
${section.getResponseString()}
```
</#if>
<#-- 响应参数table列表-->
<#if section.responseRows?? && (section.responseRows?size>0)>
| Field | Type | Description |
| :------- | :----- | :---------- |
<#list section.responseRows as rowKey,rowValue>
| ${rowValue.key!''} | ${rowValue.type!''} | ${rowValue.remark!''} |
</#list>
</#list>
</#if>
**body**
| Field | Type | Condition | Default | Description |
| :------- | :----- | :-------- | :------ | :---------- |
| loginId | String | | | 用户编号 |
| userName | String | | | 用户名 |
| password | String | | | 密码 |
**response**
```
{
"loginId":"admin",
"userName":"123456",
"passwords":"123456"
}
```
| Field | Type | Description |
| :------- | :----- | :---------- |
| loginId | String | 用户编号 |
| userName | String | 用户名 |
| password | String | 密码 |
</#items>
</#items>
</#list>
</#list>
<#------------ END 循环遍历section ---------->
</#items>
</#items>
</#list>
</#list>
<#------------ END 循环遍历chapter ---------->
</#list>
</#list>
</#if>
<#------------ END 循环遍历book ---------->
<#------------ END 循环遍历book ---------->
</#if>
apidoc-springmvc/src/test/java/com/kim/apidoc/springmvc/SpringTest.java
View file @
a5e6d864
...
@@ -17,7 +17,7 @@ public class SpringTest {
...
@@ -17,7 +17,7 @@ public class SpringTest {
Context
context
=
new
Context
();
Context
context
=
new
Context
();
context
.
setId
(
"test"
);
context
.
setId
(
"test"
);
context
.
setName
(
"测试项目"
);
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");
// context.setCss("https://darshandsoni.com/asciidoctor-skins/css/monospace.css");
ApiDoc
apigcc
=
new
ApiDoc
(
context
);
ApiDoc
apigcc
=
new
ApiDoc
(
context
);
...
...
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