I'm trying to document a model that always returns a custom response code and associated description. For a single HTTP response code, there could be multiple custom response codes. For example, a 400 response might include:
| HTTP Code | Code | Description |
|---|---|---|
| 400 | 1 | Error 1 |
| 400 | 2 | Error 2 |
| 400 | 3 | Error 3 |
I could document that a 400 status returns an "Error" object that has "Code" and "Description". But I'd like to include all of the custom status codes in the documentation if that's even possible. Is it possible? If so, how would I go about doing this?
For anyone facing this problem nowadays, here's how I was able to solve it:
'422':
description: 'Unprocessable Entity'
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/SchemaForErrror1'
- $ref: '#/components/schemas/SchemaForErrror2'
examples:
Error1:
$ref: '#/components/examples/ExampleForError1'
Error2:
$ref: '#/components/examples/ExampleForError2'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With