Skip to content
This repository has been archived by the owner on Dec 27, 2024. It is now read-only.

Commit

Permalink
feat: support now 'text/plain' when body request is raw and language …
Browse files Browse the repository at this point in the history
…is text
  • Loading branch information
joolfe committed Aug 28, 2022
1 parent f5ee60d commit 53cee26
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 13 deletions.
10 changes: 9 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ function parseBody (body = {}, method) {
example = raw
}
}

content = {
'application/json': {
schema: {
Expand All @@ -165,6 +164,15 @@ function parseBody (body = {}, method) {
}
}
}
} else if (language === 'text') {
content = {
'text/plain': {
schema: {
type: 'string',
example: raw
}
}
}
} else {
content = {
'application/json': {
Expand Down
7 changes: 6 additions & 1 deletion test/resources/input/v2/RawBody.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
"header": [],
"body": {
"mode": "raw",
"raw": "testesttestest"
"raw": "testesttestest",
"options": {
"raw": {
"language": "text"
}
}
},
"url": "https://api.io/test",
"description": "Test Raw Body"
Expand Down
7 changes: 6 additions & 1 deletion test/resources/input/v21/RawBody.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
"header": [],
"body": {
"mode": "raw",
"raw": "testesttestest"
"raw": "testesttestest",
"options": {
"raw": {
"language": "text"
}
}
},
"url": {
"raw": "https://api.io/test",
Expand Down
2 changes: 1 addition & 1 deletion test/resources/output/Basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ paths:
description: Just an example of text raw body
requestBody:
content:
application/json:
text/plain:
schema:
type: string
example: This is an example Note
Expand Down
2 changes: 1 addition & 1 deletion test/resources/output/BasicWithAuth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ paths:
description: Just an example of text raw body
requestBody:
content:
application/json:
text/plain:
schema:
type: string
example: This is an example Note
Expand Down
2 changes: 1 addition & 1 deletion test/resources/output/ExternalDocsOptsPartial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ paths:
description: Just an example of text raw body
requestBody:
content:
application/json:
text/plain:
schema:
type: string
example: This is an example Note
Expand Down
2 changes: 1 addition & 1 deletion test/resources/output/LicenseContactPartial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ paths:
description: Just an example of text raw body
requestBody:
content:
application/json:
text/plain:
schema:
type: string
example: This is an example Note
Expand Down
2 changes: 1 addition & 1 deletion test/resources/output/LicenseContactPartial2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ paths:
description: Just an example of text raw body
requestBody:
content:
application/json:
text/plain:
schema:
type: string
example: This is an example Note
Expand Down
2 changes: 1 addition & 1 deletion test/resources/output/MultipleServers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ paths:
description: Just an example of text raw body
requestBody:
content:
application/json:
text/plain:
schema:
type: string
example: This is an example Note
Expand Down
2 changes: 1 addition & 1 deletion test/resources/output/NoServers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ paths:
description: Just an example of text raw body
requestBody:
content:
application/json:
text/plain:
schema:
type: string
example: This is an example Note
Expand Down
4 changes: 2 additions & 2 deletions test/resources/output/RawBody.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ paths:
description: Test Raw Body
requestBody:
content:
application/json:
text/plain:
schema:
type: object
type: string
example: testesttestest
responses:
'200':
Expand Down
2 changes: 1 addition & 1 deletion test/resources/output/ServersOpts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ paths:
description: Just an example of text raw body
requestBody:
content:
application/json:
text/plain:
schema:
type: string
example: This is an example Note
Expand Down

0 comments on commit 53cee26

Please sign in to comment.