A way to test 422 response or to avoid automatic testing of this response #1274
-
Hi, I have 2 type of response written in my OpenAPI.yaml file for a route: post:
requestBody:
description: Brand to create
content:
application/json:
schema:
$ref: "#/components/schemas/Foo"
examples:
...
required: true
responses:
"201":
content:
application/json:
schema:
$ref: "#/components/schemas/Bar"
examples:
....
description: Successful Response
"422":
description: Validation Error
content:
application/json:
... So I have 2 questions: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes definitely! You can define different fragments that will be merged together. Something like: post:
requestBody:
description: Brand to create
content:
application/json:
schema:
$ref: "#/components/schemas/Foo"
examples:
expect_201:
value:
...
expect_422:
value:
...
required: true
responses:
"201":
content:
application/json:
schema:
$ref: "#/components/schemas/Bar"
examples:
expect_201:
value:
...
description: Successful Response
"422":
description: Validation Error
content:
application/json:
examples:
expect_422:
value:
... In mocking mode, the 2 request/response pairs will give you the different response codes 201 and 422. In testing mode, the 2 requests will be issued to endpoint and expect the 2 different response codes 201 and 422. |
Beta Was this translation helpful? Give feedback.
Hi @oliviernguyenquoc,
Yes definitely! You can define different fragments that will be merged together. Something like: