Skip to content

Commit

Permalink
feat(markdown): Add the 'Example' field to the markdown document para…
Browse files Browse the repository at this point in the history
…meter

Change template ApiDoc.md and AllInOne.md,Add the 'Example' field to the markdown document parameter

Closes #971
  • Loading branch information
jasonkung22 committed Nov 27, 2024
1 parent 42e8714 commit 2d4f952
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 33 deletions.
39 changes: 22 additions & 17 deletions src/main/resources/template/AllInOne.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}|
<%}%>
<%}%>

Expand All @@ -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}|
<%}%>
<%}%>

Expand Down Expand Up @@ -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}|
<%}%>
<%}%>
<%}%>
36 changes: 20 additions & 16 deletions src/main/resources/template/ApiDoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}|
<%}%>
<%}%>

Expand All @@ -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}|
<%}%>
<%}%>

Expand Down

0 comments on commit 2d4f952

Please sign in to comment.