@speclynx/apidom-ns-openapi-2 4.0.3 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/apidom-ns-openapi-2.browser.js +7 -7
  3. package/dist/apidom-ns-openapi-2.browser.min.js +1 -1
  4. package/package.json +9 -8
  5. package/src/elements/Contact.ts +0 -42
  6. package/src/elements/Definitions.ts +0 -13
  7. package/src/elements/Example.ts +0 -13
  8. package/src/elements/ExternalDocumentation.ts +0 -34
  9. package/src/elements/Header.ts +0 -261
  10. package/src/elements/Headers.ts +0 -13
  11. package/src/elements/Info.ts +0 -70
  12. package/src/elements/Items.ts +0 -264
  13. package/src/elements/License.ts +0 -34
  14. package/src/elements/Operation.ts +0 -106
  15. package/src/elements/Parameter.ts +0 -326
  16. package/src/elements/ParametersDefinitions.ts +0 -13
  17. package/src/elements/PathItem.ts +0 -93
  18. package/src/elements/Paths.ts +0 -13
  19. package/src/elements/Reference.ts +0 -27
  20. package/src/elements/Response.ts +0 -54
  21. package/src/elements/Responses.ts +0 -24
  22. package/src/elements/ResponsesDefinitions.ts +0 -13
  23. package/src/elements/Schema.ts +0 -204
  24. package/src/elements/Scopes.ts +0 -13
  25. package/src/elements/SecurityDefinitions.ts +0 -13
  26. package/src/elements/SecurityRequirement.ts +0 -13
  27. package/src/elements/SecurityScheme.ts +0 -83
  28. package/src/elements/Swagger.ts +0 -149
  29. package/src/elements/SwaggerVersion.ts +0 -15
  30. package/src/elements/Tag.ts +0 -44
  31. package/src/elements/Xml.ts +0 -59
  32. package/src/elements/nces/OperationConsumes.ts +0 -15
  33. package/src/elements/nces/OperationParameters.ts +0 -16
  34. package/src/elements/nces/OperationProduces.ts +0 -15
  35. package/src/elements/nces/OperationSchemes.ts +0 -15
  36. package/src/elements/nces/OperationSecurity.ts +0 -16
  37. package/src/elements/nces/OperationTags.ts +0 -16
  38. package/src/elements/nces/PathItemParameters.ts +0 -16
  39. package/src/elements/nces/SwaggerConsumes.ts +0 -15
  40. package/src/elements/nces/SwaggerProduces.ts +0 -15
  41. package/src/elements/nces/SwaggerSchemes.ts +0 -15
  42. package/src/elements/nces/SwaggerSecurity.ts +0 -16
  43. package/src/elements/nces/SwaggerTags.ts +0 -15
  44. package/src/index.ts +0 -368
  45. package/src/media-types.ts +0 -42
  46. package/src/namespace.ts +0 -70
  47. package/src/predicates.ts +0 -194
  48. package/src/refractor/index.ts +0 -330
  49. package/src/refractor/inspect.ts +0 -181
  50. package/src/refractor/plugins/replace-empty-element.ts +0 -389
  51. package/src/refractor/predicates.ts +0 -29
  52. package/src/refractor/specification.ts +0 -444
  53. package/src/refractor/toolbox.ts +0 -24
  54. package/src/refractor/visitors/FallbackVisitor.ts +0 -25
  55. package/src/refractor/visitors/SpecificationExtensionVisitor.ts +0 -22
  56. package/src/refractor/visitors/SpecificationVisitor.ts +0 -83
  57. package/src/refractor/visitors/Visitor.ts +0 -47
  58. package/src/refractor/visitors/generics/AlternatingVisitor.ts +0 -45
  59. package/src/refractor/visitors/generics/FixedFieldsVisitor.ts +0 -109
  60. package/src/refractor/visitors/generics/MapVisitor.ts +0 -25
  61. package/src/refractor/visitors/generics/MixedFieldsVisitor.ts +0 -77
  62. package/src/refractor/visitors/generics/PatternedFieldsVisitor.ts +0 -99
  63. package/src/refractor/visitors/open-api-2/BasePathVisitor.ts +0 -20
  64. package/src/refractor/visitors/open-api-2/ConsumesVisitor.ts +0 -29
  65. package/src/refractor/visitors/open-api-2/HostVisitor.ts +0 -20
  66. package/src/refractor/visitors/open-api-2/ProducesVisitor.ts +0 -29
  67. package/src/refractor/visitors/open-api-2/SchemesVisitor.ts +0 -29
  68. package/src/refractor/visitors/open-api-2/SecurityVisitor.ts +0 -34
  69. package/src/refractor/visitors/open-api-2/SwaggerVisitor.ts +0 -29
  70. package/src/refractor/visitors/open-api-2/TagsVisitor.ts +0 -34
  71. package/src/refractor/visitors/open-api-2/bases.ts +0 -82
  72. package/src/refractor/visitors/open-api-2/contact/index.ts +0 -27
  73. package/src/refractor/visitors/open-api-2/definitions/index.ts +0 -48
  74. package/src/refractor/visitors/open-api-2/example/index.ts +0 -27
  75. package/src/refractor/visitors/open-api-2/external-documentation/index.ts +0 -27
  76. package/src/refractor/visitors/open-api-2/header/index.ts +0 -27
  77. package/src/refractor/visitors/open-api-2/headers/index.ts +0 -27
  78. package/src/refractor/visitors/open-api-2/index.ts +0 -28
  79. package/src/refractor/visitors/open-api-2/info/VersionVisitor.ts +0 -21
  80. package/src/refractor/visitors/open-api-2/info/index.ts +0 -27
  81. package/src/refractor/visitors/open-api-2/items/index.ts +0 -27
  82. package/src/refractor/visitors/open-api-2/license/index.ts +0 -27
  83. package/src/refractor/visitors/open-api-2/operation/ConsumesVisitor.ts +0 -29
  84. package/src/refractor/visitors/open-api-2/operation/ParametersVisitor.ts +0 -44
  85. package/src/refractor/visitors/open-api-2/operation/ProducesVisitor.ts +0 -29
  86. package/src/refractor/visitors/open-api-2/operation/SchemesVisitor.ts +0 -29
  87. package/src/refractor/visitors/open-api-2/operation/SecurityVisitor.ts +0 -34
  88. package/src/refractor/visitors/open-api-2/operation/TagsVisitor.ts +0 -29
  89. package/src/refractor/visitors/open-api-2/operation/index.ts +0 -24
  90. package/src/refractor/visitors/open-api-2/parameter/index.ts +0 -27
  91. package/src/refractor/visitors/open-api-2/parameters-definitions/index.ts +0 -24
  92. package/src/refractor/visitors/open-api-2/path-item/$RefVisitor.ts +0 -20
  93. package/src/refractor/visitors/open-api-2/path-item/ParametersVisitor.ts +0 -44
  94. package/src/refractor/visitors/open-api-2/path-item/index.ts +0 -48
  95. package/src/refractor/visitors/open-api-2/paths/index.ts +0 -48
  96. package/src/refractor/visitors/open-api-2/reference/$RefVisitor.ts +0 -20
  97. package/src/refractor/visitors/open-api-2/reference/index.ts +0 -38
  98. package/src/refractor/visitors/open-api-2/response/index.ts +0 -27
  99. package/src/refractor/visitors/open-api-2/responses/DefaultVisitor.ts +0 -36
  100. package/src/refractor/visitors/open-api-2/responses/index.ts +0 -64
  101. package/src/refractor/visitors/open-api-2/responses-definitions/index.ts +0 -24
  102. package/src/refractor/visitors/open-api-2/schema/AllOfVisitor.ts +0 -35
  103. package/src/refractor/visitors/open-api-2/schema/ItemsVisitor.ts +0 -38
  104. package/src/refractor/visitors/open-api-2/schema/PropertiesVisitor.ts +0 -35
  105. package/src/refractor/visitors/open-api-2/schema/SchemaOrJSONReferenceVisitor.ts +0 -37
  106. package/src/refractor/visitors/open-api-2/schema/index.ts +0 -27
  107. package/src/refractor/visitors/open-api-2/scopes/index.ts +0 -27
  108. package/src/refractor/visitors/open-api-2/security-definitions/index.ts +0 -24
  109. package/src/refractor/visitors/open-api-2/security-requirement/index.ts +0 -24
  110. package/src/refractor/visitors/open-api-2/security-scheme/index.ts +0 -27
  111. package/src/refractor/visitors/open-api-2/tag/index.ts +0 -27
  112. package/src/refractor/visitors/open-api-2/xml/index.ts +0 -27
