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