Skip to content

Commit f9dde6a

Browse files
committed
Add spec with oneOf using discriminator
1 parent 44a79ac commit f9dde6a

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
openapi: 3.0.1
2+
info:
3+
title: Example
4+
description: An example
5+
version: '0.1'
6+
contact:
7+
email: contact@example.org
8+
url: 'https://example.org'
9+
servers:
10+
- url: http://example.org
11+
tags:
12+
- name: bird
13+
paths:
14+
'/v1/bird/{id}':
15+
get:
16+
tags:
17+
- bird
18+
responses:
19+
'200':
20+
description: OK
21+
content:
22+
application/json:
23+
schema:
24+
$ref: '#/components/schemas/animal'
25+
operationId: get-bird
26+
parameters:
27+
- schema:
28+
type: string
29+
format: uuid
30+
name: id
31+
in: path
32+
required: true
33+
components:
34+
schemas:
35+
animal:
36+
title: An animal
37+
oneOf:
38+
- $ref: '#/components/schemas/bird'
39+
- $ref: '#/components/schemas/robobird'
40+
discriminator:
41+
propertyName: discriminator
42+
mapping:
43+
BIRD: '#/components/schemas/bird'
44+
ROBOBIRD: '#/components/schemas/robobird'
45+
another_animal:
46+
title: Another animal
47+
oneOf:
48+
- $ref: '#/components/schemas/bird'
49+
- $ref: '#/components/schemas/robobird'
50+
discriminator:
51+
propertyName: another_discriminator
52+
mapping:
53+
ANOTHER_BIRD: '#/components/schemas/bird'
54+
ANOTHER_ROBOBIRD: '#/components/schemas/robobird'
55+
56+
bird:
57+
title: A bird
58+
required:
59+
- discriminator
60+
- another_discriminator
61+
properties:
62+
propertyA:
63+
type: string
64+
sameNameProperty:
65+
type: integer
66+
discriminator:
67+
type: string
68+
another_discriminator:
69+
type: string
70+
robobird:
71+
title: A robo-bird
72+
required:
73+
- discriminator
74+
- another_discriminator
75+
properties:
76+
propertyB:
77+
type: string
78+
sameNameProperty:
79+
type: string
80+
discriminator:
81+
type: string
82+
another_discriminator:
83+
type: string

0 commit comments

Comments
 (0)