@@ -1,444 +0,0 @@
1
- import { specificationObj as JSONSchemaDraft4Specification } from '@speclynx/apidom-ns-json-schema-draft-4';
2
-
3
- import FallbackVisitor from './visitors/FallbackVisitor.ts';
4
- import SwaggerVisitor from './visitors/open-api-2/index.ts';
5
- import SwaggerSwaggerVisitor from './visitors/open-api-2/SwaggerVisitor.ts';
6
- import SwaggerHostVisitor from './visitors/open-api-2/HostVisitor.ts';
7
- import SwaggerBasePathVisitor from './visitors/open-api-2/BasePathVisitor.ts';
8
- import SwaggerSchemesVisitor from './visitors/open-api-2/SchemesVisitor.ts';
9
- import SwaggerConsumesVisitor from './visitors/open-api-2/ConsumesVisitor.ts';
10
- import SwaggerProducesVisitor from './visitors/open-api-2/ProducesVisitor.ts';
11
- import SwaggerSecurityVisitor from './visitors/open-api-2/SecurityVisitor.ts';
12
- import SwaggerTagsVisitor from './visitors/open-api-2/TagsVisitor.ts';
13
- import InfoVisitor from './visitors/open-api-2/info/index.ts';
14
- import InfoVersionVisitor from './visitors/open-api-2/info/VersionVisitor.ts';
15
- import ContactVisitor from './visitors/open-api-2/contact/index.ts';
16
- import LicenseVisitor from './visitors/open-api-2/license/index.ts';
17
- import PathsVisitor from './visitors/open-api-2/paths/index.ts';
18
- import PathItemVisitor from './visitors/open-api-2/path-item/index.ts';
19
- import PathItem$RefVisitor from './visitors/open-api-2/path-item/$RefVisitor.ts';
20
- import PathItemParametersVisitor from './visitors/open-api-2/path-item/ParametersVisitor.ts';
21
- import OperationVisitor from './visitors/open-api-2/operation/index.ts';
22
- import OperationTagsVisitor from './visitors/open-api-2/operation/TagsVisitor.ts';
23
- import OperationConsumesVisitor from './visitors/open-api-2/operation/ConsumesVisitor.ts';
24
- import OperationProducesVisitor from './visitors/open-api-2/operation/ProducesVisitor.ts';
25
- import OperationParametersVisitor from './visitors/open-api-2/operation/ParametersVisitor.ts';
26
- import OperationSchemesVisitor from './visitors/open-api-2/operation/SchemesVisitor.ts';
27
- import OperationSecurityVisitor from './visitors/open-api-2/operation/SecurityVisitor.ts';
28
- import ExternalDocumentationElement from './visitors/open-api-2/external-documentation/index.ts';
29
- import ParameterVisitor from './visitors/open-api-2/parameter/index.ts';
30
- import ItemsVisitor from './visitors/open-api-2/items/index.ts';
31
- import ResponsesVisitor from './visitors/open-api-2/responses/index.ts';
32
- import ResponsesDefaultVisitor from './visitors/open-api-2/responses/DefaultVisitor.ts';
33
- import ResponseVisitor from './visitors/open-api-2/response/index.ts';
34
- import HeadersVisitor from './visitors/open-api-2/headers/index.ts';
35
- import ExampleVisitor from './visitors/open-api-2/example/index.ts';
36
- import HeaderVisitor from './visitors/open-api-2/header/index.ts';
37
- import TagVisitor from './visitors/open-api-2/tag/index.ts';
38
- import ReferenceVisitor from './visitors/open-api-2/reference/index.ts';
39
- import Reference$RefVisitor from './visitors/open-api-2/reference/$RefVisitor.ts';
40
- import SchemaVisitor from './visitors/open-api-2/schema/index.ts';
41
- import SchemaAllOfVisitor from './visitors/open-api-2/schema/AllOfVisitor.ts';
42
- import SchemaItemsVisitor from './visitors/open-api-2/schema/ItemsVisitor.ts';
43
- import SchemaPropertiesVisitor from './visitors/open-api-2/schema/PropertiesVisitor.ts';
44
- import SchemaOrJSONReferenceVisitor from './visitors/open-api-2/schema/SchemaOrJSONReferenceVisitor.ts';
45
- import XmlVisitor from './visitors/open-api-2/xml/index.ts';
46
- import DefinitionsVisitor from './visitors/open-api-2/definitions/index.ts';
47
- import ResponsesDefinitionsVisitor from './visitors/open-api-2/responses-definitions/index.ts';
48
- import ParametersDefinitionsVisitor from './visitors/open-api-2/parameters-definitions/index.ts';
49
- import SecurityDefinitionsVisitor from './visitors/open-api-2/security-definitions/index.ts';
50
- import SecuritySchemeVisitor from './visitors/open-api-2/security-scheme/index.ts';
51
- import ScopesVisitor from './visitors/open-api-2/scopes/index.ts';
52
- import SecurityRequirementVisitor from './visitors/open-api-2/security-requirement/index.ts';
53
- import SpecificationExtensionVisitor from './visitors/SpecificationExtensionVisitor.ts';
54
-
55
- /**
56
- * Specification object allows us to have complete control over visitors
57
- * when traversing the ApiDOM.
58
- * Specification also allows us to create amended refractors from
59
- * existing ones by manipulating it.
60
- *
61
- * Note: Specification object allows to use absolute internal JSON pointers.
62
- */
63
-
64
- const { fixedFields: jsonSchemaFixedFields } =
65
- JSONSchemaDraft4Specification.visitors.document.objects.JSONSchema;
66
-
67
- /**
68
- * @public
69
- */
70
- const specification = {
71
- visitors: {
72
- value: FallbackVisitor,
73
- document: {
74
- objects: {
75
- // JSON Schema Draft 4/5 specific visitors
76
- JSONReference: JSONSchemaDraft4Specification.visitors.document.objects.JSONReference,
77
- JSONSchema: {
78
- $ref: '#/visitors/document/objects/Schema',
79
- },
80
- // OpenAPI 2 specific visitors
81
- Swagger: {
82
- $visitor: SwaggerVisitor,
83
- element: 'swagger',
84
- fixedFields: {
85
- swagger: SwaggerSwaggerVisitor,
86
- info: {
87
- $ref: '#/visitors/document/objects/Info',
88
- },
89
- host: SwaggerHostVisitor,
90
- basePath: SwaggerBasePathVisitor,
91
- schemes: SwaggerSchemesVisitor,
92
- consumes: SwaggerConsumesVisitor,
93
- produces: SwaggerProducesVisitor,
94
- paths: {
95
- $ref: '#/visitors/document/objects/Paths',
96
- },
97
- definitions: {
98
- $ref: '#/visitors/document/objects/Definitions',
99
- },
100
- parameters: {
101
- $ref: '#/visitors/document/objects/ParametersDefinitions',
102
- },
103
- responses: {
104
- $ref: '#/visitors/document/objects/ResponsesDefinitions',
105
- },
106
- securityDefinitions: {
107
- $ref: '#/visitors/document/objects/SecurityDefinitions',
108
- },
109
- security: SwaggerSecurityVisitor,
110
- tags: SwaggerTagsVisitor,
111
- externalDocs: {
112
- $ref: '#/visitors/document/objects/ExternalDocumentation',
113
- },
114
- },
115
- },
116
- Info: {
117
- $visitor: InfoVisitor,
118
- element: 'info',
119
- fixedFields: {
120
- title: { $ref: '#/visitors/value' },
121
- description: { $ref: '#/visitors/value' },
122
- termsOfService: { $ref: '#/visitors/value' },
123
- contact: {
124
- $ref: '#/visitors/document/objects/Contact',
125
- },
126
- license: {
127
- $ref: '#/visitors/document/objects/License',
128
- },
129
- version: InfoVersionVisitor,
130
- },
131
- },
132
- Contact: {
133
- $visitor: ContactVisitor,
134
- element: 'contact',
135
- fixedFields: {
136
- name: { $ref: '#/visitors/value' },
137
- url: { $ref: '#/visitors/value' },
138
- email: { $ref: '#/visitors/value' },
139
- },
140
- },
141
- License: {
142
- $visitor: LicenseVisitor,
143
- element: 'license',
144
- fixedFields: {
145
- name: { $ref: '#/visitors/value' },
146
- url: { $ref: '#/visitors/value' },
147
- },
148
- },
149
- Paths: {
150
- $visitor: PathsVisitor,
151
- element: 'paths',
152
- },
153
- PathItem: {
154
- $visitor: PathItemVisitor,
155
- element: 'pathItem',
156
- fixedFields: {
157
- $ref: PathItem$RefVisitor,
158
- get: {
159
- $ref: '#/visitors/document/objects/Operation',
160
- },
161
- put: {
162
- $ref: '#/visitors/document/objects/Operation',
163
- },
164
- post: {
165
- $ref: '#/visitors/document/objects/Operation',
166
- },
167
- delete: {
168
- $ref: '#/visitors/document/objects/Operation',
169
- },
170
- options: {
171
- $ref: '#/visitors/document/objects/Operation',
172
- },
173
- head: {
174
- $ref: '#/visitors/document/objects/Operation',
175
- },
176
- patch: {
177
- $ref: '#/visitors/document/objects/Operation',
178
- },
179
- parameters: PathItemParametersVisitor,
180
- },
181
- },
182
- Operation: {
183
- $visitor: OperationVisitor,
184
- element: 'operation',
185
- fixedFields: {
186
- tags: OperationTagsVisitor,
187
- summary: { $ref: '#/visitors/value' },
188
- description: { $ref: '#/visitors/value' },
189
- externalDocs: {
190
- $ref: '#/visitors/document/objects/ExternalDocumentation',
191
- },
192
- operationId: { $ref: '#/visitors/value' },
193
- consumes: OperationConsumesVisitor,
194
- produces: OperationProducesVisitor,
195
- parameters: OperationParametersVisitor,
196
- responses: {
197
- $ref: '#/visitors/document/objects/Responses',
198
- },
199
- schemes: OperationSchemesVisitor,
200
- deprecated: { $ref: '#/visitors/value' },
201
- security: OperationSecurityVisitor,
202
- },
203
- },
204
- ExternalDocumentation: {
205
- $visitor: ExternalDocumentationElement,
206
- element: 'externalDocumentation',
207
- fixedFields: {
208
- description: { $ref: '#/visitors/value' },
209
- url: { $ref: '#/visitors/value' },
210
- },
211
- },
212
- Parameter: {
213
- $visitor: ParameterVisitor,
214
- element: 'parameter',
215
- fixedFields: {
216
- name: { $ref: '#/visitors/value' },
217
- in: { $ref: '#/visitors/value' },
218
- description: jsonSchemaFixedFields.description,
219
- required: jsonSchemaFixedFields.required,
220
- schema: SchemaOrJSONReferenceVisitor,
221
- type: jsonSchemaFixedFields.type,
222
- format: jsonSchemaFixedFields.format,
223
- items: {
224
- $visitor: ItemsVisitor,
225
- alias: 'itemsField',
226
- },
227
- collectionFormat: { $ref: '#/visitors/value' },
228
- default: jsonSchemaFixedFields.default,
229
- maximum: jsonSchemaFixedFields.maximum,
230
- exclusiveMaximum: jsonSchemaFixedFields.exclusiveMaximum,
231
- minimum: jsonSchemaFixedFields.minimum,
232
- exclusiveMinimum: jsonSchemaFixedFields.exclusiveMinimum,
233
- maxLength: jsonSchemaFixedFields.maxLength,
234
- minLength: jsonSchemaFixedFields.minLength,
235
- pattern: jsonSchemaFixedFields.pattern,
236
- maxItems: jsonSchemaFixedFields.maxItems,
237
- minItems: jsonSchemaFixedFields.minItems,
238
- uniqueItems: jsonSchemaFixedFields.uniqueItems,
239
- enum: jsonSchemaFixedFields.enum,
240
- multipleOf: jsonSchemaFixedFields.multipleOf,
241
- },
242
- },
243
- Items: {
244
- $visitor: ItemsVisitor,
245
- element: 'items',
246
- fixedFields: {
247
- type: jsonSchemaFixedFields.type,
248
- format: jsonSchemaFixedFields.format,
249
- items: {
250
- $visitor: ItemsVisitor,
251
- alias: 'itemsField',
252
- },
253
- collectionFormat: { $ref: '#/visitors/value' },
254
- default: jsonSchemaFixedFields.default,
255
- maximum: jsonSchemaFixedFields.maximum,
256
- exclusiveMaximum: jsonSchemaFixedFields.exclusiveMaximum,
257
- minimum: jsonSchemaFixedFields.minimum,
258
- exclusiveMinimum: jsonSchemaFixedFields.exclusiveMinimum,
259
- maxLength: jsonSchemaFixedFields.maxLength,
260
- minLength: jsonSchemaFixedFields.minLength,
261
- pattern: jsonSchemaFixedFields.pattern,
262
- maxItems: jsonSchemaFixedFields.maxItems,
263
- minItems: jsonSchemaFixedFields.minItems,
264
- uniqueItems: jsonSchemaFixedFields.uniqueItems,
265
- enum: jsonSchemaFixedFields.enum,
266
- multipleOf: jsonSchemaFixedFields.multipleOf,
267
- },
268
- },
269
- Responses: {
270
- $visitor: ResponsesVisitor,
271
- element: 'responses',
272
- fixedFields: {
273
- default: ResponsesDefaultVisitor,
274
- },
275
- },
276
- Response: {
277
- $visitor: ResponseVisitor,
278
- element: 'response',
279
- fixedFields: {
280
- description: { $ref: '#/visitors/value' },
281
- schema: SchemaOrJSONReferenceVisitor,
282
- headers: {
283
- $ref: '#/visitors/document/objects/Headers',
284
- },
285
- examples: {
286
- $ref: '#/visitors/document/objects/Example',
287
- },
288
- },
289
- },
290
- Headers: {
291
- $visitor: HeadersVisitor,
292
- element: 'headers',
293
- },
294
- Example: {
295
- $visitor: ExampleVisitor,
296
- element: 'example',
297
- },
298
- Header: {
299
- $visitor: HeaderVisitor,
300
- element: 'header',
301
- fixedFields: {
302
- description: jsonSchemaFixedFields.description,
303
- type: jsonSchemaFixedFields.type,
304
- format: jsonSchemaFixedFields.format,
305
- items: {
306
- $visitor: ItemsVisitor,
307
- alias: 'itemsField',
308
- },
309
- collectionFormat: { $ref: '#/visitors/value' },
310
- default: jsonSchemaFixedFields.default,
311
- maximum: jsonSchemaFixedFields.maximum,
312
- exclusiveMaximum: jsonSchemaFixedFields.exclusiveMaximum,
313
- minimum: jsonSchemaFixedFields.minimum,
314
- exclusiveMinimum: jsonSchemaFixedFields.exclusiveMinimum,
315
- maxLength: jsonSchemaFixedFields.maxLength,
316
- minLength: jsonSchemaFixedFields.minLength,
317
- pattern: jsonSchemaFixedFields.pattern,
318
- maxItems: jsonSchemaFixedFields.maxItems,
319
- minItems: jsonSchemaFixedFields.minItems,
320
- uniqueItems: jsonSchemaFixedFields.uniqueItems,
321
- enum: jsonSchemaFixedFields.enum,
322
- multipleOf: jsonSchemaFixedFields.multipleOf,
323
- },
324
- },
325
- Tag: {
326
- $visitor: TagVisitor,
327
- element: 'tag',
328
- fixedFields: {
329
- name: { $ref: '#/visitors/value' },
330
- description: { $ref: '#/visitors/value' },
331
- externalDocs: {
332
- $ref: '#/visitors/document/objects/ExternalDocumentation',
333
- },
334
- },
335
- },
336
- Reference: {
337
- $visitor: ReferenceVisitor,
338
- element: 'reference',
339
- fixedFields: {
340
- $ref: Reference$RefVisitor,
341
- },
342
- },
343
- Schema: {
344
- $visitor: SchemaVisitor,
345
- element: 'schema',
346
- fixedFields: {
347
- // the following properties are taken directly from the JSON Schema definition and follow the same specifications
348
- format: jsonSchemaFixedFields.format,
349
- title: jsonSchemaFixedFields.title,
350
- description: jsonSchemaFixedFields.description,
351
- default: jsonSchemaFixedFields.default,
352
- multipleOf: jsonSchemaFixedFields.multipleOf,
353
- maximum: jsonSchemaFixedFields.maximum,
354
- exclusiveMaximum: jsonSchemaFixedFields.exclusiveMaximum,
355
- minimum: jsonSchemaFixedFields.minimum,
356
- exclusiveMinimum: jsonSchemaFixedFields.exclusiveMinimum,
357
- maxLength: jsonSchemaFixedFields.maxLength,
358
- minLength: jsonSchemaFixedFields.minLength,
359
- pattern: jsonSchemaFixedFields.pattern,
360
- maxItems: jsonSchemaFixedFields.maxItems,
361
- minItems: jsonSchemaFixedFields.minItems,
362
- uniqueItems: jsonSchemaFixedFields.uniqueItems,
363
- maxProperties: jsonSchemaFixedFields.maxProperties,
364
- minProperties: jsonSchemaFixedFields.minProperties,
365
- required: jsonSchemaFixedFields.required,
366
- enum: jsonSchemaFixedFields.enum,
367
- type: jsonSchemaFixedFields.type,
368
- readOnly: jsonSchemaFixedFields.readOnly,
369
- // the following properties are taken from the JSON Schema definition but their definitions were adjusted to the Swagger Specification
370
- items: SchemaItemsVisitor,
371
- allOf: SchemaAllOfVisitor,
372
- properties: SchemaPropertiesVisitor,
373
- additionalProperties: SchemaOrJSONReferenceVisitor,
374
- // OpenAPI vocabulary
375
- discriminator: { $ref: '#/visitors/value' },
376
- xml: {
377
- $ref: '#/visitors/document/objects/XML',
378
- },
379
- externalDocs: {
380
- $ref: '#/visitors/document/objects/ExternalDocumentation',
381
- },
382
- example: { $ref: '#/visitors/value' },
383
- },
384
- },
385
- XML: {
386
- $visitor: XmlVisitor,
387
- element: 'xml',
388
- fixedFields: {
389
- name: { $ref: '#/visitors/value' },
390
- namespace: { $ref: '#/visitors/value' },
391
- prefix: { $ref: '#/visitors/value' },
392
- attribute: { $ref: '#/visitors/value' },
393
- wrapped: { $ref: '#/visitors/value' },
394
- },
395
- },
396
- Definitions: {
397
- $visitor: DefinitionsVisitor,
398
- element: 'definitions',
399
- },
400
- ParametersDefinitions: {
401
- $visitor: ParametersDefinitionsVisitor,
402
- element: 'parametersDefinitions',
403
- },
404
- ResponsesDefinitions: {
405
- $visitor: ResponsesDefinitionsVisitor,
406
- element: 'responsesDefinitions',
407
- },
408
- SecurityDefinitions: {
409
- $visitor: SecurityDefinitionsVisitor,
410
- element: 'securityDefinitions',
411
- },
412
- SecurityScheme: {
413
- $visitor: SecuritySchemeVisitor,
414
- element: 'securityScheme',
415
- fixedFields: {
416
- type: { $ref: '#/visitors/value' },
417
- description: { $ref: '#/visitors/value' },
418
- name: { $ref: '#/visitors/value' },
419
- in: { $ref: '#/visitors/value' },
420
- flow: { $ref: '#/visitors/value' },
421
- authorizationUrl: { $ref: '#/visitors/value' },
422
- token: { $ref: '#/visitors/value' },
423
- scopes: {
424
- $ref: '#/visitors/document/objects/Scopes',
425
- },
426
- },
427
- },
428
- Scopes: {
429
- $visitor: ScopesVisitor,
430
- element: 'scopes',
431
- },
432
- SecurityRequirement: {
433
- $visitor: SecurityRequirementVisitor,
434
- element: 'securityRequirement',
435
- },
436
- },
437
- extension: {
438
- $visitor: SpecificationExtensionVisitor,
439
- },
440
- },
441
- },
442
- };
443
-
444
- export default specification;
@@ -1,24 +0,0 @@
1
- import { isStringElement, Namespace } from '@speclynx/apidom-datamodel';
2
-
3
- import * as openApi2Predicates from '../predicates.ts';
4
- import * as refractorPredicates from './predicates.ts';
5
- import openApi2Namespace from '../namespace.ts';
6
-
7
- /**
8
- * @public
9
- */
10
- export interface Toolbox {
11
- predicates: Record<string, (...args: any[]) => boolean>;
12
- namespace: Namespace;
13
- }
14
-
15
- const createToolbox = (): Toolbox => {
16
- const namespace = new Namespace();
17
- const predicates = { ...refractorPredicates, ...openApi2Predicates, isStringElement };
18
-
19
- namespace.use(openApi2Namespace);
20
-
21
- return { predicates, namespace };
22
- };
23
-
24
- export default createToolbox;
@@ -1,25 +0,0 @@
1
- import { Element, cloneDeep } from '@speclynx/apidom-datamodel';
2
- import { Path } from '@speclynx/apidom-traverse';
3
-
4
- import Visitor, { VisitorOptions } from './Visitor.ts';
5
-
6
- /**
7
- * This visitor is responsible for falling back to current traversed element
8
- * Given OpenApi3_0Visitor expects ObjectElement to be traversed. If
9
- * different Element is provided FallBackVisitor is responsible to assigning
10
- * this Element as current element.
11
- */
12
-
13
- export type { VisitorOptions as FallbackVisitorOptions };
14
-
15
- /**
16
- * @public
17
- */
18
- class FallbackVisitor extends Visitor {
19
- enter(path: Path<Element>) {
20
- this.element = this.consume ? path.node : cloneDeep(path.node);
21
- path.stop();
22
- }
23
- }
24
-
25
- export default FallbackVisitor;
@@ -1,22 +0,0 @@
1
- import { MemberElement, cloneDeep } from '@speclynx/apidom-datamodel';
2
- import { Path } from '@speclynx/apidom-traverse';
3
-
4
- import SpecificationVisitor, { SpecificationVisitorOptions } from './SpecificationVisitor.ts';
5
-
6
- export type { SpecificationVisitorOptions as SpecificationExtensionVisitorOptions };
7
-
8
- /**
9
- * @public
10
- */
11
- class SpecificationExtensionVisitor extends SpecificationVisitor {
12
- declare public element: MemberElement;
13
-
14
- MemberElement(path: Path<MemberElement>) {
15
- this.element = cloneDeep(path.node);
16
- this.element.classes.push('specification-extension');
17
-
18
- path.stop();
19
- }
20
- }
21
-
22
- export default SpecificationExtensionVisitor;
@@ -1,83 +0,0 @@
1
- import { pathSatisfies, path, pick } from 'ramda';
2
- import { isFunction } from 'ramda-adjunct';
3
- import { cloneDeep } from '@speclynx/apidom-datamodel';
4
- import { traverse } from '@speclynx/apidom-traverse';
5
-
6
- import Visitor, { VisitorOptions } from './Visitor.ts';
7
- import FallbackVisitor from './FallbackVisitor.ts';
8
- import type specification from '../specification.ts';
9
-
10
- /**
11
- * This is a base Type for every visitor that does
12
- * internal look-ups to retrieve other child visitors.
13
- * @public
14
- */
15
- export interface SpecificationVisitorOptions extends VisitorOptions {
16
- readonly specObj: typeof specification;
17
- }
18
-
19
- /**
20
- * @public
21
- */
22
- class SpecificationVisitor extends Visitor {
23
- protected readonly specObj: typeof specification;
24
-
25
- protected readonly passingOptionsNames = ['specObj', 'consume'];
26
-
27
- constructor({ specObj, ...rest }: SpecificationVisitorOptions) {
28
- super({ ...rest });
29
- this.specObj = specObj;
30
- }
31
-
32
- retrievePassingOptions() {
33
- return pick(this.passingOptionsNames as (keyof this)[], this) as unknown as Record<
34
- string,
35
- unknown
36
- >;
37
- }
38
-
39
- retrieveFixedFields(specPath: string[]) {
40
- const fixedFields = path(['visitors', ...specPath, 'fixedFields'], this.specObj);
41
- if (typeof fixedFields === 'object' && fixedFields !== null) {
42
- return Object.keys(fixedFields);
43
- }
44
- return [];
45
- }
46
-
47
- retrieveVisitor(specPath: string[]) {
48
- if (pathSatisfies(isFunction, ['visitors', ...specPath], this.specObj)) {
49
- return path(['visitors', ...specPath], this.specObj);
50
- }
51
-
52
- return path(['visitors', ...specPath, '$visitor'], this.specObj);
53
- }
54
-
55
- retrieveVisitorInstance(specPath: string[], options = {}): Visitor {
56
- const passingOpts = this.retrievePassingOptions();
57
- const VisitorClz = this.retrieveVisitor(specPath) as typeof Visitor;
58
- const visitorOpts = { ...passingOpts, ...options };
59
-
60
- return new VisitorClz(visitorOpts);
61
- }
62
-
63
- toRefractedElement(specPath: string[], element: any, options = {}) {
64
- /**
65
- * This is `Visitor shortcut`: mechanism for short circuiting the traversal and replacing
66
- * it by basic node cloning.
67
- *
68
- * Visiting the element is equivalent to cloning it if the prototype of a visitor
69
- * is the same as the prototype of FallbackVisitor. If that's the case, we can avoid
70
- * bootstrapping the traversal cycle for fields that don't require any special visiting.
71
- */
72
- const visitor = this.retrieveVisitorInstance(specPath, options);
73
-
74
- if (visitor instanceof FallbackVisitor && visitor?.constructor === FallbackVisitor) {
75
- return this.consume ? element : cloneDeep(element);
76
- }
77
-
78
- traverse(element, visitor);
79
- return visitor.element;
80
- }
81
- }
82
-
83
- export default SpecificationVisitor;
@@ -1,47 +0,0 @@
1
- import { deepmerge } from '@speclynx/apidom-core';
2
- import {
3
- Element,
4
- ObjectElement,
5
- SourceMapElement,
6
- StyleElement,
7
- cloneDeep,
8
- } from '@speclynx/apidom-datamodel';
9
-
10
- /**
11
- * @public
12
- */
13
- export interface VisitorOptions {
14
- readonly consume?: boolean;
15
- }
16
-
17
- /**
18
- * @public
19
- */
20
- class Visitor {
21
- public element!: Element;
22
-
23
- protected readonly consume: boolean = false;
24
-
25
- protected consumeSafe: boolean = false;
26
-
27
- constructor(options: VisitorOptions = {}) {
28
- Object.assign(this, options);
29
- }
30
-
31
- public copyMetaAndAttributes(from: Element, to: Element) {
32
- if (!from.isMetaEmpty && !to.isMetaEmpty) {
33
- to.meta = to.meta.merge(from.meta);
34
- } else if (!from.isMetaEmpty) {
35
- to.meta = from.meta.cloneDeep();
36
- }
37
- if (!from.isAttributesEmpty && !to.isAttributesEmpty) {
38
- to.attributes = deepmerge(to.attributes, from.attributes) as ObjectElement;
39
- } else if (!from.isAttributesEmpty) {
40
- to.attributes = cloneDeep(from.attributes);
41
- }
42
- SourceMapElement.transfer(from, to);
43
- StyleElement.transfer(from, to);
44
- }
45
- }
46
-
47
- export default Visitor;