1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Adapted from OpenAPITools/openapi-generator
# `modules/openapi-generator/src/test/resources/3_0/allOf.yaml` (Apache-2.0).
# Operation operationIds added; the discriminator's property name is
# `kind` (renamed from the original `$_type`) so the synthesized Rust
# field name stays a plain identifier.
openapi: 3.0.1
info:
version: 1.0.0
title: Example
paths:
/person/{personId}:
get:
operationId: getPerson
parameters:
- name: personId
in: path
required: true
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Person'
components:
schemas:
Person:
type: object
discriminator:
propertyName: kind
mapping:
a: '#/components/schemas/Adult'
c: Child
required:
- kind
- lastName
- firstName
properties:
kind:
type: string
lastName:
type: string
firstName:
type: string
Adult:
description: A representation of an adult
allOf:
- $ref: '#/components/schemas/Person'
- type: object
required:
properties:
hasChildren:
type: boolean
Child:
description: A representation of a child
allOf:
- $ref: '#/components/schemas/Person'
- type: object
required:
properties:
age:
type: integer
format: int32