Commit a5e6d864 authored by duanledexianxianxian's avatar duanledexianxianxian 😁

生成markdown api文档

parent 2e5785bf
...@@ -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();
/** /**
......
...@@ -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** <#-- 接口名称-->
### ${chapter?counter}.${section?counter} ${section.name}
<#-- 接口描述-->
<#if section.description??>
```HTTP ${section.description}
POST /api/v1/users HTTP/1.1 </#if>
{
"loginId":"admin",
"userName":"123456",
"passwords":"123456"
}
```
**header** <#-- 请求-->
**Request**
| Field | Type | Condition | Default | Description | <#-- 请求示例-->
| :------- | :----- | :-------- | :------ | :---------- | ```HTTP
| loginId | String | | | 用户编号 | ${section.method} ${section.uri!''} HTTP/1.1
| userName | String | | | 用户名 | <#if section.inHeaders??>
| password | String | | | 密码 | <#list section.inHeaders as inHeaderKey,inHeaderValue>
${inHeaderValue!''}
</#list>
</#if>
<#if section.hasRequestBody()>
**query** ${section.getParameterString()}
</#if>
```
<#-- 请求参数table列表-->
<#if section.requestRows?? && (section.requestRows?size>0)>
| Field | Type | Condition | Default | Description | **Query**
| :------- | :----- | :-------- | :------ | :---------- | | Field | Type | 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.condition!''} | ${rowValue.def!''} | ${rowValue.remark!''} |
</#list> </#list>
</#if>
<#-- 响应-->
<#if section.hasResponseBody()>
**Response**
```
${section.getResponseString()}
```
</#if>
<#-- 响应参数table列表-->
<#if section.responseRows?? && (section.responseRows?size>0)>
**body** | Field | Type | Description |
| :------- | :----- | :---------- |
| Field | Type | Condition | Default | Description | <#list section.responseRows as rowKey,rowValue>
| :------- | :----- | :-------- | :------ | :---------- | | ${rowValue.key!''} | ${rowValue.type!''} | ${rowValue.remark!''} |
| loginId | String | | | 用户编号 | </#list>
| userName | String | | | 用户名 | </#if>
| 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>
...@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment