Skip to content

added multiple response examples for openAPI #642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions api-playground/openapi/advanced-features.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## `oneOf`, `anyOf`, `allOf`

For complex datatypes, OpenAPI provides the `oneOf`, `anyOf`, and `allOf` keywords, allowing you to combine schemas in certain ways. You can read more about these keywords in the [Swagger documentation](https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/), but essentially:

Check warning on line 10 in api-playground/openapi/advanced-features.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

api-playground/openapi/advanced-features.mdx#L10

Did you really mean 'datatypes'?

- `oneOf` functions like an "exclusive-or" operator
- `anyOf` functions like an "or" operator
Expand Down Expand Up @@ -54,7 +54,7 @@

### Providing options with `oneOf` and `anyOf`

When you use `oneOf` or `anyOf`, Mintlify displays the options in a tabbed container. To give your options helpful names, make sure to give each subschema a `title` field. For example, here's how you might display two different types of delivery addresses:

Check warning on line 57 in api-playground/openapi/advanced-features.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

api-playground/openapi/advanced-features.mdx#L57

Did you really mean 'subschema'?

```yaml
delivery_address:
Expand Down Expand Up @@ -135,3 +135,32 @@
const planter = require('planter');
planter.list({ potted: true });
```

## Multiple Response Examples

If your API returns different responses based on the request, you can provide multiple examples.

For example here's two different responses for a 200 response.

```yaml [expandable]
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/YourResponseSchema'
examples:
us:
summary: Response for United States
value:
countryCode: "US"
currencyCode: "USD"
taxRate: 0.0825
gb:
summary: Response for United Kingdom
value:
countryCode: "GB"
currencyCode: "GBP"
taxRate: 0.20
```