cancel
Showing results for 
Search instead for 
Did you mean: 

How can we write different message samples for the same response status code in OAS 3.0?

AayushiYadav
Frequent Visitor

How can we write different message samples for the same response status code in OAS 3.0?

Hi,

How can we write different message samples for the same response status code?

'400':
description: Any exception occured.
content:
application/json:
schema:
$ref: "#/components/schemas/error"
'400':
description: Plain text cannot be blanked.
content:
application/json:
schema:
$ref: "#/components/schemas/error"
400:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/responsenestedobj"

 

how to achieve it?

 

Thanks and Regards,

Aayushi Yadav

1 REPLY 1
HKosova
Moderator

Re: How can we write different message samples for the same response status code in OAS 3.0?

Hi @AayushiYadav,

 

Each HTTP status code can be defined only once per operation, so you'll need to merge all the 400 response definitions into one. For example, like this:

 

        '400':
          description: >-
            Possible reasons:
            
            * Plain text cannot be blanked.
            * Any exception occurred.
            * Unexpected error.

          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/error"
                  - $ref: "#/components/schemas/responsenestedobj"

 


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors