1 | "use strict";
|
---|
2 |
|
---|
3 | var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
---|
4 | exports.__esModule = true;
|
---|
5 | exports.default = void 0;
|
---|
6 | var _apidomCore = require("@swagger-api/apidom-core");
|
---|
7 | var _apidomNsOpenapi = require("@swagger-api/apidom-ns-openapi-3-0");
|
---|
8 | var _Info = _interopRequireDefault(require("../../elements/Info.cjs"));
|
---|
9 | var _Contact = _interopRequireDefault(require("../../elements/Contact.cjs"));
|
---|
10 | var _License = _interopRequireDefault(require("../../elements/License.cjs"));
|
---|
11 | var _Paths = _interopRequireDefault(require("../../elements/Paths.cjs"));
|
---|
12 | var _PathItem = _interopRequireDefault(require("../../elements/PathItem.cjs"));
|
---|
13 | var _Components = _interopRequireDefault(require("../../elements/Components.cjs"));
|
---|
14 | var _ExternalDocumentation = _interopRequireDefault(require("../../elements/ExternalDocumentation.cjs"));
|
---|
15 | var _Operation = _interopRequireDefault(require("../../elements/Operation.cjs"));
|
---|
16 | var _Schema = _interopRequireDefault(require("../../elements/Schema.cjs"));
|
---|
17 | var _RequestBody = _interopRequireDefault(require("../../elements/RequestBody.cjs"));
|
---|
18 | var _Responses = _interopRequireDefault(require("../../elements/Responses.cjs"));
|
---|
19 | var _Response = _interopRequireDefault(require("../../elements/Response.cjs"));
|
---|
20 | var _Server = _interopRequireDefault(require("../../elements/Server.cjs"));
|
---|
21 | var _Discriminator = _interopRequireDefault(require("../../elements/Discriminator.cjs"));
|
---|
22 | var _Xml = _interopRequireDefault(require("../../elements/Xml.cjs"));
|
---|
23 | var _OAuthFlows = _interopRequireDefault(require("../../elements/OAuthFlows.cjs"));
|
---|
24 | var _OAuthFlow = _interopRequireDefault(require("../../elements/OAuthFlow.cjs"));
|
---|
25 | var _ServerVariable = _interopRequireDefault(require("../../elements/ServerVariable.cjs"));
|
---|
26 | var _Parameter = _interopRequireDefault(require("../../elements/Parameter.cjs"));
|
---|
27 | var _Example = _interopRequireDefault(require("../../elements/Example.cjs"));
|
---|
28 | var _Header = _interopRequireDefault(require("../../elements/Header.cjs"));
|
---|
29 | var _SecurityScheme = _interopRequireDefault(require("../../elements/SecurityScheme.cjs"));
|
---|
30 | var _Link = _interopRequireDefault(require("../../elements/Link.cjs"));
|
---|
31 | var _Callback = _interopRequireDefault(require("../../elements/Callback.cjs"));
|
---|
32 | var _MediaType = _interopRequireDefault(require("../../elements/MediaType.cjs"));
|
---|
33 | var _Encoding = _interopRequireDefault(require("../../elements/Encoding.cjs"));
|
---|
34 | var _SecurityRequirement = _interopRequireDefault(require("../../elements/SecurityRequirement.cjs"));
|
---|
35 | var _Tag = _interopRequireDefault(require("../../elements/Tag.cjs"));
|
---|
36 | var _ComponentsPathItems = _interopRequireDefault(require("../../elements/nces/ComponentsPathItems.cjs"));
|
---|
37 | var _Webhooks = _interopRequireDefault(require("../../elements/nces/Webhooks.cjs"));
|
---|
38 | var _visitor = require("../../traversal/visitor.cjs");
|
---|
39 | /**
|
---|
40 | * OpenAPI 3.1.0 specification elements.
|
---|
41 | */
|
---|
42 |
|
---|
43 | // non-concrete Elements (NCEs)
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * This plugin is specific to YAML 1.2 format, which allows defining key-value pairs
|
---|
47 | * with empty key, empty value, or both. If the value is not provided in YAML format,
|
---|
48 | * this plugin compensates for this missing value with the most appropriate semantic element type.
|
---|
49 | *
|
---|
50 | * https://yaml.org/spec/1.2.2/#72-empty-nodes
|
---|
51 | *
|
---|
52 | * @example
|
---|
53 | *
|
---|
54 | * ```yaml
|
---|
55 | * openapi: 3.1.0
|
---|
56 | * info:
|
---|
57 | * ```
|
---|
58 | * Refracting result without this plugin:
|
---|
59 | *
|
---|
60 | * (OpenApi3_1Element
|
---|
61 | * (MemberElement
|
---|
62 | * (StringElement)
|
---|
63 | * (OpenapiElement))
|
---|
64 | * (MemberElement
|
---|
65 | * (StringElement)
|
---|
66 | * (StringElement))
|
---|
67 | *
|
---|
68 | * Refracting result with this plugin:
|
---|
69 | *
|
---|
70 | * (OpenApi3_1Element
|
---|
71 | * (MemberElement
|
---|
72 | * (StringElement)
|
---|
73 | * (OpenapiElement))
|
---|
74 | * (MemberElement
|
---|
75 | * (StringElement)
|
---|
76 | * (InfoElement))
|
---|
77 | */
|
---|
78 |
|
---|
79 | const schema = {
|
---|
80 | // concrete types handling (CTs)
|
---|
81 | OpenApi3_1Element: {
|
---|
82 | info(...args) {
|
---|
83 | return new _Info.default(...args);
|
---|
84 | },
|
---|
85 | servers(...args) {
|
---|
86 | return new _apidomNsOpenapi.ServersElement(...args);
|
---|
87 | },
|
---|
88 | paths(...args) {
|
---|
89 | return new _Paths.default(...args);
|
---|
90 | },
|
---|
91 | webhooks(...args) {
|
---|
92 | return new _Webhooks.default(...args);
|
---|
93 | },
|
---|
94 | components(...args) {
|
---|
95 | return new _Components.default(...args);
|
---|
96 | },
|
---|
97 | security(...args) {
|
---|
98 | return new _apidomNsOpenapi.SecurityElement(...args);
|
---|
99 | },
|
---|
100 | tags(...args) {
|
---|
101 | return new _apidomNsOpenapi.TagsElement(...args);
|
---|
102 | },
|
---|
103 | externalDocs(...args) {
|
---|
104 | return new _ExternalDocumentation.default(...args);
|
---|
105 | }
|
---|
106 | },
|
---|
107 | InfoElement: {
|
---|
108 | contact(...args) {
|
---|
109 | return new _Contact.default(...args);
|
---|
110 | },
|
---|
111 | license(...args) {
|
---|
112 | return new _License.default(...args);
|
---|
113 | }
|
---|
114 | },
|
---|
115 | ServerElement: {
|
---|
116 | variables(...args) {
|
---|
117 | return new _apidomNsOpenapi.ServerVariablesElement(...args);
|
---|
118 | }
|
---|
119 | },
|
---|
120 | ServerVariableElement: {
|
---|
121 | enum(...args) {
|
---|
122 | return new _apidomCore.ArrayElement(...args);
|
---|
123 | }
|
---|
124 | },
|
---|
125 | PathsElement: {
|
---|
126 | '[key: *]': function key(...args) {
|
---|
127 | return new _PathItem.default(...args);
|
---|
128 | }
|
---|
129 | },
|
---|
130 | PathItemElement: {
|
---|
131 | get(...args) {
|
---|
132 | return new _Operation.default(...args);
|
---|
133 | },
|
---|
134 | put(...args) {
|
---|
135 | return new _Operation.default(...args);
|
---|
136 | },
|
---|
137 | post(...args) {
|
---|
138 | return new _Operation.default(...args);
|
---|
139 | },
|
---|
140 | delete(...args) {
|
---|
141 | return new _Operation.default(...args);
|
---|
142 | },
|
---|
143 | options(...args) {
|
---|
144 | return new _Operation.default(...args);
|
---|
145 | },
|
---|
146 | head(...args) {
|
---|
147 | return new _Operation.default(...args);
|
---|
148 | },
|
---|
149 | patch(...args) {
|
---|
150 | return new _Operation.default(...args);
|
---|
151 | },
|
---|
152 | trace(...args) {
|
---|
153 | return new _Operation.default(...args);
|
---|
154 | },
|
---|
155 | servers(...args) {
|
---|
156 | return new _apidomNsOpenapi.PathItemServersElement(...args);
|
---|
157 | },
|
---|
158 | parameters(...args) {
|
---|
159 | return new _apidomNsOpenapi.PathItemParametersElement(...args);
|
---|
160 | }
|
---|
161 | },
|
---|
162 | OperationElement: {
|
---|
163 | tags(...args) {
|
---|
164 | return new _apidomNsOpenapi.OperationTagsElement(...args);
|
---|
165 | },
|
---|
166 | externalDocs(...args) {
|
---|
167 | return new _ExternalDocumentation.default(...args);
|
---|
168 | },
|
---|
169 | parameters(...args) {
|
---|
170 | return new _apidomNsOpenapi.OperationParametersElement(...args);
|
---|
171 | },
|
---|
172 | requestBody(...args) {
|
---|
173 | return new _RequestBody.default(...args);
|
---|
174 | },
|
---|
175 | responses(...args) {
|
---|
176 | return new _Responses.default(...args);
|
---|
177 | },
|
---|
178 | callbacks(...args) {
|
---|
179 | return new _apidomNsOpenapi.OperationCallbacksElement(...args);
|
---|
180 | },
|
---|
181 | security(...args) {
|
---|
182 | return new _apidomNsOpenapi.OperationSecurityElement(...args);
|
---|
183 | },
|
---|
184 | servers(...args) {
|
---|
185 | return new _apidomNsOpenapi.OperationServersElement(...args);
|
---|
186 | }
|
---|
187 | },
|
---|
188 | ParameterElement: {
|
---|
189 | schema(...args) {
|
---|
190 | return new _Schema.default(...args);
|
---|
191 | },
|
---|
192 | examples(...args) {
|
---|
193 | return new _apidomNsOpenapi.ParameterExamplesElement(...args);
|
---|
194 | },
|
---|
195 | content(...args) {
|
---|
196 | return new _apidomNsOpenapi.ParameterContentElement(...args);
|
---|
197 | }
|
---|
198 | },
|
---|
199 | RequestBodyElement: {
|
---|
200 | content(...args) {
|
---|
201 | return new _apidomNsOpenapi.RequestBodyContentElement(...args);
|
---|
202 | }
|
---|
203 | },
|
---|
204 | MediaTypeElement: {
|
---|
205 | schema(...args) {
|
---|
206 | return new _Schema.default(...args);
|
---|
207 | },
|
---|
208 | examples(...args) {
|
---|
209 | return new _apidomNsOpenapi.MediaTypeExamplesElement(...args);
|
---|
210 | },
|
---|
211 | encoding(...args) {
|
---|
212 | return new _apidomNsOpenapi.MediaTypeEncodingElement(...args);
|
---|
213 | }
|
---|
214 | },
|
---|
215 | EncodingElement: {
|
---|
216 | headers(...args) {
|
---|
217 | return new _apidomNsOpenapi.EncodingHeadersElement(...args);
|
---|
218 | }
|
---|
219 | },
|
---|
220 | ResponsesElement: {
|
---|
221 | '[key: *]': function key(...args) {
|
---|
222 | return new _Response.default(...args);
|
---|
223 | }
|
---|
224 | },
|
---|
225 | ResponseElement: {
|
---|
226 | headers(...args) {
|
---|
227 | return new _apidomNsOpenapi.ResponseHeadersElement(...args);
|
---|
228 | },
|
---|
229 | content(...args) {
|
---|
230 | return new _apidomNsOpenapi.ResponseContentElement(...args);
|
---|
231 | },
|
---|
232 | links(...args) {
|
---|
233 | return new _apidomNsOpenapi.ResponseLinksElement(...args);
|
---|
234 | }
|
---|
235 | },
|
---|
236 | CallbackElement: {
|
---|
237 | '[key: *]': function key(...args) {
|
---|
238 | return new _PathItem.default(...args);
|
---|
239 | }
|
---|
240 | },
|
---|
241 | LinkElement: {
|
---|
242 | server(...args) {
|
---|
243 | return new _Server.default(...args);
|
---|
244 | }
|
---|
245 | },
|
---|
246 | HeaderElement: {
|
---|
247 | schema(...args) {
|
---|
248 | return new _Schema.default(...args);
|
---|
249 | },
|
---|
250 | examples(...args) {
|
---|
251 | return new _apidomNsOpenapi.HeaderExamplesElement(...args);
|
---|
252 | },
|
---|
253 | content(...args) {
|
---|
254 | return new _apidomNsOpenapi.HeaderContentElement(...args);
|
---|
255 | }
|
---|
256 | },
|
---|
257 | ComponentsElement: {
|
---|
258 | schemas(...args) {
|
---|
259 | return new _apidomNsOpenapi.ComponentsSchemasElement(...args);
|
---|
260 | },
|
---|
261 | responses(...args) {
|
---|
262 | return new _apidomNsOpenapi.ComponentsResponsesElement(...args);
|
---|
263 | },
|
---|
264 | parameters(...args) {
|
---|
265 | return new _apidomNsOpenapi.ComponentsParametersElement(...args);
|
---|
266 | },
|
---|
267 | examples(...args) {
|
---|
268 | return new _apidomNsOpenapi.ComponentsExamplesElement(...args);
|
---|
269 | },
|
---|
270 | requestBodies(...args) {
|
---|
271 | return new _apidomNsOpenapi.ComponentsRequestBodiesElement(...args);
|
---|
272 | },
|
---|
273 | headers(...args) {
|
---|
274 | return new _apidomNsOpenapi.ComponentsHeadersElement(...args);
|
---|
275 | },
|
---|
276 | securitySchemes(...args) {
|
---|
277 | return new _apidomNsOpenapi.ComponentsSecuritySchemesElement(...args);
|
---|
278 | },
|
---|
279 | links(...args) {
|
---|
280 | return new _apidomNsOpenapi.ComponentsLinksElement(...args);
|
---|
281 | },
|
---|
282 | callbacks(...args) {
|
---|
283 | return new _apidomNsOpenapi.ComponentsCallbacksElement(...args);
|
---|
284 | },
|
---|
285 | pathItems(...args) {
|
---|
286 | return new _ComponentsPathItems.default(...args);
|
---|
287 | }
|
---|
288 | },
|
---|
289 | SecurityRequirementElement: {
|
---|
290 | '[key: *]': function key(...args) {
|
---|
291 | return new _apidomCore.ArrayElement(...args);
|
---|
292 | }
|
---|
293 | },
|
---|
294 | TagElement: {
|
---|
295 | externalDocs(...args) {
|
---|
296 | return new _ExternalDocumentation.default(...args);
|
---|
297 | }
|
---|
298 | },
|
---|
299 | SchemaElement: {
|
---|
300 | $vocabulary(...args) {
|
---|
301 | const element = new _apidomCore.ObjectElement(...args);
|
---|
302 | element.classes.push('json-schema-$vocabulary');
|
---|
303 | return element;
|
---|
304 | },
|
---|
305 | $defs(...args) {
|
---|
306 | const element = new _apidomCore.ObjectElement(...args);
|
---|
307 | element.classes.push('json-schema-$defs');
|
---|
308 | return element;
|
---|
309 | },
|
---|
310 | allOf(...args) {
|
---|
311 | const element = new _apidomCore.ArrayElement(...args);
|
---|
312 | element.classes.push('json-schema-allOf');
|
---|
313 | return element;
|
---|
314 | },
|
---|
315 | anyOf(...args) {
|
---|
316 | const element = new _apidomCore.ArrayElement(...args);
|
---|
317 | element.classes.push('json-schema-anyOf');
|
---|
318 | return element;
|
---|
319 | },
|
---|
320 | oneOf(...args) {
|
---|
321 | const element = new _apidomCore.ArrayElement(...args);
|
---|
322 | element.classes.push('json-schema-oneOf');
|
---|
323 | return element;
|
---|
324 | },
|
---|
325 | not(...args) {
|
---|
326 | return new _Schema.default(...args);
|
---|
327 | },
|
---|
328 | if(...args) {
|
---|
329 | return new _Schema.default(...args);
|
---|
330 | },
|
---|
331 | then(...args) {
|
---|
332 | return new _Schema.default(...args);
|
---|
333 | },
|
---|
334 | else(...args) {
|
---|
335 | return new _Schema.default(...args);
|
---|
336 | },
|
---|
337 | dependentSchemas(...args) {
|
---|
338 | const element = new _apidomCore.ObjectElement(...args);
|
---|
339 | element.classes.push('json-schema-dependentSchemas');
|
---|
340 | return element;
|
---|
341 | },
|
---|
342 | prefixItems(...args) {
|
---|
343 | const element = new _apidomCore.ArrayElement(...args);
|
---|
344 | element.classes.push('json-schema-prefixItems');
|
---|
345 | return element;
|
---|
346 | },
|
---|
347 | items(...args) {
|
---|
348 | return new _Schema.default(...args);
|
---|
349 | },
|
---|
350 | contains(...args) {
|
---|
351 | return new _Schema.default(...args);
|
---|
352 | },
|
---|
353 | properties(...args) {
|
---|
354 | const element = new _apidomCore.ObjectElement(...args);
|
---|
355 | element.classes.push('json-schema-properties');
|
---|
356 | return element;
|
---|
357 | },
|
---|
358 | patternProperties(...args) {
|
---|
359 | const element = new _apidomCore.ObjectElement(...args);
|
---|
360 | element.classes.push('json-schema-patternProperties');
|
---|
361 | return element;
|
---|
362 | },
|
---|
363 | additionalProperties(...args) {
|
---|
364 | return new _Schema.default(...args);
|
---|
365 | },
|
---|
366 | propertyNames(...args) {
|
---|
367 | return new _Schema.default(...args);
|
---|
368 | },
|
---|
369 | unevaluatedItems(...args) {
|
---|
370 | return new _Schema.default(...args);
|
---|
371 | },
|
---|
372 | unevaluatedProperties(...args) {
|
---|
373 | return new _Schema.default(...args);
|
---|
374 | },
|
---|
375 | type(...args) {
|
---|
376 | const element = new _apidomCore.ArrayElement(...args);
|
---|
377 | element.classes.push('json-schema-type');
|
---|
378 | return element;
|
---|
379 | },
|
---|
380 | enum(...args) {
|
---|
381 | const element = new _apidomCore.ArrayElement(...args);
|
---|
382 | element.classes.push('json-schema-enum');
|
---|
383 | return element;
|
---|
384 | },
|
---|
385 | required(...args) {
|
---|
386 | const element = new _apidomCore.ArrayElement(...args);
|
---|
387 | element.classes.push('json-schema-required');
|
---|
388 | return element;
|
---|
389 | },
|
---|
390 | dependentRequired(...args) {
|
---|
391 | const element = new _apidomCore.ObjectElement(...args);
|
---|
392 | element.classes.push('json-schema-dependentRequired');
|
---|
393 | return element;
|
---|
394 | },
|
---|
395 | examples(...args) {
|
---|
396 | const element = new _apidomCore.ArrayElement(...args);
|
---|
397 | element.classes.push('json-schema-examples');
|
---|
398 | return element;
|
---|
399 | },
|
---|
400 | contentSchema(...args) {
|
---|
401 | return new _Schema.default(...args);
|
---|
402 | },
|
---|
403 | discriminator(...args) {
|
---|
404 | return new _Discriminator.default(...args);
|
---|
405 | },
|
---|
406 | xml(...args) {
|
---|
407 | return new _Xml.default(...args);
|
---|
408 | },
|
---|
409 | externalDocs(...args) {
|
---|
410 | return new _ExternalDocumentation.default(...args);
|
---|
411 | }
|
---|
412 | },
|
---|
413 | DiscriminatorElement: {
|
---|
414 | mapping(...args) {
|
---|
415 | return new _apidomNsOpenapi.DiscriminatorMappingElement(...args);
|
---|
416 | }
|
---|
417 | },
|
---|
418 | SecuritySchemeElement: {
|
---|
419 | flows(...args) {
|
---|
420 | return new _OAuthFlows.default(...args);
|
---|
421 | }
|
---|
422 | },
|
---|
423 | OAuthFlowsElement: {
|
---|
424 | implicit(...args) {
|
---|
425 | return new _OAuthFlow.default(...args);
|
---|
426 | },
|
---|
427 | password(...args) {
|
---|
428 | return new _OAuthFlow.default(...args);
|
---|
429 | },
|
---|
430 | clientCredentials(...args) {
|
---|
431 | return new _OAuthFlow.default(...args);
|
---|
432 | },
|
---|
433 | authorizationCode(...args) {
|
---|
434 | return new _OAuthFlow.default(...args);
|
---|
435 | }
|
---|
436 | },
|
---|
437 | OAuthFlowElement: {
|
---|
438 | scopes(...args) {
|
---|
439 | return new _apidomNsOpenapi.OAuthFlowScopesElement(...args);
|
---|
440 | }
|
---|
441 | },
|
---|
442 | // non-concrete types handling (NCEs)
|
---|
443 | [_Webhooks.default.primaryClass]: {
|
---|
444 | '[key: *]': function key(...args) {
|
---|
445 | return new _PathItem.default(...args);
|
---|
446 | }
|
---|
447 | },
|
---|
448 | [_apidomNsOpenapi.ServerVariablesElement.primaryClass]: {
|
---|
449 | '[key: *]': function key(...args) {
|
---|
450 | return new _ServerVariable.default(...args);
|
---|
451 | }
|
---|
452 | },
|
---|
453 | [_apidomNsOpenapi.ComponentsSchemasElement.primaryClass]: {
|
---|
454 | '[key: *]': function key(...args) {
|
---|
455 | return new _Schema.default(...args);
|
---|
456 | }
|
---|
457 | },
|
---|
458 | [_apidomNsOpenapi.ComponentsResponsesElement.primaryClass]: {
|
---|
459 | '[key: *]': function key(...args) {
|
---|
460 | return new _Response.default(...args);
|
---|
461 | }
|
---|
462 | },
|
---|
463 | [_apidomNsOpenapi.ComponentsParametersElement.primaryClass]: {
|
---|
464 | '[key: *]': function key(...args) {
|
---|
465 | return new _Parameter.default(...args);
|
---|
466 | }
|
---|
467 | },
|
---|
468 | [_apidomNsOpenapi.ComponentsExamplesElement.primaryClass]: {
|
---|
469 | '[key: *]': function key(...args) {
|
---|
470 | return new _Example.default(...args);
|
---|
471 | }
|
---|
472 | },
|
---|
473 | [_apidomNsOpenapi.ComponentsRequestBodiesElement.primaryClass]: {
|
---|
474 | '[key: *]': function key(...args) {
|
---|
475 | return new _RequestBody.default(...args);
|
---|
476 | }
|
---|
477 | },
|
---|
478 | [_apidomNsOpenapi.ComponentsHeadersElement.primaryClass]: {
|
---|
479 | '[key: *]': function key(...args) {
|
---|
480 | return new _Header.default(...args);
|
---|
481 | }
|
---|
482 | },
|
---|
483 | [_apidomNsOpenapi.ComponentsSecuritySchemesElement.primaryClass]: {
|
---|
484 | '[key: *]': function key(...args) {
|
---|
485 | return new _SecurityScheme.default(...args);
|
---|
486 | }
|
---|
487 | },
|
---|
488 | [_apidomNsOpenapi.ComponentsLinksElement.primaryClass]: {
|
---|
489 | '[key: *]': function key(...args) {
|
---|
490 | return new _Link.default(...args);
|
---|
491 | }
|
---|
492 | },
|
---|
493 | [_apidomNsOpenapi.ComponentsCallbacksElement.primaryClass]: {
|
---|
494 | '[key: *]': function key(...args) {
|
---|
495 | return new _Callback.default(...args);
|
---|
496 | }
|
---|
497 | },
|
---|
498 | [_ComponentsPathItems.default.primaryClass]: {
|
---|
499 | '[key: *]': function key(...args) {
|
---|
500 | return new _PathItem.default(...args);
|
---|
501 | }
|
---|
502 | },
|
---|
503 | [_apidomNsOpenapi.OperationCallbacksElement.primaryClass]: {
|
---|
504 | '[key: *]': function key(...args) {
|
---|
505 | return new _Callback.default(...args);
|
---|
506 | }
|
---|
507 | },
|
---|
508 | [_apidomNsOpenapi.ParameterExamplesElement.primaryClass]: {
|
---|
509 | '[key: *]': function key(...args) {
|
---|
510 | return new _Example.default(...args);
|
---|
511 | }
|
---|
512 | },
|
---|
513 | [_apidomNsOpenapi.ParameterContentElement.primaryClass]: {
|
---|
514 | '[key: *]': function key(...args) {
|
---|
515 | return new _MediaType.default(...args);
|
---|
516 | }
|
---|
517 | },
|
---|
518 | [_apidomNsOpenapi.RequestBodyContentElement.primaryClass]: {
|
---|
519 | '[key: *]': function key(...args) {
|
---|
520 | return new _MediaType.default(...args);
|
---|
521 | }
|
---|
522 | },
|
---|
523 | [_apidomNsOpenapi.MediaTypeExamplesElement.primaryClass]: {
|
---|
524 | '[key: *]': function key(...args) {
|
---|
525 | return new _Example.default(...args);
|
---|
526 | }
|
---|
527 | },
|
---|
528 | [_apidomNsOpenapi.MediaTypeEncodingElement.primaryClass]: {
|
---|
529 | '[key: *]': function key(...args) {
|
---|
530 | return new _Encoding.default(...args);
|
---|
531 | }
|
---|
532 | },
|
---|
533 | [_apidomNsOpenapi.EncodingHeadersElement.primaryClass]: {
|
---|
534 | '[key: *]': function key(...args) {
|
---|
535 | return new _Header.default(...args);
|
---|
536 | }
|
---|
537 | },
|
---|
538 | [_apidomNsOpenapi.ResponseHeadersElement.primaryClass]: {
|
---|
539 | '[key: *]': function key(...args) {
|
---|
540 | return new _Header.default(...args);
|
---|
541 | }
|
---|
542 | },
|
---|
543 | [_apidomNsOpenapi.ResponseContentElement.primaryClass]: {
|
---|
544 | '[key: *]': function key(...args) {
|
---|
545 | return new _MediaType.default(...args);
|
---|
546 | }
|
---|
547 | },
|
---|
548 | [_apidomNsOpenapi.ResponseLinksElement.primaryClass]: {
|
---|
549 | '[key: *]': function key(...args) {
|
---|
550 | return new _Link.default(...args);
|
---|
551 | }
|
---|
552 | },
|
---|
553 | 'json-schema-$defs': {
|
---|
554 | '[key: *]': function key(...args) {
|
---|
555 | return new _Schema.default(...args);
|
---|
556 | }
|
---|
557 | },
|
---|
558 | 'json-schema-dependentSchemas': {
|
---|
559 | '[key: *]': function key(...args) {
|
---|
560 | return new _Schema.default(...args);
|
---|
561 | }
|
---|
562 | },
|
---|
563 | 'json-schema-properties': {
|
---|
564 | '[key: *]': function key(...args) {
|
---|
565 | return new _Schema.default(...args);
|
---|
566 | }
|
---|
567 | },
|
---|
568 | [_apidomNsOpenapi.ServersElement.primaryClass]: {
|
---|
569 | '<*>': (...args) => new _Server.default(...args)
|
---|
570 | },
|
---|
571 | [_apidomNsOpenapi.SecurityElement.primaryClass]: {
|
---|
572 | '<*>': function asterisk(...args) {
|
---|
573 | return new _SecurityRequirement.default(...args);
|
---|
574 | }
|
---|
575 | },
|
---|
576 | [_apidomNsOpenapi.TagsElement.primaryClass]: {
|
---|
577 | '<*>': function asterisk(...args) {
|
---|
578 | return new _Tag.default(...args);
|
---|
579 | }
|
---|
580 | },
|
---|
581 | [_apidomNsOpenapi.PathItemServersElement.primaryClass]: {
|
---|
582 | '<*>': function asterisk(...args) {
|
---|
583 | return new _Server.default(...args);
|
---|
584 | }
|
---|
585 | },
|
---|
586 | [_apidomNsOpenapi.PathItemParametersElement.primaryClass]: {
|
---|
587 | '<*>': function asterisk(...args) {
|
---|
588 | return new _Parameter.default(...args);
|
---|
589 | }
|
---|
590 | },
|
---|
591 | [_apidomNsOpenapi.OperationParametersElement.primaryClass]: {
|
---|
592 | '<*>': function asterisk(...args) {
|
---|
593 | return new _Parameter.default(...args);
|
---|
594 | }
|
---|
595 | },
|
---|
596 | [_apidomNsOpenapi.OperationSecurityElement.primaryClass]: {
|
---|
597 | '<*>': function asterisk(...args) {
|
---|
598 | return new _SecurityRequirement.default(...args);
|
---|
599 | }
|
---|
600 | },
|
---|
601 | [_apidomNsOpenapi.OperationServersElement.primaryClass]: {
|
---|
602 | '<*>': function asterisk(...args) {
|
---|
603 | return new _Server.default(...args);
|
---|
604 | }
|
---|
605 | },
|
---|
606 | 'json-schema-allOf': {
|
---|
607 | '<*>': function asterisk(...args) {
|
---|
608 | return new _Schema.default(...args);
|
---|
609 | }
|
---|
610 | },
|
---|
611 | 'json-schema-anyOf': {
|
---|
612 | '<*>': function asterisk(...args) {
|
---|
613 | return new _Schema.default(...args);
|
---|
614 | }
|
---|
615 | },
|
---|
616 | 'json-schema-oneOf': {
|
---|
617 | '<*>': function asterisk(...args) {
|
---|
618 | return new _Schema.default(...args);
|
---|
619 | }
|
---|
620 | },
|
---|
621 | 'json-schema-prefixItems': {
|
---|
622 | '<*>': function asterisk(...args) {
|
---|
623 | return new _Schema.default(...args);
|
---|
624 | }
|
---|
625 | }
|
---|
626 | };
|
---|
627 | const findElementFactory = (ancestor, keyName) => {
|
---|
628 | const elementType = (0, _visitor.getNodeType)(ancestor); // @ts-ignore
|
---|
629 | const keyMapping = schema[elementType] || schema[(0, _apidomCore.toValue)(ancestor.classes.first)];
|
---|
630 | return typeof keyMapping === 'undefined' ? undefined : Object.prototype.hasOwnProperty.call(keyMapping, '[key: *]') ? keyMapping['[key: *]'] : keyMapping[keyName];
|
---|
631 | };
|
---|
632 | const plugin = () => ({
|
---|
633 | predicates
|
---|
634 | }) => {
|
---|
635 | const isEmptyElement = element => predicates.isStringElement(element) && predicates.includesClasses(['yaml-e-node', 'yaml-e-scalar'], element);
|
---|
636 | return {
|
---|
637 | visitor: {
|
---|
638 | StringElement(element, key, parent, path, ancestors) {
|
---|
639 | if (!isEmptyElement(element)) return undefined;
|
---|
640 | const lineage = [...ancestors, parent].filter(predicates.isElement);
|
---|
641 | const parentElement = lineage[lineage.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
|
---|
642 | let elementFactory;
|
---|
643 | let context;
|
---|
644 | if (predicates.isArrayElement(parentElement)) {
|
---|
645 | context = element;
|
---|
646 | elementFactory = findElementFactory(parentElement, '<*>');
|
---|
647 | } else if (predicates.isMemberElement(parentElement)) {
|
---|
648 | context = lineage[lineage.length - 2]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
|
---|
649 | elementFactory = findElementFactory(context, (0, _apidomCore.toValue)(parentElement.key));
|
---|
650 | }
|
---|
651 |
|
---|
652 | // no element factory found
|
---|
653 | if (typeof elementFactory !== 'function') return undefined;
|
---|
654 | return elementFactory.call({
|
---|
655 | context
|
---|
656 | }, undefined, (0, _apidomCore.cloneDeep)(element.meta), (0, _apidomCore.cloneDeep)(element.attributes));
|
---|
657 | }
|
---|
658 | }
|
---|
659 | };
|
---|
660 | };
|
---|
661 | var _default = exports.default = plugin; |
---|