Skip to content

A way to test 422 response or to avoid automatic testing of this response #1274

Discussion options

You must be logged in to vote

Hi @oliviernguyenquoc,

1/ Is it possible to have a different requestBody to test both "OK" (Code: 201) scenario and "Not OK" (Code 422) scenario ?

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:
  …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by oliviernguyenquoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment