From 2d4f95235b4db2454d062bd4697ff3c09dbe317a Mon Sep 17 00:00:00 2001 From: gongyangfan <704210402@qq.com> Date: Wed, 27 Nov 2024 17:10:03 +0800 Subject: [PATCH] feat(markdown): Add the 'Example' field to the markdown document parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change template ApiDoc.md and AllInOne.md,Add the 'Example' field to the markdown document parameter Closes #971 --- src/main/resources/template/AllInOne.md | 39 ++++++++++++++----------- src/main/resources/template/ApiDoc.md | 36 +++++++++++++---------- 2 files changed, 42 insertions(+), 33 deletions(-) diff --git a/src/main/resources/template/AllInOne.md b/src/main/resources/template/AllInOne.md index 58768a6a..4ed44c7a 100644 --- a/src/main/resources/template/AllInOne.md +++ b/src/main/resources/template/AllInOne.md @@ -44,48 +44,53 @@ for(doc in api.list){ **Content-Type:** ${doc.contentType} **Description:** ${doc.detail} -<%if(isNotEmpty(doc.headers)){%> +<%if(isNotEmpty(doc.requestHeaders)){%> **Request-headers:** -| Header | Type | Required | Description | Since | -|--------|------|----------|-------------|-------| -${doc.headers} +| Header | Type | Required | Description | Since | Example | +|--------|------|----------|-------------|-------|---------| +<% +for(param in doc.requestHeaders){ +%> +|${param.name}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.since}|${param.value}| <%}%> +<%}%> + <%if(isNotEmpty(doc.pathParams)){%> **Path-parameters:** -| Parameter | Type | Required | Description | Since | -|-----------|------|----------|-------------|-------| +| Parameter | Type | Required | Description | Since | Example | +|-----------|------|----------|-------------|-------|---------| <% for(param in doc.pathParams){ %> -|${param.field}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.version}| +|${param.field}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.version}|${param.value}| <%}%> <%}%> <%if(isNotEmpty(doc.queryParams)){%> **Query-parameters:** -| Parameter | Type | Required | Description | Since | -|-----------|------|----------|-------------|-------| +| Parameter | Type | Required | Description | Since | Example | +|-----------|------|----------|-------------|-------|---------| <% for(param in doc.queryParams){ %> -|${param.field}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.version}| +|${param.field}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.version}|${param.value}| <%}%> <%}%> <%if(isNotEmpty(doc.requestParams)){%> **Body-parameters:** -| Parameter | Type | Required | Description | Since | -|-----------|------|----------|-------------|-------| +| Parameter | Type | Required | Description | Since | Example | +|-----------|------|----------|-------------|-------|---------| <% for(param in doc.requestParams){ %> -|${param.field}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.version}| +|${param.field}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.version}|${param.value}| <%}%> <%}%> @@ -98,12 +103,12 @@ ${doc.requestUsage} <%if(isNotEmpty(doc.responseParams)){%> **Response-fields:** -| Field | Type | Description | Since | -|-------|------|-------------|-------| +| Field | Type | Description | Since | Example | +|-------|------|-------------|-------|---------| <% for(param in doc.responseParams){ %> -|${param.field}|${param.type}|${lineBreaksToBr(param.desc)}|${param.version}| +|${param.field}|${param.type}|${lineBreaksToBr(param.desc)}|${param.version}|${param.value}| <%}%> <%}%> @@ -155,7 +160,7 @@ for(dict in dictList){ <% for(dataDict in dict.dataDictList){ %> -|${dataDict.name}|${dataDict.value}|${dataDict.type}|${htmlEscape(dataDict.desc)}| +|${dataDict.name}|${dataDict.value}|${dataDict.type}|${htmlEscape(dataDict.desc)}|${param.value}| <%}%> <%}%> <%}%> diff --git a/src/main/resources/template/ApiDoc.md b/src/main/resources/template/ApiDoc.md index c4bbbf14..543ebc27 100644 --- a/src/main/resources/template/ApiDoc.md +++ b/src/main/resources/template/ApiDoc.md @@ -21,47 +21,51 @@ for(doc in list){ **Description:** ${doc.detail} -<%if(isNotEmpty(doc.headers)){%> +<%if(isNotEmpty(doc.requestHeaders)){%> **Request-headers:** -| Header | Type | Required | Description | Since | -|--------|------|----------|-------------|-------| -${doc.headers} +| Header | Type | Required | Description | Since | Example | +|--------|------|----------|-------------|-------|---------| +<% +for(param in doc.requestHeaders){ +%> +|${param.name}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.since}|${param.value}| +<%}%> <%}%> <%if(isNotEmpty(doc.pathParams)){%> **Path-parameters:** -| Parameter | Type | Required | Description | Since | -|-----------|------|----------|-------------|-------| +| Parameter | Type | Required | Description | Since | Example | +|-----------|------|----------|-------------|-------|---------| <% for(param in doc.pathParams){ %> -|${param.field}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.version}| +|${param.field}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.version}|${param.value}| <%}%> <%}%> <%if(isNotEmpty(doc.queryParams)){%> **Query-parameters:** -| Parameter | Type | Required | Description | Since | -|-----------|------|----------|-------------|-------| +| Parameter | Type | Required | Description | Since | Example | +|-----------|------|----------|-------------|-------|---------| <% for(param in doc.queryParams){ %> -|${param.field}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.version}| +|${param.field}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.version}|${param.value}| <%}%> <%}%> <%if(isNotEmpty(doc.requestParams)){%> **Body-parameters:** -| Parameter | Type | Required | Description | Since | -|-----------|------|----------|-------------|-------| +| Parameter | Type | Required | Description | Since | Example | +|-----------|------|----------|-------------|-------|---------| <% for(param in doc.requestParams){ %> -|${param.field}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.version}| +|${param.field}|${param.type}|${param.required}|${lineBreaksToBr(param.desc)}|${param.version}|${param.value}| <%}%> <%}%> @@ -75,12 +79,12 @@ ${doc.requestUsage} **Response-fields:** -| Field | Type | Description | Since | -|-------|------|-------------|-------| +| Field | Type | Description | Since | Example | +|-------|------|-------------|-------|---------| <% for(param in doc.responseParams){ %> -|${param.field}|${param.type}|${lineBreaksToBr(param.desc)}|${param.version}| +|${param.field}|${param.type}|${lineBreaksToBr(param.desc)}|${param.version}|${param.value}| <%}%> <%}%>