Commit a5e6d864 authored by duanledexianxianxian's avatar duanledexianxianxian 😁

生成markdown api文档

parent 2e5785bf
......@@ -21,19 +21,19 @@ import java.util.*;
public class Section extends Node {
/**
* The Method.
* 请求方法.
*/
Method method;
/**
* The Uri.
* 请求url.
*/
String uri;
/**
* The In headers.
* 请求头.
*/
Map<String, Header> inHeaders = new LinkedHashMap<>();
/**
* The Path variable.
* 路径变量.
*/
ObjectNode pathVariable = ObjectMappers.instance.createObjectNode();
/**
......
......@@ -6,78 +6,84 @@
<#-- ---------- BEGIN 循环遍历book ---------->
<#if books??>
<#list books as bookKey,bookValue>
${bookKey}
<#if bookValue.name??>
<#--book名称-->
# ${bookValue.name}
</#if>
<#-- ---------- BEGIN 循环遍历chapter ---------->
<#list bookValue.chapters>
<#items as chapter>
<#-- 章节名称-->
## ${chapter?counter}. ${chapter.name}
<#-- 章节描述-->
<#if chapter.description??>
${chapter.description}
</#if>
<#-- ---------- BEGIN 循环遍历section ---------->
<#list chapter.sections>
<#items as section>
### ${chapter?counter}.${section?counter} ${section.name}
${section.description}
**request**
<#-- 接口名称-->
### ${chapter?counter}.${section?counter} ${section.name}
<#-- 接口描述-->
<#if section.description??>
```HTTP
POST /api/v1/users HTTP/1.1
{
"loginId":"admin",
"userName":"123456",
"passwords":"123456"
}
```
${section.description}
</#if>
**header**
<#-- 请求-->
**Request**
| Field | Type | Condition | Default | Description |
| :------- | :----- | :-------- | :------ | :---------- |
| loginId | String | | | 用户编号 |
| userName | String | | | 用户名 |
| password | String | | | 密码 |
<#-- 请求示例-->
```HTTP
${section.method} ${section.uri!''} HTTP/1.1
<#if section.inHeaders??>
<#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>
| rowValue.key | rowValue.type | rowValue.condition | rowValue.def | rowValue.remark |
| ${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)>
**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 | 密码 |
| Field | Type | Description |
| :------- | :----- | :---------- |
<#list section.responseRows as rowKey,rowValue>
| ${rowValue.key!''} | ${rowValue.type!''} | ${rowValue.remark!''} |
</#list>
</#if>
</#items>
</#list>
<#------------ END 循环遍历section ---------->
</#items>
</#list>
<#------------ END 循环遍历chapter ---------->
</#list>
</#if>
<#------------ END 循环遍历book ---------->
</#if>
......@@ -17,7 +17,7 @@ public class SpringTest {
Context context = new Context();
context.setId("test");
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");
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