Created
November 29, 2021 10:05
-
-
Save ponelat/7ba6f1ec61a6b7e0054bf0b3a7f80f0b to your computer and use it in GitHub Desktop.
Using oneOf in bodies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openapi: 3.0.3 | |
info: | |
title: Example multiple responses | |
description: Example of multiple responses | |
version: 1.0.0 | |
paths: | |
/one: | |
post: | |
description: Multiple request/response types. | |
requestBody: | |
description: Multiple request bodies | |
content: | |
application/json: | |
schema: | |
oneOf: | |
- $ref: '#/components/schemas/Dog' | |
- $ref: '#/components/schemas/Cat' | |
- $ref: '#/components/schemas/Hamster' | |
responses: | |
'200': | |
description: Multiple response types | |
content: | |
application/json: | |
schema: | |
oneOf: | |
- $ref: '#/components/schemas/Dog' | |
- $ref: '#/components/schemas/Cat' | |
- $ref: '#/components/schemas/Hamster' | |
components: | |
schemas: | |
Dog: | |
type: object | |
properties: | |
size: | |
type: string | |
example: Large | |
Cat: | |
type: object | |
properties: | |
favouriteToy: | |
type: string | |
example: Scratch post | |
Hamster: | |
type: object | |
properties: | |
favouriteToy: | |
type: string | |
example: Hamster wheel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment