-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallOf.yml
More file actions
127 lines (120 loc) · 3.57 KB
/
allOf.yml
File metadata and controls
127 lines (120 loc) · 3.57 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
openapi: 3.1.0
info:
title: Complex Inheritance & Intersection Test
version: 1.3.0
description: |
A stress test for `allOf` merging logic with a `oneOf` discriminator.
paths:
/products/books:
post:
summary: Create a complex book record
requestBody:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/PhysicalBook'
- $ref: '#/components/schemas/DigitalBook'
# This tells the UI/Validator which schema is which
discriminator:
propertyName: bookType
mapping:
physical: '#/components/schemas/PhysicalBook'
digital: '#/components/schemas/DigitalBook'
responses:
"201":
description: Created
components:
schemas:
BaseProduct:
type: object
required: [id, sku, bookType] # bookType is now required for all
properties:
id:
type: string
format: uuid
sku:
type: string
pattern: "^[A-Z]{3}-[0-9]{4}$"
bookType:
type: string
description: "Discriminator field to distinguish between physical and digital."
status:
type: string
enum: [DRAFT, PUBLISHED, ARCHIVED, DELETED]
AuditMeta:
type: object
required: [timestamps]
properties:
timestamps:
type: object
properties:
createdAt: { type: string, format: date-time }
updatedAt: { type: string, format: date-time }
tags:
type: array
minItems: 1
items:
type: string
ActiveProductConstraint:
type: object
properties:
status:
enum: [PUBLISHED]
tags:
maxItems: 5
uniqueItems: true
PhysicalBook:
title: Physical Book
allOf:
- $ref: '#/components/schemas/BaseProduct'
- $ref: '#/components/schemas/AuditMeta'
- $ref: '#/components/schemas/ActiveProductConstraint'
- type: object
required: [dimensions, weight]
properties:
# Constraining the discriminator for this specific branch
bookType:
type: string
const: physical
dimensions:
type: object
required: [height, width]
properties:
height: { type: number }
width: { type: number }
unit: { type: string, enum: [cm, in] }
weight:
type: number
distribution:
type: array
items:
allOf:
- $ref: '#/components/schemas/WarehouseLocation'
- type: object
properties:
stockCount: { type: integer, minimum: 0 }
DigitalBook:
title: Digital Book
allOf:
- $ref: '#/components/schemas/BaseProduct'
- $ref: '#/components/schemas/AuditMeta'
- type: object
required: [downloadUrl, fileSize]
properties:
bookType:
type: string
const: digital
downloadUrl: { type: string, format: uri }
fileSize: { type: integer }
formats:
type: array
items:
type: string
enum: [pdf, epub, mobi]
WarehouseLocation:
type: object
required: [warehouseCode]
properties:
warehouseCode: { type: string }
region: { type: string }