Skip to content

Instantly share code, notes, and snippets.

@ponelat
Created November 29, 2021 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ponelat/7ba6f1ec61a6b7e0054bf0b3a7f80f0b to your computer and use it in GitHub Desktop.
Save ponelat/7ba6f1ec61a6b7e0054bf0b3a7f80f0b to your computer and use it in GitHub Desktop.
Using oneOf in bodies
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