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.
fix: 1917 fixed handling of example request for invalid requests
- Loading branch information
Łukasz Kużyński
committed
Oct 18, 2021
1 parent
1b73f8f
commit 444012b
Showing
2 changed files
with
81 additions
and
8 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
66 changes: 66 additions & 0 deletions
66
test-harness/specs/violations/ignoring-example-key-for-invalid-body.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,66 @@ | ||
====test==== | ||
If Prism detects an invalid input (422 code), but user requests for other code (200) with an example key then example key and requested code are ignored | ||
====spec==== | ||
openapi: 3.1.0 | ||
info: | ||
title: test | ||
version: '1.0' | ||
servers: | ||
- url: 'http://localhost:3000' | ||
paths: | ||
/test: | ||
post: | ||
summary: '' | ||
operationId: post-test | ||
responses: | ||
'200': | ||
description: OK | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
examples: | ||
200-test: | ||
value: | ||
name: 200-test | ||
'422': | ||
description: Unprocessable Entity (WebDAV) | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
examples: | ||
422-test: | ||
value: | ||
name: 422-test | ||
422-test2: | ||
value: | ||
name: 422-test2 | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
test: | ||
type: string | ||
required: | ||
- test | ||
====server==== | ||
mock -p 4010 ${document} --errors | ||
====command==== | ||
curl --request POST --url 'http://localhost:4010/test' \ | ||
--header 'Content-Type: application/json' \ | ||
--header 'Prefer: code=200, example=200-test' \ | ||
--data '{}' | ||
====expect==== | ||
HTTP/1.1 422 Unauthorized | ||
sl-violations: [{"location":["request","body"],"severity":"Error","code":"required","message":"must have required property 'test'"}] | ||
|
||
{"name":"422-test"} |