1+ {
2+ "openapi" : " 3.0.3" ,
3+ "info" : {
4+ "title" : " Discriminator Mapping Test" ,
5+ "version" : " v1.0.0"
6+ },
7+ "paths" : {
8+ "/pets" : {
9+ "get" : {
10+ "summary" : " List pets" ,
11+ "operationId" : " listPets" ,
12+ "responses" : {
13+ "200" : {
14+ "description" : " List of pets" ,
15+ "content" : {
16+ "application/json" : {
17+ "schema" : {
18+ "type" : " array" ,
19+ "items" : {
20+ "$ref" : " #/components/schemas/Pet"
21+ }
22+ }
23+ }
24+ }
25+ }
26+ }
27+ },
28+ "post" : {
29+ "summary" : " Create a pet" ,
30+ "operationId" : " createPet" ,
31+ "requestBody" : {
32+ "required" : true ,
33+ "content" : {
34+ "application/json" : {
35+ "schema" : {
36+ "$ref" : " #/components/schemas/Pet"
37+ }
38+ }
39+ }
40+ },
41+ "responses" : {
42+ "201" : {
43+ "description" : " Pet created" ,
44+ "content" : {
45+ "application/json" : {
46+ "schema" : {
47+ "$ref" : " #/components/schemas/Pet"
48+ }
49+ }
50+ }
51+ }
52+ }
53+ }
54+ },
55+ "/vehicles" : {
56+ "get" : {
57+ "summary" : " List vehicles" ,
58+ "operationId" : " listVehicles" ,
59+ "responses" : {
60+ "200" : {
61+ "description" : " List of vehicles" ,
62+ "content" : {
63+ "application/json" : {
64+ "schema" : {
65+ "type" : " array" ,
66+ "items" : {
67+ "$ref" : " #/components/schemas/Vehicle"
68+ }
69+ }
70+ }
71+ }
72+ }
73+ }
74+ }
75+ },
76+ "/notifications" : {
77+ "get" : {
78+ "summary" : " List notifications" ,
79+ "operationId" : " listNotifications" ,
80+ "responses" : {
81+ "200" : {
82+ "description" : " List of notifications" ,
83+ "content" : {
84+ "application/json" : {
85+ "schema" : {
86+ "type" : " array" ,
87+ "items" : {
88+ "$ref" : " #/components/schemas/Notification"
89+ }
90+ }
91+ }
92+ }
93+ }
94+ }
95+ }
96+ }
97+ },
98+ "components" : {
99+ "schemas" : {
100+ "Pet" : {
101+ "oneOf" : [
102+ {
103+ "$ref" : " #/components/schemas/Dog"
104+ },
105+ {
106+ "$ref" : " #/components/schemas/Cat"
107+ },
108+ {
109+ "$ref" : " #/components/schemas/Bird"
110+ }
111+ ],
112+ "discriminator" : {
113+ "propertyName" : " petType" ,
114+ "mapping" : {
115+ "dog" : " #/components/schemas/Dog" ,
116+ "canine" : " #/components/schemas/Dog" ,
117+ "cat" : " #/components/schemas/Cat" ,
118+ "feline" : " #/components/schemas/Cat" ,
119+ "bird" : " #/components/schemas/Bird" ,
120+ "avian" : " #/components/schemas/Bird"
121+ }
122+ }
123+ },
124+ "Dog" : {
125+ "type" : " object" ,
126+ "required" : [" petType" , " name" , " breed" ],
127+ "properties" : {
128+ "petType" : {
129+ "type" : " string"
130+ },
131+ "name" : {
132+ "type" : " string"
133+ },
134+ "breed" : {
135+ "type" : " string"
136+ },
137+ "barkLoudness" : {
138+ "type" : " integer" ,
139+ "minimum" : 1 ,
140+ "maximum" : 10
141+ }
142+ }
143+ },
144+ "Cat" : {
145+ "type" : " object" ,
146+ "required" : [" petType" , " name" , " breed" ],
147+ "properties" : {
148+ "petType" : {
149+ "type" : " string"
150+ },
151+ "name" : {
152+ "type" : " string"
153+ },
154+ "breed" : {
155+ "type" : " string"
156+ },
157+ "meowVolume" : {
158+ "type" : " integer" ,
159+ "minimum" : 1 ,
160+ "maximum" : 10
161+ }
162+ }
163+ },
164+ "Bird" : {
165+ "type" : " object" ,
166+ "required" : [" petType" , " name" , " species" ],
167+ "properties" : {
168+ "petType" : {
169+ "type" : " string"
170+ },
171+ "name" : {
172+ "type" : " string"
173+ },
174+ "species" : {
175+ "type" : " string"
176+ },
177+ "canTalk" : {
178+ "type" : " boolean"
179+ }
180+ }
181+ },
182+ "Vehicle" : {
183+ "oneOf" : [
184+ {
185+ "$ref" : " #/components/schemas/Car"
186+ },
187+ {
188+ "$ref" : " #/components/schemas/Motorcycle"
189+ }
190+ ],
191+ "discriminator" : {
192+ "propertyName" : " vehicleType"
193+ }
194+ },
195+ "Car" : {
196+ "type" : " object" ,
197+ "required" : [" vehicleType" , " make" , " model" ],
198+ "properties" : {
199+ "vehicleType" : {
200+ "type" : " string"
201+ },
202+ "make" : {
203+ "type" : " string"
204+ },
205+ "model" : {
206+ "type" : " string"
207+ },
208+ "doors" : {
209+ "type" : " integer" ,
210+ "minimum" : 2 ,
211+ "maximum" : 5
212+ }
213+ }
214+ },
215+ "Motorcycle" : {
216+ "type" : " object" ,
217+ "required" : [" vehicleType" , " make" , " model" ],
218+ "properties" : {
219+ "vehicleType" : {
220+ "type" : " string"
221+ },
222+ "make" : {
223+ "type" : " string"
224+ },
225+ "model" : {
226+ "type" : " string"
227+ },
228+ "engineSize" : {
229+ "type" : " number"
230+ }
231+ }
232+ },
233+ "Notification" : {
234+ "anyOf" : [
235+ {
236+ "$ref" : " #/components/schemas/EmailNotification"
237+ },
238+ {
239+ "$ref" : " #/components/schemas/SMSNotification"
240+ },
241+ {
242+ "$ref" : " #/components/schemas/PushNotification"
243+ }
244+ ],
245+ "discriminator" : {
246+ "propertyName" : " notificationType" ,
247+ "mapping" : {
248+ "email" : " #/components/schemas/EmailNotification" ,
249+ "mail" : " #/components/schemas/EmailNotification" ,
250+ "sms" : " #/components/schemas/SMSNotification" ,
251+ "text" : " #/components/schemas/SMSNotification" ,
252+ "push" : " #/components/schemas/PushNotification" ,
253+ "mobile" : " #/components/schemas/PushNotification"
254+ }
255+ }
256+ },
257+ "EmailNotification" : {
258+ "type" : " object" ,
259+ "required" : [" notificationType" , " recipient" , " subject" ],
260+ "properties" : {
261+ "notificationType" : {
262+ "type" : " string"
263+ },
264+ "recipient" : {
265+ "type" : " string" ,
266+ "format" : " email"
267+ },
268+ "subject" : {
269+ "type" : " string"
270+ },
271+ "body" : {
272+ "type" : " string"
273+ }
274+ }
275+ },
276+ "SMSNotification" : {
277+ "type" : " object" ,
278+ "required" : [" notificationType" , " phoneNumber" , " message" ],
279+ "properties" : {
280+ "notificationType" : {
281+ "type" : " string"
282+ },
283+ "phoneNumber" : {
284+ "type" : " string"
285+ },
286+ "message" : {
287+ "type" : " string" ,
288+ "maxLength" : 160
289+ }
290+ }
291+ },
292+ "PushNotification" : {
293+ "type" : " object" ,
294+ "required" : [" notificationType" , " deviceId" , " title" ],
295+ "properties" : {
296+ "notificationType" : {
297+ "type" : " string"
298+ },
299+ "deviceId" : {
300+ "type" : " string"
301+ },
302+ "title" : {
303+ "type" : " string"
304+ },
305+ "body" : {
306+ "type" : " string"
307+ },
308+ "badge" : {
309+ "type" : " integer" ,
310+ "minimum" : 0
311+ }
312+ }
313+ }
314+ }
315+ }
316+ }
0 commit comments