@speclynx/apidom-ns-openapi-3-0 4.0.1 → 4.0.3
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 +10 -0
- package/package.json +8 -9
- package/src/elements/Callback.cjs +15 -0
- package/src/elements/Callback.mjs +12 -0
- package/src/elements/Callback.ts +13 -0
- package/src/elements/Components.cjs +69 -0
- package/src/elements/Components.mjs +66 -0
- package/src/elements/Components.ts +85 -0
- package/src/elements/Contact.cjs +33 -0
- package/src/elements/Contact.mjs +30 -0
- package/src/elements/Contact.ts +42 -0
- package/src/elements/Discriminator.cjs +27 -0
- package/src/elements/Discriminator.mjs +24 -0
- package/src/elements/Discriminator.ts +34 -0
- package/src/elements/Encoding.cjs +45 -0
- package/src/elements/Encoding.mjs +42 -0
- package/src/elements/Encoding.ts +59 -0
- package/src/elements/Example.cjs +39 -0
- package/src/elements/Example.mjs +36 -0
- package/src/elements/Example.ts +51 -0
- package/src/elements/ExternalDocumentation.cjs +27 -0
- package/src/elements/ExternalDocumentation.mjs +24 -0
- package/src/elements/ExternalDocumentation.ts +34 -0
- package/src/elements/Header.cjs +90 -0
- package/src/elements/Header.mjs +86 -0
- package/src/elements/Header.ts +119 -0
- package/src/elements/Info.cjs +52 -0
- package/src/elements/Info.mjs +48 -0
- package/src/elements/Info.ts +70 -0
- package/src/elements/License.cjs +27 -0
- package/src/elements/License.mjs +24 -0
- package/src/elements/License.ts +34 -0
- package/src/elements/Link.cjs +63 -0
- package/src/elements/Link.mjs +59 -0
- package/src/elements/Link.ts +85 -0
- package/src/elements/MediaType.cjs +39 -0
- package/src/elements/MediaType.mjs +35 -0
- package/src/elements/MediaType.ts +48 -0
- package/src/elements/OAuthFlow.cjs +39 -0
- package/src/elements/OAuthFlow.mjs +36 -0
- package/src/elements/OAuthFlow.ts +50 -0
- package/src/elements/OAuthFlows.cjs +39 -0
- package/src/elements/OAuthFlows.mjs +35 -0
- package/src/elements/OAuthFlows.ts +47 -0
- package/src/elements/OpenApi3-0.cjs +65 -0
- package/src/elements/OpenApi3-0.mjs +61 -0
- package/src/elements/OpenApi3-0.ts +90 -0
- package/src/elements/Openapi.cjs +17 -0
- package/src/elements/Openapi.mjs +14 -0
- package/src/elements/Openapi.ts +15 -0
- package/src/elements/Operation.cjs +90 -0
- package/src/elements/Operation.mjs +86 -0
- package/src/elements/Operation.ts +124 -0
- package/src/elements/Parameter.cjs +102 -0
- package/src/elements/Parameter.mjs +98 -0
- package/src/elements/Parameter.ts +135 -0
- package/src/elements/PathItem.cjs +93 -0
- package/src/elements/PathItem.mjs +89 -0
- package/src/elements/PathItem.ts +125 -0
- package/src/elements/Paths.cjs +15 -0
- package/src/elements/Paths.mjs +12 -0
- package/src/elements/Paths.ts +13 -0
- package/src/elements/Reference.cjs +22 -0
- package/src/elements/Reference.mjs +19 -0
- package/src/elements/Reference.ts +27 -0
- package/src/elements/RequestBody.cjs +36 -0
- package/src/elements/RequestBody.mjs +33 -0
- package/src/elements/RequestBody.ts +46 -0
- package/src/elements/Response.cjs +39 -0
- package/src/elements/Response.mjs +36 -0
- package/src/elements/Response.ts +50 -0
- package/src/elements/Responses.cjs +21 -0
- package/src/elements/Responses.mjs +17 -0
- package/src/elements/Responses.ts +24 -0
- package/src/elements/Schema.cjs +170 -0
- package/src/elements/Schema.mjs +166 -0
- package/src/elements/Schema.ts +230 -0
- package/src/elements/SecurityRequirement.cjs +15 -0
- package/src/elements/SecurityRequirement.mjs +12 -0
- package/src/elements/SecurityRequirement.ts +13 -0
- package/src/elements/SecurityScheme.cjs +63 -0
- package/src/elements/SecurityScheme.mjs +59 -0
- package/src/elements/SecurityScheme.ts +84 -0
- package/src/elements/Server.cjs +33 -0
- package/src/elements/Server.mjs +30 -0
- package/src/elements/Server.ts +42 -0
- package/src/elements/ServerVariable.cjs +33 -0
- package/src/elements/ServerVariable.mjs +30 -0
- package/src/elements/ServerVariable.ts +43 -0
- package/src/elements/Tag.cjs +33 -0
- package/src/elements/Tag.mjs +29 -0
- package/src/elements/Tag.ts +44 -0
- package/src/elements/Xml.cjs +45 -0
- package/src/elements/Xml.mjs +42 -0
- package/src/elements/Xml.ts +59 -0
- package/src/elements/nces/ComponentsCallbacks.cjs +16 -0
- package/src/elements/nces/ComponentsCallbacks.mjs +13 -0
- package/src/elements/nces/ComponentsCallbacks.ts +15 -0
- package/src/elements/nces/ComponentsExamples.cjs +17 -0
- package/src/elements/nces/ComponentsExamples.mjs +14 -0
- package/src/elements/nces/ComponentsExamples.ts +16 -0
- package/src/elements/nces/ComponentsHeaders.cjs +16 -0
- package/src/elements/nces/ComponentsHeaders.mjs +13 -0
- package/src/elements/nces/ComponentsHeaders.ts +15 -0
- package/src/elements/nces/ComponentsLinks.cjs +16 -0
- package/src/elements/nces/ComponentsLinks.mjs +13 -0
- package/src/elements/nces/ComponentsLinks.ts +15 -0
- package/src/elements/nces/ComponentsParameters.cjs +17 -0
- package/src/elements/nces/ComponentsParameters.mjs +14 -0
- package/src/elements/nces/ComponentsParameters.ts +16 -0
- package/src/elements/nces/ComponentsRequestBodies.cjs +16 -0
- package/src/elements/nces/ComponentsRequestBodies.mjs +13 -0
- package/src/elements/nces/ComponentsRequestBodies.ts +15 -0
- package/src/elements/nces/ComponentsResponses.cjs +16 -0
- package/src/elements/nces/ComponentsResponses.mjs +13 -0
- package/src/elements/nces/ComponentsResponses.ts +15 -0
- package/src/elements/nces/ComponentsSchemas.cjs +16 -0
- package/src/elements/nces/ComponentsSchemas.mjs +13 -0
- package/src/elements/nces/ComponentsSchemas.ts +15 -0
- package/src/elements/nces/ComponentsSecuritySchemes.cjs +16 -0
- package/src/elements/nces/ComponentsSecuritySchemes.mjs +13 -0
- package/src/elements/nces/ComponentsSecuritySchemes.ts +15 -0
- package/src/elements/nces/DiscriminatorMapping.cjs +16 -0
- package/src/elements/nces/DiscriminatorMapping.mjs +13 -0
- package/src/elements/nces/DiscriminatorMapping.ts +15 -0
- package/src/elements/nces/EncodingHeaders.cjs +16 -0
- package/src/elements/nces/EncodingHeaders.mjs +13 -0
- package/src/elements/nces/EncodingHeaders.ts +15 -0
- package/src/elements/nces/HeaderContent.cjs +17 -0
- package/src/elements/nces/HeaderContent.mjs +14 -0
- package/src/elements/nces/HeaderContent.ts +16 -0
- package/src/elements/nces/HeaderExamples.cjs +17 -0
- package/src/elements/nces/HeaderExamples.mjs +14 -0
- package/src/elements/nces/HeaderExamples.ts +16 -0
- package/src/elements/nces/LinkParameters.cjs +16 -0
- package/src/elements/nces/LinkParameters.mjs +13 -0
- package/src/elements/nces/LinkParameters.ts +15 -0
- package/src/elements/nces/MediaTypeEncoding.cjs +16 -0
- package/src/elements/nces/MediaTypeEncoding.mjs +13 -0
- package/src/elements/nces/MediaTypeEncoding.ts +15 -0
- package/src/elements/nces/MediaTypeExamples.cjs +17 -0
- package/src/elements/nces/MediaTypeExamples.mjs +14 -0
- package/src/elements/nces/MediaTypeExamples.ts +16 -0
- package/src/elements/nces/OAuthFlowScopes.cjs +16 -0
- package/src/elements/nces/OAuthFlowScopes.mjs +13 -0
- package/src/elements/nces/OAuthFlowScopes.ts +15 -0
- package/src/elements/nces/OperationCallbacks.cjs +16 -0
- package/src/elements/nces/OperationCallbacks.mjs +13 -0
- package/src/elements/nces/OperationCallbacks.ts +15 -0
- package/src/elements/nces/OperationParameters.cjs +17 -0
- package/src/elements/nces/OperationParameters.mjs +14 -0
- package/src/elements/nces/OperationParameters.ts +16 -0
- package/src/elements/nces/OperationSecurity.cjs +17 -0
- package/src/elements/nces/OperationSecurity.mjs +14 -0
- package/src/elements/nces/OperationSecurity.ts +16 -0
- package/src/elements/nces/OperationServers.cjs +17 -0
- package/src/elements/nces/OperationServers.mjs +14 -0
- package/src/elements/nces/OperationServers.ts +16 -0
- package/src/elements/nces/OperationTags.cjs +16 -0
- package/src/elements/nces/OperationTags.mjs +13 -0
- package/src/elements/nces/OperationTags.ts +15 -0
- package/src/elements/nces/ParameterContent.cjs +17 -0
- package/src/elements/nces/ParameterContent.mjs +14 -0
- package/src/elements/nces/ParameterContent.ts +16 -0
- package/src/elements/nces/ParameterExamples.cjs +17 -0
- package/src/elements/nces/ParameterExamples.mjs +14 -0
- package/src/elements/nces/ParameterExamples.ts +16 -0
- package/src/elements/nces/PathItemParameters.cjs +17 -0
- package/src/elements/nces/PathItemParameters.mjs +14 -0
- package/src/elements/nces/PathItemParameters.ts +16 -0
- package/src/elements/nces/PathItemServers.cjs +17 -0
- package/src/elements/nces/PathItemServers.mjs +14 -0
- package/src/elements/nces/PathItemServers.ts +16 -0
- package/src/elements/nces/RequestBodyContent.cjs +17 -0
- package/src/elements/nces/RequestBodyContent.mjs +14 -0
- package/src/elements/nces/RequestBodyContent.ts +16 -0
- package/src/elements/nces/ResponseContent.cjs +17 -0
- package/src/elements/nces/ResponseContent.mjs +14 -0
- package/src/elements/nces/ResponseContent.ts +16 -0
- package/src/elements/nces/ResponseHeaders.cjs +16 -0
- package/src/elements/nces/ResponseHeaders.mjs +13 -0
- package/src/elements/nces/ResponseHeaders.ts +15 -0
- package/src/elements/nces/ResponseLinks.cjs +16 -0
- package/src/elements/nces/ResponseLinks.mjs +13 -0
- package/src/elements/nces/ResponseLinks.ts +15 -0
- package/src/elements/nces/Security.cjs +16 -0
- package/src/elements/nces/Security.mjs +13 -0
- package/src/elements/nces/Security.ts +15 -0
- package/src/elements/nces/ServerVariables.cjs +16 -0
- package/src/elements/nces/ServerVariables.mjs +13 -0
- package/src/elements/nces/ServerVariables.ts +15 -0
- package/src/elements/nces/Servers.cjs +16 -0
- package/src/elements/nces/Servers.mjs +13 -0
- package/src/elements/nces/Servers.ts +15 -0
- package/src/elements/nces/Tags.cjs +16 -0
- package/src/elements/nces/Tags.mjs +13 -0
- package/src/elements/nces/Tags.ts +15 -0
- package/src/index.cjs +205 -0
- package/src/index.mjs +54 -0
- package/src/index.ts +550 -0
- package/src/media-types.cjs +34 -0
- package/src/media-types.mjs +30 -0
- package/src/media-types.ts +52 -0
- package/src/namespace.cjs +79 -0
- package/src/namespace.mjs +74 -0
- package/src/namespace.ts +78 -0
- package/src/predicates.cjs +188 -0
- package/src/predicates.mjs +155 -0
- package/src/predicates.ts +185 -0
- package/src/refractor/index.cjs +358 -0
- package/src/refractor/index.mjs +321 -0
- package/src/refractor/index.ts +370 -0
- package/src/refractor/inspect.cjs +205 -0
- package/src/refractor/inspect.mjs +170 -0
- package/src/refractor/inspect.ts +239 -0
- package/src/refractor/plugins/replace-empty-element.cjs +633 -0
- package/src/refractor/plugins/replace-empty-element.mjs +625 -0
- package/src/refractor/plugins/replace-empty-element.ts +656 -0
- package/src/refractor/predicates.cjs +36 -0
- package/src/refractor/predicates.mjs +31 -0
- package/src/refractor/predicates.ts +39 -0
- package/src/refractor/specification.cjs +700 -0
- package/src/refractor/specification.mjs +695 -0
- package/src/refractor/specification.ts +557 -0
- package/src/refractor/toolbox.cjs +28 -0
- package/src/refractor/toolbox.mjs +21 -0
- package/src/refractor/toolbox.ts +24 -0
- package/src/refractor/visitors/FallbackVisitor.cjs +24 -0
- package/src/refractor/visitors/FallbackVisitor.mjs +18 -0
- package/src/refractor/visitors/FallbackVisitor.ts +24 -0
- package/src/refractor/visitors/SpecificationExtensionVisitor.cjs +18 -0
- package/src/refractor/visitors/SpecificationExtensionVisitor.mjs +13 -0
- package/src/refractor/visitors/SpecificationExtensionVisitor.ts +22 -0
- package/src/refractor/visitors/SpecificationVisitor.cjs +88 -0
- package/src/refractor/visitors/SpecificationVisitor.mjs +82 -0
- package/src/refractor/visitors/SpecificationVisitor.ts +112 -0
- package/src/refractor/visitors/Visitor.cjs +36 -0
- package/src/refractor/visitors/Visitor.mjs +33 -0
- package/src/refractor/visitors/Visitor.ts +47 -0
- package/src/refractor/visitors/generics/AlternatingVisitor.cjs +42 -0
- package/src/refractor/visitors/generics/AlternatingVisitor.mjs +35 -0
- package/src/refractor/visitors/generics/AlternatingVisitor.ts +45 -0
- package/src/refractor/visitors/generics/FixedFieldsVisitor.cjs +75 -0
- package/src/refractor/visitors/generics/FixedFieldsVisitor.mjs +68 -0
- package/src/refractor/visitors/generics/FixedFieldsVisitor.ts +110 -0
- package/src/refractor/visitors/generics/MapVisitor.cjs +21 -0
- package/src/refractor/visitors/generics/MapVisitor.mjs +15 -0
- package/src/refractor/visitors/generics/MapVisitor.ts +25 -0
- package/src/refractor/visitors/generics/MixedFieldsVisitor.cjs +67 -0
- package/src/refractor/visitors/generics/MixedFieldsVisitor.mjs +61 -0
- package/src/refractor/visitors/generics/MixedFieldsVisitor.ts +77 -0
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.cjs +72 -0
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.mjs +66 -0
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.ts +99 -0
- package/src/refractor/visitors/open-api-3-0/ContentVisitor.cjs +23 -0
- package/src/refractor/visitors/open-api-3-0/ContentVisitor.mjs +18 -0
- package/src/refractor/visitors/open-api-3-0/ContentVisitor.ts +28 -0
- package/src/refractor/visitors/open-api-3-0/ExamplesVisitor.cjs +33 -0
- package/src/refractor/visitors/open-api-3-0/ExamplesVisitor.mjs +28 -0
- package/src/refractor/visitors/open-api-3-0/ExamplesVisitor.ts +48 -0
- package/src/refractor/visitors/open-api-3-0/OpenapiVisitor.cjs +25 -0
- package/src/refractor/visitors/open-api-3-0/OpenapiVisitor.mjs +19 -0
- package/src/refractor/visitors/open-api-3-0/OpenapiVisitor.ts +30 -0
- package/src/refractor/visitors/open-api-3-0/ParametersVisitor.cjs +36 -0
- package/src/refractor/visitors/open-api-3-0/ParametersVisitor.mjs +31 -0
- package/src/refractor/visitors/open-api-3-0/ParametersVisitor.ts +47 -0
- package/src/refractor/visitors/open-api-3-0/SecurityVisitor.cjs +35 -0
- package/src/refractor/visitors/open-api-3-0/SecurityVisitor.mjs +29 -0
- package/src/refractor/visitors/open-api-3-0/SecurityVisitor.ts +44 -0
- package/src/refractor/visitors/open-api-3-0/ServersVisitor.cjs +32 -0
- package/src/refractor/visitors/open-api-3-0/ServersVisitor.mjs +26 -0
- package/src/refractor/visitors/open-api-3-0/ServersVisitor.ts +40 -0
- package/src/refractor/visitors/open-api-3-0/TagsVisitor.cjs +32 -0
- package/src/refractor/visitors/open-api-3-0/TagsVisitor.mjs +26 -0
- package/src/refractor/visitors/open-api-3-0/TagsVisitor.ts +40 -0
- package/src/refractor/visitors/open-api-3-0/bases.cjs +72 -0
- package/src/refractor/visitors/open-api-3-0/bases.mjs +67 -0
- package/src/refractor/visitors/open-api-3-0/bases.ts +82 -0
- package/src/refractor/visitors/open-api-3-0/callback/index.cjs +38 -0
- package/src/refractor/visitors/open-api-3-0/callback/index.mjs +32 -0
- package/src/refractor/visitors/open-api-3-0/callback/index.ts +49 -0
- package/src/refractor/visitors/open-api-3-0/components/CallbacksVisitor.cjs +33 -0
- package/src/refractor/visitors/open-api-3-0/components/CallbacksVisitor.mjs +27 -0
- package/src/refractor/visitors/open-api-3-0/components/CallbacksVisitor.ts +45 -0
- package/src/refractor/visitors/open-api-3-0/components/ExamplesVisitor.cjs +34 -0
- package/src/refractor/visitors/open-api-3-0/components/ExamplesVisitor.mjs +28 -0
- package/src/refractor/visitors/open-api-3-0/components/ExamplesVisitor.ts +46 -0
- package/src/refractor/visitors/open-api-3-0/components/HeadersVisitor.cjs +41 -0
- package/src/refractor/visitors/open-api-3-0/components/HeadersVisitor.mjs +35 -0
- package/src/refractor/visitors/open-api-3-0/components/HeadersVisitor.ts +53 -0
- package/src/refractor/visitors/open-api-3-0/components/LinksVisitor.cjs +33 -0
- package/src/refractor/visitors/open-api-3-0/components/LinksVisitor.mjs +27 -0
- package/src/refractor/visitors/open-api-3-0/components/LinksVisitor.ts +45 -0
- package/src/refractor/visitors/open-api-3-0/components/ParametersVisitor.cjs +34 -0
- package/src/refractor/visitors/open-api-3-0/components/ParametersVisitor.mjs +28 -0
- package/src/refractor/visitors/open-api-3-0/components/ParametersVisitor.ts +46 -0
- package/src/refractor/visitors/open-api-3-0/components/RequestBodiesVisitor.cjs +33 -0
- package/src/refractor/visitors/open-api-3-0/components/RequestBodiesVisitor.mjs +27 -0
- package/src/refractor/visitors/open-api-3-0/components/RequestBodiesVisitor.ts +45 -0
- package/src/refractor/visitors/open-api-3-0/components/ResponsesVisitor.cjs +41 -0
- package/src/refractor/visitors/open-api-3-0/components/ResponsesVisitor.mjs +35 -0
- package/src/refractor/visitors/open-api-3-0/components/ResponsesVisitor.ts +53 -0
- package/src/refractor/visitors/open-api-3-0/components/SchemasVisitor.cjs +34 -0
- package/src/refractor/visitors/open-api-3-0/components/SchemasVisitor.mjs +28 -0
- package/src/refractor/visitors/open-api-3-0/components/SchemasVisitor.ts +46 -0
- package/src/refractor/visitors/open-api-3-0/components/SecuritySchemesVisitor.cjs +33 -0
- package/src/refractor/visitors/open-api-3-0/components/SecuritySchemesVisitor.mjs +27 -0
- package/src/refractor/visitors/open-api-3-0/components/SecuritySchemesVisitor.ts +45 -0
- package/src/refractor/visitors/open-api-3-0/components/index.cjs +25 -0
- package/src/refractor/visitors/open-api-3-0/components/index.mjs +19 -0
- package/src/refractor/visitors/open-api-3-0/components/index.ts +31 -0
- package/src/refractor/visitors/open-api-3-0/contact/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/contact/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/contact/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/distriminator/MappingVisitor.cjs +19 -0
- package/src/refractor/visitors/open-api-3-0/distriminator/MappingVisitor.mjs +14 -0
- package/src/refractor/visitors/open-api-3-0/distriminator/MappingVisitor.ts +24 -0
- package/src/refractor/visitors/open-api-3-0/distriminator/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/distriminator/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/distriminator/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/encoding/HeadersVisitor.cjs +43 -0
- package/src/refractor/visitors/open-api-3-0/encoding/HeadersVisitor.mjs +37 -0
- package/src/refractor/visitors/open-api-3-0/encoding/HeadersVisitor.ts +57 -0
- package/src/refractor/visitors/open-api-3-0/encoding/index.cjs +40 -0
- package/src/refractor/visitors/open-api-3-0/encoding/index.mjs +34 -0
- package/src/refractor/visitors/open-api-3-0/encoding/index.ts +49 -0
- package/src/refractor/visitors/open-api-3-0/example/ExternalValueVisitor.cjs +16 -0
- package/src/refractor/visitors/open-api-3-0/example/ExternalValueVisitor.mjs +11 -0
- package/src/refractor/visitors/open-api-3-0/example/ExternalValueVisitor.ts +20 -0
- package/src/refractor/visitors/open-api-3-0/example/index.cjs +29 -0
- package/src/refractor/visitors/open-api-3-0/example/index.mjs +24 -0
- package/src/refractor/visitors/open-api-3-0/example/index.ts +38 -0
- package/src/refractor/visitors/open-api-3-0/external-documentation/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/external-documentation/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/external-documentation/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/header/ContentVisitor.cjs +17 -0
- package/src/refractor/visitors/open-api-3-0/header/ContentVisitor.mjs +12 -0
- package/src/refractor/visitors/open-api-3-0/header/ContentVisitor.ts +18 -0
- package/src/refractor/visitors/open-api-3-0/header/ExamplesVisitor.cjs +17 -0
- package/src/refractor/visitors/open-api-3-0/header/ExamplesVisitor.mjs +12 -0
- package/src/refractor/visitors/open-api-3-0/header/ExamplesVisitor.ts +18 -0
- package/src/refractor/visitors/open-api-3-0/header/SchemaVisitor.cjs +32 -0
- package/src/refractor/visitors/open-api-3-0/header/SchemaVisitor.mjs +27 -0
- package/src/refractor/visitors/open-api-3-0/header/SchemaVisitor.ts +33 -0
- package/src/refractor/visitors/open-api-3-0/header/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/header/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/header/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/index.cjs +29 -0
- package/src/refractor/visitors/open-api-3-0/index.mjs +23 -0
- package/src/refractor/visitors/open-api-3-0/index.ts +39 -0
- package/src/refractor/visitors/open-api-3-0/info/VersionVisitor.cjs +17 -0
- package/src/refractor/visitors/open-api-3-0/info/VersionVisitor.mjs +12 -0
- package/src/refractor/visitors/open-api-3-0/info/VersionVisitor.ts +21 -0
- package/src/refractor/visitors/open-api-3-0/info/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/info/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/info/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/license/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/license/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/license/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/link/OperationIdVisitor.cjs +16 -0
- package/src/refractor/visitors/open-api-3-0/link/OperationIdVisitor.mjs +11 -0
- package/src/refractor/visitors/open-api-3-0/link/OperationIdVisitor.ts +20 -0
- package/src/refractor/visitors/open-api-3-0/link/OperationRefVisitor.cjs +16 -0
- package/src/refractor/visitors/open-api-3-0/link/OperationRefVisitor.mjs +11 -0
- package/src/refractor/visitors/open-api-3-0/link/OperationRefVisitor.ts +20 -0
- package/src/refractor/visitors/open-api-3-0/link/ParametersVisitor.cjs +19 -0
- package/src/refractor/visitors/open-api-3-0/link/ParametersVisitor.mjs +14 -0
- package/src/refractor/visitors/open-api-3-0/link/ParametersVisitor.ts +24 -0
- package/src/refractor/visitors/open-api-3-0/link/index.cjs +29 -0
- package/src/refractor/visitors/open-api-3-0/link/index.mjs +24 -0
- package/src/refractor/visitors/open-api-3-0/link/index.ts +38 -0
- package/src/refractor/visitors/open-api-3-0/media-type/EncodingVisitor.cjs +19 -0
- package/src/refractor/visitors/open-api-3-0/media-type/EncodingVisitor.mjs +14 -0
- package/src/refractor/visitors/open-api-3-0/media-type/EncodingVisitor.ts +24 -0
- package/src/refractor/visitors/open-api-3-0/media-type/ExamplesVisitor.cjs +17 -0
- package/src/refractor/visitors/open-api-3-0/media-type/ExamplesVisitor.mjs +12 -0
- package/src/refractor/visitors/open-api-3-0/media-type/ExamplesVisitor.ts +18 -0
- package/src/refractor/visitors/open-api-3-0/media-type/SchemaVisitor.cjs +32 -0
- package/src/refractor/visitors/open-api-3-0/media-type/SchemaVisitor.mjs +27 -0
- package/src/refractor/visitors/open-api-3-0/media-type/SchemaVisitor.ts +33 -0
- package/src/refractor/visitors/open-api-3-0/media-type/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/media-type/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/media-type/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/oauth-flow/ScopesVisitor.cjs +19 -0
- package/src/refractor/visitors/open-api-3-0/oauth-flow/ScopesVisitor.mjs +14 -0
- package/src/refractor/visitors/open-api-3-0/oauth-flow/ScopesVisitor.ts +24 -0
- package/src/refractor/visitors/open-api-3-0/oauth-flow/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/oauth-flow/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/oauth-flow/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/oauth-flows/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/oauth-flows/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/oauth-flows/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/operation/CallbacksVisitor.cjs +34 -0
- package/src/refractor/visitors/open-api-3-0/operation/CallbacksVisitor.mjs +28 -0
- package/src/refractor/visitors/open-api-3-0/operation/CallbacksVisitor.ts +45 -0
- package/src/refractor/visitors/open-api-3-0/operation/ParametersVisitor.cjs +17 -0
- package/src/refractor/visitors/open-api-3-0/operation/ParametersVisitor.mjs +12 -0
- package/src/refractor/visitors/open-api-3-0/operation/ParametersVisitor.ts +18 -0
- package/src/refractor/visitors/open-api-3-0/operation/RequestBodyVisitor.cjs +35 -0
- package/src/refractor/visitors/open-api-3-0/operation/RequestBodyVisitor.mjs +29 -0
- package/src/refractor/visitors/open-api-3-0/operation/RequestBodyVisitor.ts +39 -0
- package/src/refractor/visitors/open-api-3-0/operation/SecurityVisitor.cjs +32 -0
- package/src/refractor/visitors/open-api-3-0/operation/SecurityVisitor.mjs +26 -0
- package/src/refractor/visitors/open-api-3-0/operation/SecurityVisitor.ts +41 -0
- package/src/refractor/visitors/open-api-3-0/operation/ServersVisitor.cjs +17 -0
- package/src/refractor/visitors/open-api-3-0/operation/ServersVisitor.mjs +12 -0
- package/src/refractor/visitors/open-api-3-0/operation/ServersVisitor.ts +18 -0
- package/src/refractor/visitors/open-api-3-0/operation/TagsVisitor.cjs +27 -0
- package/src/refractor/visitors/open-api-3-0/operation/TagsVisitor.mjs +21 -0
- package/src/refractor/visitors/open-api-3-0/operation/TagsVisitor.ts +32 -0
- package/src/refractor/visitors/open-api-3-0/operation/index.cjs +23 -0
- package/src/refractor/visitors/open-api-3-0/operation/index.mjs +17 -0
- package/src/refractor/visitors/open-api-3-0/operation/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/parameter/ContentVisitor.cjs +17 -0
- package/src/refractor/visitors/open-api-3-0/parameter/ContentVisitor.mjs +12 -0
- package/src/refractor/visitors/open-api-3-0/parameter/ContentVisitor.ts +18 -0
- package/src/refractor/visitors/open-api-3-0/parameter/ExamplesVisitor.cjs +17 -0
- package/src/refractor/visitors/open-api-3-0/parameter/ExamplesVisitor.mjs +12 -0
- package/src/refractor/visitors/open-api-3-0/parameter/ExamplesVisitor.ts +18 -0
- package/src/refractor/visitors/open-api-3-0/parameter/SchemaVisitor.cjs +36 -0
- package/src/refractor/visitors/open-api-3-0/parameter/SchemaVisitor.mjs +30 -0
- package/src/refractor/visitors/open-api-3-0/parameter/SchemaVisitor.ts +36 -0
- package/src/refractor/visitors/open-api-3-0/parameter/index.cjs +40 -0
- package/src/refractor/visitors/open-api-3-0/parameter/index.mjs +34 -0
- package/src/refractor/visitors/open-api-3-0/parameter/index.ts +49 -0
- package/src/refractor/visitors/open-api-3-0/path-item/$RefVisitor.cjs +16 -0
- package/src/refractor/visitors/open-api-3-0/path-item/$RefVisitor.mjs +11 -0
- package/src/refractor/visitors/open-api-3-0/path-item/$RefVisitor.ts +20 -0
- package/src/refractor/visitors/open-api-3-0/path-item/ParametersVisitor.cjs +17 -0
- package/src/refractor/visitors/open-api-3-0/path-item/ParametersVisitor.mjs +12 -0
- package/src/refractor/visitors/open-api-3-0/path-item/ParametersVisitor.ts +18 -0
- package/src/refractor/visitors/open-api-3-0/path-item/ServersVisitor.cjs +17 -0
- package/src/refractor/visitors/open-api-3-0/path-item/ServersVisitor.mjs +12 -0
- package/src/refractor/visitors/open-api-3-0/path-item/ServersVisitor.ts +18 -0
- package/src/refractor/visitors/open-api-3-0/path-item/index.cjs +42 -0
- package/src/refractor/visitors/open-api-3-0/path-item/index.mjs +36 -0
- package/src/refractor/visitors/open-api-3-0/path-item/index.ts +53 -0
- package/src/refractor/visitors/open-api-3-0/paths/index.cjs +40 -0
- package/src/refractor/visitors/open-api-3-0/paths/index.mjs +34 -0
- package/src/refractor/visitors/open-api-3-0/paths/index.ts +51 -0
- package/src/refractor/visitors/open-api-3-0/reference/$RefVisitor.cjs +16 -0
- package/src/refractor/visitors/open-api-3-0/reference/$RefVisitor.mjs +11 -0
- package/src/refractor/visitors/open-api-3-0/reference/$RefVisitor.ts +20 -0
- package/src/refractor/visitors/open-api-3-0/reference/index.cjs +33 -0
- package/src/refractor/visitors/open-api-3-0/reference/index.mjs +27 -0
- package/src/refractor/visitors/open-api-3-0/reference/index.ts +41 -0
- package/src/refractor/visitors/open-api-3-0/request-body/ContentVisitor.cjs +17 -0
- package/src/refractor/visitors/open-api-3-0/request-body/ContentVisitor.mjs +12 -0
- package/src/refractor/visitors/open-api-3-0/request-body/ContentVisitor.ts +18 -0
- package/src/refractor/visitors/open-api-3-0/request-body/index.cjs +39 -0
- package/src/refractor/visitors/open-api-3-0/request-body/index.mjs +33 -0
- package/src/refractor/visitors/open-api-3-0/request-body/index.ts +46 -0
- package/src/refractor/visitors/open-api-3-0/response/ContentVisitor.cjs +17 -0
- package/src/refractor/visitors/open-api-3-0/response/ContentVisitor.mjs +12 -0
- package/src/refractor/visitors/open-api-3-0/response/ContentVisitor.ts +18 -0
- package/src/refractor/visitors/open-api-3-0/response/HeadersVisitor.cjs +42 -0
- package/src/refractor/visitors/open-api-3-0/response/HeadersVisitor.mjs +36 -0
- package/src/refractor/visitors/open-api-3-0/response/HeadersVisitor.ts +57 -0
- package/src/refractor/visitors/open-api-3-0/response/LinksVisitor.cjs +32 -0
- package/src/refractor/visitors/open-api-3-0/response/LinksVisitor.mjs +26 -0
- package/src/refractor/visitors/open-api-3-0/response/LinksVisitor.ts +45 -0
- package/src/refractor/visitors/open-api-3-0/response/index.cjs +47 -0
- package/src/refractor/visitors/open-api-3-0/response/index.mjs +41 -0
- package/src/refractor/visitors/open-api-3-0/response/index.ts +57 -0
- package/src/refractor/visitors/open-api-3-0/responses/DefaultVisitor.cjs +40 -0
- package/src/refractor/visitors/open-api-3-0/responses/DefaultVisitor.mjs +34 -0
- package/src/refractor/visitors/open-api-3-0/responses/DefaultVisitor.ts +39 -0
- package/src/refractor/visitors/open-api-3-0/responses/index.cjs +46 -0
- package/src/refractor/visitors/open-api-3-0/responses/index.mjs +40 -0
- package/src/refractor/visitors/open-api-3-0/responses/index.ts +64 -0
- package/src/refractor/visitors/open-api-3-0/schema/AllOfVisitor.cjs +25 -0
- package/src/refractor/visitors/open-api-3-0/schema/AllOfVisitor.mjs +21 -0
- package/src/refractor/visitors/open-api-3-0/schema/AllOfVisitor.ts +34 -0
- package/src/refractor/visitors/open-api-3-0/schema/AnyOfVisitor.cjs +25 -0
- package/src/refractor/visitors/open-api-3-0/schema/AnyOfVisitor.mjs +21 -0
- package/src/refractor/visitors/open-api-3-0/schema/AnyOfVisitor.ts +34 -0
- package/src/refractor/visitors/open-api-3-0/schema/ItemsVisitor.cjs +22 -0
- package/src/refractor/visitors/open-api-3-0/schema/ItemsVisitor.mjs +19 -0
- package/src/refractor/visitors/open-api-3-0/schema/ItemsVisitor.ts +31 -0
- package/src/refractor/visitors/open-api-3-0/schema/OneOfVisitor.cjs +25 -0
- package/src/refractor/visitors/open-api-3-0/schema/OneOfVisitor.mjs +21 -0
- package/src/refractor/visitors/open-api-3-0/schema/OneOfVisitor.ts +34 -0
- package/src/refractor/visitors/open-api-3-0/schema/PropertiesVisitor.cjs +25 -0
- package/src/refractor/visitors/open-api-3-0/schema/PropertiesVisitor.mjs +21 -0
- package/src/refractor/visitors/open-api-3-0/schema/PropertiesVisitor.ts +34 -0
- package/src/refractor/visitors/open-api-3-0/schema/SchemaOrReferenceVisitor.cjs +23 -0
- package/src/refractor/visitors/open-api-3-0/schema/SchemaOrReferenceVisitor.mjs +19 -0
- package/src/refractor/visitors/open-api-3-0/schema/SchemaOrReferenceVisitor.ts +36 -0
- package/src/refractor/visitors/open-api-3-0/schema/TypeVisitor.cjs +19 -0
- package/src/refractor/visitors/open-api-3-0/schema/TypeVisitor.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/schema/TypeVisitor.ts +26 -0
- package/src/refractor/visitors/open-api-3-0/schema/index.cjs +24 -0
- package/src/refractor/visitors/open-api-3-0/schema/index.mjs +18 -0
- package/src/refractor/visitors/open-api-3-0/schema/index.ts +30 -0
- package/src/refractor/visitors/open-api-3-0/security-requirement/index.cjs +19 -0
- package/src/refractor/visitors/open-api-3-0/security-requirement/index.mjs +14 -0
- package/src/refractor/visitors/open-api-3-0/security-requirement/index.ts +24 -0
- package/src/refractor/visitors/open-api-3-0/security-scheme/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/security-scheme/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/security-scheme/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/server/UrlVisitor.cjs +16 -0
- package/src/refractor/visitors/open-api-3-0/server/UrlVisitor.mjs +11 -0
- package/src/refractor/visitors/open-api-3-0/server/UrlVisitor.ts +20 -0
- package/src/refractor/visitors/open-api-3-0/server/VariablesVisitor.cjs +19 -0
- package/src/refractor/visitors/open-api-3-0/server/VariablesVisitor.mjs +14 -0
- package/src/refractor/visitors/open-api-3-0/server/VariablesVisitor.ts +24 -0
- package/src/refractor/visitors/open-api-3-0/server/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/server/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/server/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/server-variable/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/server-variable/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/server-variable/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/tag/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/tag/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/tag/index.ts +27 -0
- package/src/refractor/visitors/open-api-3-0/xml/index.cjs +20 -0
- package/src/refractor/visitors/open-api-3-0/xml/index.mjs +15 -0
- package/src/refractor/visitors/open-api-3-0/xml/index.ts +27 -0
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
export type { VisitorOptions as FallbackVisitorOptions };
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class FallbackVisitor extends Visitor {
|
|
18
|
+
enter(path: Path<Element>) {
|
|
19
|
+
this.element = this.consume ? path.node : cloneDeep(path.node);
|
|
20
|
+
path.stop();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default FallbackVisitor;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
7
|
+
var _SpecificationVisitor = _interopRequireDefault(require("./SpecificationVisitor.cjs"));
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class SpecificationExtensionVisitor extends _SpecificationVisitor.default {
|
|
12
|
+
MemberElement(path) {
|
|
13
|
+
this.element = (0, _apidomDatamodel.cloneDeep)(path.node);
|
|
14
|
+
this.element.classes.push('specification-extension');
|
|
15
|
+
path.stop();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
var _default = exports.default = SpecificationExtensionVisitor;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cloneDeep } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import SpecificationVisitor from "./SpecificationVisitor.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
class SpecificationExtensionVisitor extends SpecificationVisitor {
|
|
7
|
+
MemberElement(path) {
|
|
8
|
+
this.element = cloneDeep(path.node);
|
|
9
|
+
this.element.classes.push('specification-extension');
|
|
10
|
+
path.stop();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export default SpecificationExtensionVisitor;
|
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
@@ -0,0 +1,88 @@
|
|
|
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 _ramda = require("ramda");
|
|
7
|
+
var _ramdaAdjunct = require("ramda-adjunct");
|
|
8
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
9
|
+
var _apidomTraverse = require("@speclynx/apidom-traverse");
|
|
10
|
+
var _Visitor = _interopRequireDefault(require("./Visitor.cjs"));
|
|
11
|
+
var _FallbackVisitor = _interopRequireDefault(require("./FallbackVisitor.cjs"));
|
|
12
|
+
/**
|
|
13
|
+
* This is a base Type for every visitor that does
|
|
14
|
+
* internal look-ups to retrieve other child visitors.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
class SpecificationVisitor extends _Visitor.default {
|
|
22
|
+
specObj;
|
|
23
|
+
passingOptionsNames = ['specObj', 'openApiGenericElement', 'sourceContext', 'openApiSemanticElement', 'consume'];
|
|
24
|
+
openApiGenericElement;
|
|
25
|
+
sourceContext;
|
|
26
|
+
openApiSemanticElement;
|
|
27
|
+
constructor({
|
|
28
|
+
specObj,
|
|
29
|
+
passingOptionsNames,
|
|
30
|
+
openApiGenericElement,
|
|
31
|
+
openApiSemanticElement,
|
|
32
|
+
...rest
|
|
33
|
+
}) {
|
|
34
|
+
super({
|
|
35
|
+
...rest
|
|
36
|
+
});
|
|
37
|
+
this.specObj = specObj;
|
|
38
|
+
this.openApiGenericElement = openApiGenericElement;
|
|
39
|
+
this.openApiSemanticElement = openApiSemanticElement;
|
|
40
|
+
if (Array.isArray(passingOptionsNames)) {
|
|
41
|
+
this.passingOptionsNames = passingOptionsNames;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
retrievePassingOptions() {
|
|
45
|
+
return (0, _ramda.pick)(this.passingOptionsNames, this);
|
|
46
|
+
}
|
|
47
|
+
retrieveFixedFields(specPath) {
|
|
48
|
+
const fixedFields = (0, _ramda.path)(['visitors', ...specPath, 'fixedFields'], this.specObj);
|
|
49
|
+
if (typeof fixedFields === 'object' && fixedFields !== null) {
|
|
50
|
+
return Object.keys(fixedFields);
|
|
51
|
+
}
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
retrieveVisitor(specPath) {
|
|
55
|
+
if ((0, _ramda.pathSatisfies)(_ramdaAdjunct.isFunction, ['visitors', ...specPath], this.specObj)) {
|
|
56
|
+
return (0, _ramda.path)(['visitors', ...specPath], this.specObj);
|
|
57
|
+
}
|
|
58
|
+
return (0, _ramda.path)(['visitors', ...specPath, '$visitor'], this.specObj);
|
|
59
|
+
}
|
|
60
|
+
retrieveVisitorInstance(specPath, options = {}) {
|
|
61
|
+
const passingOpts = this.retrievePassingOptions();
|
|
62
|
+
const VisitorClz = this.retrieveVisitor(specPath);
|
|
63
|
+
const visitorOpts = {
|
|
64
|
+
...passingOpts,
|
|
65
|
+
...options
|
|
66
|
+
};
|
|
67
|
+
return new VisitorClz(visitorOpts);
|
|
68
|
+
}
|
|
69
|
+
toRefractedElement(specPath, element, options = {}) {
|
|
70
|
+
/**
|
|
71
|
+
* This is `Visitor shortcut`: a mechanism for short-circuiting the traversal and replacing
|
|
72
|
+
* it by basic node cloning.
|
|
73
|
+
*
|
|
74
|
+
* Visiting the element is equivalent to cloning it if the prototype of a visitor
|
|
75
|
+
* is the same as the prototype of FallbackVisitor. If that's the case, we can avoid
|
|
76
|
+
* bootstrapping the traversal cycle for fields that don't require any special visiting.
|
|
77
|
+
*/
|
|
78
|
+
const visitor = this.retrieveVisitorInstance(specPath, options);
|
|
79
|
+
if (visitor instanceof _FallbackVisitor.default && visitor?.constructor === _FallbackVisitor.default) {
|
|
80
|
+
return this.consume ? element : (0, _apidomDatamodel.cloneDeep)(element);
|
|
81
|
+
}
|
|
82
|
+
(0, _apidomTraverse.traverse)(element, visitor, {
|
|
83
|
+
nodeTypeGetter: _apidomTraverse.getNodePrimitiveType
|
|
84
|
+
});
|
|
85
|
+
return visitor.element;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
var _default = exports.default = SpecificationVisitor;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { pathSatisfies, path, pick } from 'ramda';
|
|
2
|
+
import { isFunction } from 'ramda-adjunct';
|
|
3
|
+
import { cloneDeep } from '@speclynx/apidom-datamodel';
|
|
4
|
+
import { traverse, getNodePrimitiveType } from '@speclynx/apidom-traverse';
|
|
5
|
+
import Visitor from "./Visitor.mjs";
|
|
6
|
+
import FallbackVisitor from "./FallbackVisitor.mjs";
|
|
7
|
+
/**
|
|
8
|
+
* This is a base Type for every visitor that does
|
|
9
|
+
* internal look-ups to retrieve other child visitors.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
class SpecificationVisitor extends Visitor {
|
|
16
|
+
specObj;
|
|
17
|
+
passingOptionsNames = ['specObj', 'openApiGenericElement', 'sourceContext', 'openApiSemanticElement', 'consume'];
|
|
18
|
+
openApiGenericElement;
|
|
19
|
+
sourceContext;
|
|
20
|
+
openApiSemanticElement;
|
|
21
|
+
constructor({
|
|
22
|
+
specObj,
|
|
23
|
+
passingOptionsNames,
|
|
24
|
+
openApiGenericElement,
|
|
25
|
+
openApiSemanticElement,
|
|
26
|
+
...rest
|
|
27
|
+
}) {
|
|
28
|
+
super({
|
|
29
|
+
...rest
|
|
30
|
+
});
|
|
31
|
+
this.specObj = specObj;
|
|
32
|
+
this.openApiGenericElement = openApiGenericElement;
|
|
33
|
+
this.openApiSemanticElement = openApiSemanticElement;
|
|
34
|
+
if (Array.isArray(passingOptionsNames)) {
|
|
35
|
+
this.passingOptionsNames = passingOptionsNames;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
retrievePassingOptions() {
|
|
39
|
+
return pick(this.passingOptionsNames, this);
|
|
40
|
+
}
|
|
41
|
+
retrieveFixedFields(specPath) {
|
|
42
|
+
const fixedFields = path(['visitors', ...specPath, 'fixedFields'], this.specObj);
|
|
43
|
+
if (typeof fixedFields === 'object' && fixedFields !== null) {
|
|
44
|
+
return Object.keys(fixedFields);
|
|
45
|
+
}
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
retrieveVisitor(specPath) {
|
|
49
|
+
if (pathSatisfies(isFunction, ['visitors', ...specPath], this.specObj)) {
|
|
50
|
+
return path(['visitors', ...specPath], this.specObj);
|
|
51
|
+
}
|
|
52
|
+
return path(['visitors', ...specPath, '$visitor'], this.specObj);
|
|
53
|
+
}
|
|
54
|
+
retrieveVisitorInstance(specPath, options = {}) {
|
|
55
|
+
const passingOpts = this.retrievePassingOptions();
|
|
56
|
+
const VisitorClz = this.retrieveVisitor(specPath);
|
|
57
|
+
const visitorOpts = {
|
|
58
|
+
...passingOpts,
|
|
59
|
+
...options
|
|
60
|
+
};
|
|
61
|
+
return new VisitorClz(visitorOpts);
|
|
62
|
+
}
|
|
63
|
+
toRefractedElement(specPath, element, options = {}) {
|
|
64
|
+
/**
|
|
65
|
+
* This is `Visitor shortcut`: a 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
|
+
if (visitor instanceof FallbackVisitor && visitor?.constructor === FallbackVisitor) {
|
|
74
|
+
return this.consume ? element : cloneDeep(element);
|
|
75
|
+
}
|
|
76
|
+
traverse(element, visitor, {
|
|
77
|
+
nodeTypeGetter: getNodePrimitiveType
|
|
78
|
+
});
|
|
79
|
+
return visitor.element;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export default SpecificationVisitor;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { pathSatisfies, path, pick } from 'ramda';
|
|
2
|
+
import { isFunction } from 'ramda-adjunct';
|
|
3
|
+
import { ObjectElement, cloneDeep } from '@speclynx/apidom-datamodel';
|
|
4
|
+
import { traverse, getNodePrimitiveType } from '@speclynx/apidom-traverse';
|
|
5
|
+
|
|
6
|
+
import OpenApi3_0Element from '../../elements/OpenApi3-0.ts';
|
|
7
|
+
import Visitor, { VisitorOptions } from './Visitor.ts';
|
|
8
|
+
import type specification from '../specification.ts';
|
|
9
|
+
import FallbackVisitor from './FallbackVisitor.ts';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This is a base Type for every visitor that does
|
|
13
|
+
* internal look-ups to retrieve other child visitors.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface SpecificationVisitorOptions extends VisitorOptions {
|
|
17
|
+
readonly specObj: typeof specification;
|
|
18
|
+
readonly passingOptionsNames?: string[];
|
|
19
|
+
readonly openApiGenericElement?: ObjectElement;
|
|
20
|
+
readonly sourceContext?: Record<string, unknown>;
|
|
21
|
+
readonly openApiSemanticElement?: OpenApi3_0Element;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
class SpecificationVisitor extends Visitor {
|
|
28
|
+
protected readonly specObj: typeof specification;
|
|
29
|
+
|
|
30
|
+
protected readonly passingOptionsNames: string[] = [
|
|
31
|
+
'specObj',
|
|
32
|
+
'openApiGenericElement',
|
|
33
|
+
'sourceContext',
|
|
34
|
+
'openApiSemanticElement',
|
|
35
|
+
'consume',
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
protected openApiGenericElement?: ObjectElement;
|
|
39
|
+
|
|
40
|
+
protected sourceContext?: Record<string, unknown>;
|
|
41
|
+
|
|
42
|
+
protected openApiSemanticElement?: OpenApi3_0Element;
|
|
43
|
+
|
|
44
|
+
constructor({
|
|
45
|
+
specObj,
|
|
46
|
+
passingOptionsNames,
|
|
47
|
+
openApiGenericElement,
|
|
48
|
+
openApiSemanticElement,
|
|
49
|
+
...rest
|
|
50
|
+
}: SpecificationVisitorOptions) {
|
|
51
|
+
super({ ...rest });
|
|
52
|
+
this.specObj = specObj;
|
|
53
|
+
this.openApiGenericElement = openApiGenericElement;
|
|
54
|
+
this.openApiSemanticElement = openApiSemanticElement;
|
|
55
|
+
|
|
56
|
+
if (Array.isArray(passingOptionsNames)) {
|
|
57
|
+
this.passingOptionsNames = passingOptionsNames;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
retrievePassingOptions() {
|
|
62
|
+
return pick(this.passingOptionsNames as (keyof this)[], this) as unknown as Record<
|
|
63
|
+
string,
|
|
64
|
+
unknown
|
|
65
|
+
>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
retrieveFixedFields(specPath: string[]) {
|
|
69
|
+
const fixedFields = path(['visitors', ...specPath, 'fixedFields'], this.specObj);
|
|
70
|
+
if (typeof fixedFields === 'object' && fixedFields !== null) {
|
|
71
|
+
return Object.keys(fixedFields);
|
|
72
|
+
}
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
retrieveVisitor(specPath: string[]) {
|
|
77
|
+
if (pathSatisfies(isFunction, ['visitors', ...specPath], this.specObj)) {
|
|
78
|
+
return path(['visitors', ...specPath], this.specObj);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return path(['visitors', ...specPath, '$visitor'], this.specObj);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
retrieveVisitorInstance(specPath: string[], options = {}): Visitor {
|
|
85
|
+
const passingOpts = this.retrievePassingOptions();
|
|
86
|
+
const VisitorClz = this.retrieveVisitor(specPath) as typeof Visitor;
|
|
87
|
+
const visitorOpts = { ...passingOpts, ...options };
|
|
88
|
+
|
|
89
|
+
return new VisitorClz(visitorOpts);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
toRefractedElement(specPath: string[], element: any, options = {}) {
|
|
93
|
+
/**
|
|
94
|
+
* This is `Visitor shortcut`: a mechanism for short-circuiting the traversal and replacing
|
|
95
|
+
* it by basic node cloning.
|
|
96
|
+
*
|
|
97
|
+
* Visiting the element is equivalent to cloning it if the prototype of a visitor
|
|
98
|
+
* is the same as the prototype of FallbackVisitor. If that's the case, we can avoid
|
|
99
|
+
* bootstrapping the traversal cycle for fields that don't require any special visiting.
|
|
100
|
+
*/
|
|
101
|
+
const visitor = this.retrieveVisitorInstance(specPath, options);
|
|
102
|
+
|
|
103
|
+
if (visitor instanceof FallbackVisitor && visitor?.constructor === FallbackVisitor) {
|
|
104
|
+
return this.consume ? element : cloneDeep(element);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
traverse(element, visitor, { nodeTypeGetter: getNodePrimitiveType });
|
|
108
|
+
return visitor.element;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default SpecificationVisitor;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomCore = require("@speclynx/apidom-core");
|
|
6
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
class Visitor {
|
|
15
|
+
element;
|
|
16
|
+
consume = false;
|
|
17
|
+
consumeSafe = false;
|
|
18
|
+
constructor(options = {}) {
|
|
19
|
+
Object.assign(this, options);
|
|
20
|
+
}
|
|
21
|
+
copyMetaAndAttributes(from, to) {
|
|
22
|
+
if (!from.isMetaEmpty && !to.isMetaEmpty) {
|
|
23
|
+
to.meta = to.meta.merge(from.meta);
|
|
24
|
+
} else if (!from.isMetaEmpty) {
|
|
25
|
+
to.meta = from.meta.cloneDeep();
|
|
26
|
+
}
|
|
27
|
+
if (!from.isAttributesEmpty && !to.isAttributesEmpty) {
|
|
28
|
+
to.attributes = (0, _apidomCore.deepmerge)(to.attributes, from.attributes);
|
|
29
|
+
} else if (!from.isAttributesEmpty) {
|
|
30
|
+
to.attributes = (0, _apidomDatamodel.cloneDeep)(from.attributes);
|
|
31
|
+
}
|
|
32
|
+
_apidomDatamodel.SourceMapElement.transfer(from, to);
|
|
33
|
+
_apidomDatamodel.StyleElement.transfer(from, to);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
var _default = exports.default = Visitor;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { deepmerge } from '@speclynx/apidom-core';
|
|
2
|
+
import { SourceMapElement, StyleElement, cloneDeep } from '@speclynx/apidom-datamodel';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class Visitor {
|
|
12
|
+
element;
|
|
13
|
+
consume = false;
|
|
14
|
+
consumeSafe = false;
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
Object.assign(this, options);
|
|
17
|
+
}
|
|
18
|
+
copyMetaAndAttributes(from, to) {
|
|
19
|
+
if (!from.isMetaEmpty && !to.isMetaEmpty) {
|
|
20
|
+
to.meta = to.meta.merge(from.meta);
|
|
21
|
+
} else if (!from.isMetaEmpty) {
|
|
22
|
+
to.meta = from.meta.cloneDeep();
|
|
23
|
+
}
|
|
24
|
+
if (!from.isAttributesEmpty && !to.isAttributesEmpty) {
|
|
25
|
+
to.attributes = deepmerge(to.attributes, from.attributes);
|
|
26
|
+
} else if (!from.isAttributesEmpty) {
|
|
27
|
+
to.attributes = cloneDeep(from.attributes);
|
|
28
|
+
}
|
|
29
|
+
SourceMapElement.transfer(from, to);
|
|
30
|
+
StyleElement.transfer(from, to);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export default Visitor;
|
|
@@ -0,0 +1,47 @@
|
|
|
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;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 _ramda = require("ramda");
|
|
7
|
+
var _ramdaAdjunct = require("ramda-adjunct");
|
|
8
|
+
var _SpecificationVisitor = _interopRequireDefault(require("../SpecificationVisitor.cjs"));
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
class AlternatingVisitor extends _SpecificationVisitor.default {
|
|
21
|
+
alternator;
|
|
22
|
+
constructor({
|
|
23
|
+
alternator,
|
|
24
|
+
...rest
|
|
25
|
+
}) {
|
|
26
|
+
super({
|
|
27
|
+
...rest
|
|
28
|
+
});
|
|
29
|
+
this.alternator = alternator || [];
|
|
30
|
+
}
|
|
31
|
+
enter(path) {
|
|
32
|
+
const element = path.node;
|
|
33
|
+
const functions = this.alternator.map(({
|
|
34
|
+
predicate,
|
|
35
|
+
specPath
|
|
36
|
+
}) => (0, _ramda.ifElse)(predicate, (0, _ramda.always)(specPath), _ramdaAdjunct.stubUndefined));
|
|
37
|
+
const specPath = (0, _ramdaAdjunct.dispatch)(functions)(element);
|
|
38
|
+
this.element = this.toRefractedElement(specPath, element);
|
|
39
|
+
path.stop();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
var _default = exports.default = AlternatingVisitor;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ifElse, always } from 'ramda';
|
|
2
|
+
import { dispatch, stubUndefined } from 'ramda-adjunct';
|
|
3
|
+
import SpecificationVisitor from "../SpecificationVisitor.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
class AlternatingVisitor extends SpecificationVisitor {
|
|
14
|
+
alternator;
|
|
15
|
+
constructor({
|
|
16
|
+
alternator,
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
19
|
+
super({
|
|
20
|
+
...rest
|
|
21
|
+
});
|
|
22
|
+
this.alternator = alternator || [];
|
|
23
|
+
}
|
|
24
|
+
enter(path) {
|
|
25
|
+
const element = path.node;
|
|
26
|
+
const functions = this.alternator.map(({
|
|
27
|
+
predicate,
|
|
28
|
+
specPath
|
|
29
|
+
}) => ifElse(predicate, always(specPath), stubUndefined));
|
|
30
|
+
const specPath = dispatch(functions)(element);
|
|
31
|
+
this.element = this.toRefractedElement(specPath, element);
|
|
32
|
+
path.stop();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export default AlternatingVisitor;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ifElse, always } from 'ramda';
|
|
2
|
+
import { dispatch, stubUndefined } from 'ramda-adjunct';
|
|
3
|
+
import { Element } from '@speclynx/apidom-datamodel';
|
|
4
|
+
import { Path } from '@speclynx/apidom-traverse';
|
|
5
|
+
|
|
6
|
+
import SpecificationVisitor, { SpecificationVisitorOptions } from '../SpecificationVisitor.ts';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export type Alternator = { predicate: (element: unknown) => boolean; specPath: string[] };
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface AlternatingVisitorOptions extends SpecificationVisitorOptions {
|
|
17
|
+
readonly alternator: Alternator[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
class AlternatingVisitor extends SpecificationVisitor {
|
|
24
|
+
protected alternator: Alternator[];
|
|
25
|
+
|
|
26
|
+
constructor({ alternator, ...rest }: AlternatingVisitorOptions) {
|
|
27
|
+
super({ ...rest });
|
|
28
|
+
this.alternator = alternator || [];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
enter(path: Path<Element>) {
|
|
32
|
+
const element = path.node;
|
|
33
|
+
const functions = this.alternator.map(
|
|
34
|
+
({ predicate, specPath }: { predicate: (element: unknown) => boolean; specPath: string[] }) =>
|
|
35
|
+
ifElse(predicate, always(specPath), stubUndefined),
|
|
36
|
+
);
|
|
37
|
+
const specPath = dispatch(functions)(element);
|
|
38
|
+
|
|
39
|
+
this.element = this.toRefractedElement(specPath, element);
|
|
40
|
+
|
|
41
|
+
path.stop();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default AlternatingVisitor;
|
|
@@ -0,0 +1,75 @@
|
|
|
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 _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
7
|
+
var _apidomCore = require("@speclynx/apidom-core");
|
|
8
|
+
var _SpecificationVisitor = _interopRequireDefault(require("../SpecificationVisitor.cjs"));
|
|
9
|
+
var _predicates = require("../../predicates.cjs");
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
class FixedFieldsVisitor extends _SpecificationVisitor.default {
|
|
22
|
+
specPath;
|
|
23
|
+
ignoredFields;
|
|
24
|
+
canSupportSpecificationExtensions = true;
|
|
25
|
+
specificationExtensionPredicate = _predicates.isOpenApiExtension;
|
|
26
|
+
constructor({
|
|
27
|
+
specPath,
|
|
28
|
+
ignoredFields,
|
|
29
|
+
canSupportSpecificationExtensions,
|
|
30
|
+
specificationExtensionPredicate,
|
|
31
|
+
...rest
|
|
32
|
+
}) {
|
|
33
|
+
super({
|
|
34
|
+
...rest
|
|
35
|
+
});
|
|
36
|
+
this.specPath = specPath;
|
|
37
|
+
this.ignoredFields = ignoredFields || [];
|
|
38
|
+
if (typeof canSupportSpecificationExtensions === 'boolean') {
|
|
39
|
+
this.canSupportSpecificationExtensions = canSupportSpecificationExtensions;
|
|
40
|
+
}
|
|
41
|
+
if (typeof specificationExtensionPredicate === 'function') {
|
|
42
|
+
this.specificationExtensionPredicate = specificationExtensionPredicate;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
ObjectElement(path) {
|
|
46
|
+
const objectElement = path.node;
|
|
47
|
+
const specPath = this.specPath(objectElement);
|
|
48
|
+
const fields = this.retrieveFixedFields(specPath);
|
|
49
|
+
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
objectElement.forEach((value, key, memberElement) => {
|
|
52
|
+
const keyValue = (0, _apidomCore.toValue)(key);
|
|
53
|
+
if ((0, _apidomDatamodel.isStringElement)(key) && fields.includes(keyValue) && !this.ignoredFields.includes(keyValue)) {
|
|
54
|
+
const fixedFieldElement = this.toRefractedElement([...specPath, 'fixedFields', keyValue], value);
|
|
55
|
+
const newMemberElement = new _apidomDatamodel.MemberElement(this.consume ? key : (0, _apidomDatamodel.cloneDeep)(key), fixedFieldElement);
|
|
56
|
+
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
57
|
+
this.element.content.push(newMemberElement);
|
|
58
|
+
// consume: release processed generic subtree
|
|
59
|
+
if (this.consume && this.consumeSafe && !memberElement.isFrozen) memberElement.value = undefined;
|
|
60
|
+
} else if (this.canSupportSpecificationExtensions && this.specificationExtensionPredicate(memberElement)) {
|
|
61
|
+
const extensionElement = this.toRefractedElement(['document', 'extension'], memberElement);
|
|
62
|
+
this.element.content.push(extensionElement);
|
|
63
|
+
// consume: release processed generic subtree
|
|
64
|
+
if (this.consume && this.consumeSafe && !memberElement.isFrozen) {
|
|
65
|
+
memberElement.value = undefined;
|
|
66
|
+
}
|
|
67
|
+
} else if (!this.ignoredFields.includes(keyValue)) {
|
|
68
|
+
this.element.content.push(this.consume ? memberElement : (0, _apidomDatamodel.cloneDeep)(memberElement));
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
this.copyMetaAndAttributes(objectElement, this.element);
|
|
72
|
+
path.stop();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
var _default = exports.default = FixedFieldsVisitor;
|