Created
September 9, 2017 15:41
-
-
Save owenconti/716bdb401a0603dc3b28e3d78ae55318 to your computer and use it in GitHub Desktop.
OAS3 oneOf, anyOf
This file contains hidden or 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.0 | |
info: | |
version: 0.0.0 | |
title: test | |
paths: {} | |
components: | |
schemas: | |
# Item type is displayed | |
ArrayOfStr: | |
type: array | |
items: | |
type: string | |
# Item type is NOT displayed | |
ArrayOfStrOrInt: | |
type: array | |
items: | |
oneOf: | |
- type: integer | |
- type: string | |
ArrayOfPet: | |
type: array | |
items: | |
$ref: '#/components/schemas/Pet' | |
ArrayOfPetOrStringOrInt: | |
type: array | |
items: | |
oneOf: | |
- $ref: '#/components/schemas/Pet' | |
- type: string | |
- type: integer | |
# Neither model name nor contents is displayed | |
CatOrDog: | |
anyOf: | |
- $ref: '#/components/schemas/Cat' | |
- $ref: '#/components/schemas/Dog' | |
Pet: | |
type: object | |
properties: | |
name: | |
type: string | |
required: | |
- name | |
Cat: | |
allOf: | |
- $ref: '#/components/schemas/Pet' | |
- type: object | |
properties: | |
huntingSkill: | |
type: string | |
description: The measured skill for hunting | |
default: lazy | |
enum: | |
- clueless | |
- lazy | |
- adventurous | |
- aggressive | |
Dog: | |
allOf: | |
- $ref: '#/components/schemas/Pet' | |
- type: object | |
properties: | |
packSize: | |
type: integer | |
format: int32 | |
description: the size of the pack the dog is from | |
default: 0 | |
minimum: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment