This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
forked from stoplightio/prism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow for empty request bodies to skip validation, fixes stoplightio#…
- Loading branch information
Daniel A. White
authored
Feb 17, 2022
1 parent
705fca1
commit 03b46ff
Showing
4 changed files
with
119 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
test-harness/specs/validate-body-params/enforce-content-type-if-body-included.oas3_1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
====test==== | ||
Given a request body when the spec hasn't specified one | ||
then return 415 | ||
====spec==== | ||
openapi: '3.1.0' | ||
paths: | ||
/path: | ||
post: | ||
responses: | ||
200: | ||
content: | ||
text/plain: | ||
example: ok | ||
415: | ||
content: | ||
text/plain: | ||
example: no body allowed | ||
====server==== | ||
mock -p 4010 ${document} | ||
====command==== | ||
curl -i -X POST http://localhost:4010/path -H "Content-Type: text/plain" --data "empty" | ||
====expect==== | ||
HTTP/1.1 415 Bad Request | ||
content-type: text/plain | ||
|
||
no body allowed |
22 changes: 22 additions & 0 deletions
22
test-harness/specs/validate-body-params/ignore-content-type-if-empty-body.oas3_1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
====test==== | ||
Given a request declaring a content-type but has no body | ||
then return 200 | ||
====spec==== | ||
openapi: '3.1.0' | ||
paths: | ||
/path: | ||
post: | ||
responses: | ||
200: | ||
content: | ||
text/plain: | ||
example: ok | ||
====server==== | ||
mock -p 4010 ${document} | ||
====command==== | ||
curl -i -X POST http://localhost:4010/path -H "Content-Type: text/plain" | ||
====expect==== | ||
HTTP/1.1 200 OK | ||
content-type: text/plain | ||
|
||
ok |