@speclynx/apidom-ns-openapi-3-0 4.0.3 → 4.0.5
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/dist/apidom-ns-openapi-3-0.browser.js +30 -6
- package/dist/apidom-ns-openapi-3-0.browser.min.js +1 -1
- package/package.json +9 -8
- package/src/elements/Callback.ts +0 -13
- package/src/elements/Components.ts +0 -85
- package/src/elements/Contact.ts +0 -42
- package/src/elements/Discriminator.ts +0 -34
- package/src/elements/Encoding.ts +0 -59
- package/src/elements/Example.ts +0 -51
- package/src/elements/ExternalDocumentation.ts +0 -34
- package/src/elements/Header.ts +0 -119
- package/src/elements/Info.ts +0 -70
- package/src/elements/License.ts +0 -34
- package/src/elements/Link.ts +0 -85
- package/src/elements/MediaType.ts +0 -48
- package/src/elements/OAuthFlow.ts +0 -50
- package/src/elements/OAuthFlows.ts +0 -47
- package/src/elements/OpenApi3-0.ts +0 -90
- package/src/elements/Openapi.ts +0 -15
- package/src/elements/Operation.ts +0 -124
- package/src/elements/Parameter.ts +0 -135
- package/src/elements/PathItem.ts +0 -125
- package/src/elements/Paths.ts +0 -13
- package/src/elements/Reference.ts +0 -27
- package/src/elements/RequestBody.ts +0 -46
- package/src/elements/Response.ts +0 -50
- package/src/elements/Responses.ts +0 -24
- package/src/elements/Schema.ts +0 -230
- package/src/elements/SecurityRequirement.ts +0 -13
- package/src/elements/SecurityScheme.ts +0 -84
- package/src/elements/Server.ts +0 -42
- package/src/elements/ServerVariable.ts +0 -43
- package/src/elements/Tag.ts +0 -44
- package/src/elements/Xml.ts +0 -59
- package/src/elements/nces/ComponentsCallbacks.ts +0 -15
- package/src/elements/nces/ComponentsExamples.ts +0 -16
- package/src/elements/nces/ComponentsHeaders.ts +0 -15
- package/src/elements/nces/ComponentsLinks.ts +0 -15
- package/src/elements/nces/ComponentsParameters.ts +0 -16
- package/src/elements/nces/ComponentsRequestBodies.ts +0 -15
- package/src/elements/nces/ComponentsResponses.ts +0 -15
- package/src/elements/nces/ComponentsSchemas.ts +0 -15
- package/src/elements/nces/ComponentsSecuritySchemes.ts +0 -15
- package/src/elements/nces/DiscriminatorMapping.ts +0 -15
- package/src/elements/nces/EncodingHeaders.ts +0 -15
- package/src/elements/nces/HeaderContent.ts +0 -16
- package/src/elements/nces/HeaderExamples.ts +0 -16
- package/src/elements/nces/LinkParameters.ts +0 -15
- package/src/elements/nces/MediaTypeEncoding.ts +0 -15
- package/src/elements/nces/MediaTypeExamples.ts +0 -16
- package/src/elements/nces/OAuthFlowScopes.ts +0 -15
- package/src/elements/nces/OperationCallbacks.ts +0 -15
- package/src/elements/nces/OperationParameters.ts +0 -16
- package/src/elements/nces/OperationSecurity.ts +0 -16
- package/src/elements/nces/OperationServers.ts +0 -16
- package/src/elements/nces/OperationTags.ts +0 -15
- package/src/elements/nces/ParameterContent.ts +0 -16
- package/src/elements/nces/ParameterExamples.ts +0 -16
- package/src/elements/nces/PathItemParameters.ts +0 -16
- package/src/elements/nces/PathItemServers.ts +0 -16
- package/src/elements/nces/RequestBodyContent.ts +0 -16
- package/src/elements/nces/ResponseContent.ts +0 -16
- package/src/elements/nces/ResponseHeaders.ts +0 -15
- package/src/elements/nces/ResponseLinks.ts +0 -15
- package/src/elements/nces/Security.ts +0 -15
- package/src/elements/nces/ServerVariables.ts +0 -15
- package/src/elements/nces/Servers.ts +0 -15
- package/src/elements/nces/Tags.ts +0 -15
- package/src/index.ts +0 -550
- package/src/media-types.ts +0 -52
- package/src/namespace.ts +0 -78
- package/src/predicates.ts +0 -185
- package/src/refractor/index.ts +0 -370
- package/src/refractor/inspect.ts +0 -239
- package/src/refractor/plugins/replace-empty-element.ts +0 -656
- package/src/refractor/predicates.ts +0 -39
- package/src/refractor/specification.ts +0 -557
- package/src/refractor/toolbox.ts +0 -24
- package/src/refractor/visitors/FallbackVisitor.ts +0 -24
- package/src/refractor/visitors/SpecificationExtensionVisitor.ts +0 -22
- package/src/refractor/visitors/SpecificationVisitor.ts +0 -112
- package/src/refractor/visitors/Visitor.ts +0 -47
- package/src/refractor/visitors/generics/AlternatingVisitor.ts +0 -45
- package/src/refractor/visitors/generics/FixedFieldsVisitor.ts +0 -110
- package/src/refractor/visitors/generics/MapVisitor.ts +0 -25
- package/src/refractor/visitors/generics/MixedFieldsVisitor.ts +0 -77
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.ts +0 -99
- package/src/refractor/visitors/open-api-3-0/ContentVisitor.ts +0 -28
- package/src/refractor/visitors/open-api-3-0/ExamplesVisitor.ts +0 -48
- package/src/refractor/visitors/open-api-3-0/OpenapiVisitor.ts +0 -30
- package/src/refractor/visitors/open-api-3-0/ParametersVisitor.ts +0 -47
- package/src/refractor/visitors/open-api-3-0/SecurityVisitor.ts +0 -44
- package/src/refractor/visitors/open-api-3-0/ServersVisitor.ts +0 -40
- package/src/refractor/visitors/open-api-3-0/TagsVisitor.ts +0 -40
- package/src/refractor/visitors/open-api-3-0/bases.ts +0 -82
- package/src/refractor/visitors/open-api-3-0/callback/index.ts +0 -49
- package/src/refractor/visitors/open-api-3-0/components/CallbacksVisitor.ts +0 -45
- package/src/refractor/visitors/open-api-3-0/components/ExamplesVisitor.ts +0 -46
- package/src/refractor/visitors/open-api-3-0/components/HeadersVisitor.ts +0 -53
- package/src/refractor/visitors/open-api-3-0/components/LinksVisitor.ts +0 -45
- package/src/refractor/visitors/open-api-3-0/components/ParametersVisitor.ts +0 -46
- package/src/refractor/visitors/open-api-3-0/components/RequestBodiesVisitor.ts +0 -45
- package/src/refractor/visitors/open-api-3-0/components/ResponsesVisitor.ts +0 -53
- package/src/refractor/visitors/open-api-3-0/components/SchemasVisitor.ts +0 -46
- package/src/refractor/visitors/open-api-3-0/components/SecuritySchemesVisitor.ts +0 -45
- package/src/refractor/visitors/open-api-3-0/components/index.ts +0 -31
- package/src/refractor/visitors/open-api-3-0/contact/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/distriminator/MappingVisitor.ts +0 -24
- package/src/refractor/visitors/open-api-3-0/distriminator/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/encoding/HeadersVisitor.ts +0 -57
- package/src/refractor/visitors/open-api-3-0/encoding/index.ts +0 -49
- package/src/refractor/visitors/open-api-3-0/example/ExternalValueVisitor.ts +0 -20
- package/src/refractor/visitors/open-api-3-0/example/index.ts +0 -38
- package/src/refractor/visitors/open-api-3-0/external-documentation/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/header/ContentVisitor.ts +0 -18
- package/src/refractor/visitors/open-api-3-0/header/ExamplesVisitor.ts +0 -18
- package/src/refractor/visitors/open-api-3-0/header/SchemaVisitor.ts +0 -33
- package/src/refractor/visitors/open-api-3-0/header/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/index.ts +0 -39
- package/src/refractor/visitors/open-api-3-0/info/VersionVisitor.ts +0 -21
- package/src/refractor/visitors/open-api-3-0/info/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/license/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/link/OperationIdVisitor.ts +0 -20
- package/src/refractor/visitors/open-api-3-0/link/OperationRefVisitor.ts +0 -20
- package/src/refractor/visitors/open-api-3-0/link/ParametersVisitor.ts +0 -24
- package/src/refractor/visitors/open-api-3-0/link/index.ts +0 -38
- package/src/refractor/visitors/open-api-3-0/media-type/EncodingVisitor.ts +0 -24
- package/src/refractor/visitors/open-api-3-0/media-type/ExamplesVisitor.ts +0 -18
- package/src/refractor/visitors/open-api-3-0/media-type/SchemaVisitor.ts +0 -33
- package/src/refractor/visitors/open-api-3-0/media-type/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/oauth-flow/ScopesVisitor.ts +0 -24
- package/src/refractor/visitors/open-api-3-0/oauth-flow/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/oauth-flows/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/operation/CallbacksVisitor.ts +0 -45
- package/src/refractor/visitors/open-api-3-0/operation/ParametersVisitor.ts +0 -18
- package/src/refractor/visitors/open-api-3-0/operation/RequestBodyVisitor.ts +0 -39
- package/src/refractor/visitors/open-api-3-0/operation/SecurityVisitor.ts +0 -41
- package/src/refractor/visitors/open-api-3-0/operation/ServersVisitor.ts +0 -18
- package/src/refractor/visitors/open-api-3-0/operation/TagsVisitor.ts +0 -32
- package/src/refractor/visitors/open-api-3-0/operation/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/parameter/ContentVisitor.ts +0 -18
- package/src/refractor/visitors/open-api-3-0/parameter/ExamplesVisitor.ts +0 -18
- package/src/refractor/visitors/open-api-3-0/parameter/SchemaVisitor.ts +0 -36
- package/src/refractor/visitors/open-api-3-0/parameter/index.ts +0 -49
- package/src/refractor/visitors/open-api-3-0/path-item/$RefVisitor.ts +0 -20
- package/src/refractor/visitors/open-api-3-0/path-item/ParametersVisitor.ts +0 -18
- package/src/refractor/visitors/open-api-3-0/path-item/ServersVisitor.ts +0 -18
- package/src/refractor/visitors/open-api-3-0/path-item/index.ts +0 -53
- package/src/refractor/visitors/open-api-3-0/paths/index.ts +0 -51
- package/src/refractor/visitors/open-api-3-0/reference/$RefVisitor.ts +0 -20
- package/src/refractor/visitors/open-api-3-0/reference/index.ts +0 -41
- package/src/refractor/visitors/open-api-3-0/request-body/ContentVisitor.ts +0 -18
- package/src/refractor/visitors/open-api-3-0/request-body/index.ts +0 -46
- package/src/refractor/visitors/open-api-3-0/response/ContentVisitor.ts +0 -18
- package/src/refractor/visitors/open-api-3-0/response/HeadersVisitor.ts +0 -57
- package/src/refractor/visitors/open-api-3-0/response/LinksVisitor.ts +0 -45
- package/src/refractor/visitors/open-api-3-0/response/index.ts +0 -57
- package/src/refractor/visitors/open-api-3-0/responses/DefaultVisitor.ts +0 -39
- package/src/refractor/visitors/open-api-3-0/responses/index.ts +0 -64
- package/src/refractor/visitors/open-api-3-0/schema/AllOfVisitor.ts +0 -34
- package/src/refractor/visitors/open-api-3-0/schema/AnyOfVisitor.ts +0 -34
- package/src/refractor/visitors/open-api-3-0/schema/ItemsVisitor.ts +0 -31
- package/src/refractor/visitors/open-api-3-0/schema/OneOfVisitor.ts +0 -34
- package/src/refractor/visitors/open-api-3-0/schema/PropertiesVisitor.ts +0 -34
- package/src/refractor/visitors/open-api-3-0/schema/SchemaOrReferenceVisitor.ts +0 -36
- package/src/refractor/visitors/open-api-3-0/schema/TypeVisitor.ts +0 -26
- package/src/refractor/visitors/open-api-3-0/schema/index.ts +0 -30
- package/src/refractor/visitors/open-api-3-0/security-requirement/index.ts +0 -24
- package/src/refractor/visitors/open-api-3-0/security-scheme/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/server/UrlVisitor.ts +0 -20
- package/src/refractor/visitors/open-api-3-0/server/VariablesVisitor.ts +0 -24
- package/src/refractor/visitors/open-api-3-0/server/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/server-variable/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/tag/index.ts +0 -27
- package/src/refractor/visitors/open-api-3-0/xml/index.ts +0 -27
package/src/predicates.ts
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import CallbackElement from './elements/Callback.ts';
|
|
2
|
-
import ComponentsElement from './elements/Components.ts';
|
|
3
|
-
import ContactElement from './elements/Contact.ts';
|
|
4
|
-
import ExampleElement from './elements/Example.ts';
|
|
5
|
-
import ExternalDocumentationElement from './elements/ExternalDocumentation.ts';
|
|
6
|
-
import HeaderElement from './elements/Header.ts';
|
|
7
|
-
import InfoElement from './elements/Info.ts';
|
|
8
|
-
import LicenseElement from './elements/License.ts';
|
|
9
|
-
import LinkElement from './elements/Link.ts';
|
|
10
|
-
import OpenapiElement from './elements/Openapi.ts';
|
|
11
|
-
import OpenApi3_0Element from './elements/OpenApi3-0.ts';
|
|
12
|
-
import OperationElement from './elements/Operation.ts';
|
|
13
|
-
import ParameterElement from './elements/Parameter.ts';
|
|
14
|
-
import PathItemElement from './elements/PathItem.ts';
|
|
15
|
-
import PathsElement from './elements/Paths.ts';
|
|
16
|
-
import ReferenceElement from './elements/Reference.ts';
|
|
17
|
-
import RequestBodyElement from './elements/RequestBody.ts';
|
|
18
|
-
import ResponseElement from './elements/Response.ts';
|
|
19
|
-
import ResponsesElement from './elements/Responses.ts';
|
|
20
|
-
import SchemaElement from './elements/Schema.ts';
|
|
21
|
-
import SecurityRequirementElement from './elements/SecurityRequirement.ts';
|
|
22
|
-
import SecuritySchemeElement from './elements/SecurityScheme.ts';
|
|
23
|
-
import ServerElement from './elements/Server.ts';
|
|
24
|
-
import ServerVariableElement from './elements/ServerVariable.ts';
|
|
25
|
-
import MediaTypeElement from './elements/MediaType.ts';
|
|
26
|
-
// NCE types
|
|
27
|
-
import ServersElement from './elements/nces/Servers.ts';
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export const isCallbackElement = (element: unknown): element is CallbackElement =>
|
|
33
|
-
element instanceof CallbackElement;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
export const isComponentsElement = (element: unknown): element is ComponentsElement =>
|
|
39
|
-
element instanceof ComponentsElement;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @public
|
|
43
|
-
*/
|
|
44
|
-
export const isContactElement = (element: unknown): element is ContactElement =>
|
|
45
|
-
element instanceof ContactElement;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @public
|
|
49
|
-
*/
|
|
50
|
-
export const isExampleElement = (element: unknown): element is ExampleElement =>
|
|
51
|
-
element instanceof ExampleElement;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @public
|
|
55
|
-
*/
|
|
56
|
-
export const isExternalDocumentationElement = (
|
|
57
|
-
element: unknown,
|
|
58
|
-
): element is ExternalDocumentationElement => element instanceof ExternalDocumentationElement;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @public
|
|
62
|
-
*/
|
|
63
|
-
export const isHeaderElement = (element: unknown): element is HeaderElement =>
|
|
64
|
-
element instanceof HeaderElement;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @public
|
|
68
|
-
*/
|
|
69
|
-
export const isInfoElement = (element: unknown): element is InfoElement =>
|
|
70
|
-
element instanceof InfoElement;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @public
|
|
74
|
-
*/
|
|
75
|
-
export const isLicenseElement = (element: unknown): element is LicenseElement =>
|
|
76
|
-
element instanceof LicenseElement;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @public
|
|
80
|
-
*/
|
|
81
|
-
export const isLinkElement = (element: unknown): element is LinkElement =>
|
|
82
|
-
element instanceof LinkElement;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @public
|
|
86
|
-
*/
|
|
87
|
-
export const isOpenapiElement = (element: unknown): element is OpenapiElement =>
|
|
88
|
-
element instanceof OpenapiElement;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* @public
|
|
92
|
-
*/
|
|
93
|
-
export const isOpenApi3_0Element = (element: unknown): element is OpenApi3_0Element =>
|
|
94
|
-
element instanceof OpenApi3_0Element;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* @public
|
|
98
|
-
*/
|
|
99
|
-
export const isOperationElement = (element: unknown): element is OperationElement =>
|
|
100
|
-
element instanceof OperationElement;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* @public
|
|
104
|
-
*/
|
|
105
|
-
export const isParameterElement = (element: unknown): element is ParameterElement =>
|
|
106
|
-
element instanceof ParameterElement;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @public
|
|
110
|
-
*/
|
|
111
|
-
export const isPathItemElement = (element: unknown): element is PathItemElement =>
|
|
112
|
-
element instanceof PathItemElement;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* @public
|
|
116
|
-
*/
|
|
117
|
-
export const isPathsElement = (element: unknown): element is PathsElement =>
|
|
118
|
-
element instanceof PathsElement;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* @public
|
|
122
|
-
*/
|
|
123
|
-
export const isReferenceElement = (element: unknown): element is ReferenceElement =>
|
|
124
|
-
element instanceof ReferenceElement;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @public
|
|
128
|
-
*/
|
|
129
|
-
export const isRequestBodyElement = (element: unknown): element is RequestBodyElement =>
|
|
130
|
-
element instanceof RequestBodyElement;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @public
|
|
134
|
-
*/
|
|
135
|
-
export const isResponseElement = (element: unknown): element is ResponseElement =>
|
|
136
|
-
element instanceof ResponseElement;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* @public
|
|
140
|
-
*/
|
|
141
|
-
export const isResponsesElement = (element: unknown): element is ResponsesElement =>
|
|
142
|
-
element instanceof ResponsesElement;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* @public
|
|
146
|
-
*/
|
|
147
|
-
export const isSchemaElement = (element: unknown): element is SchemaElement =>
|
|
148
|
-
element instanceof SchemaElement;
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* @public
|
|
152
|
-
*/
|
|
153
|
-
export const isSecurityRequirementElement = (
|
|
154
|
-
element: unknown,
|
|
155
|
-
): element is SecurityRequirementElement => element instanceof SecurityRequirementElement;
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* @public
|
|
159
|
-
*/
|
|
160
|
-
export const isSecuritySchemeElement = (element: unknown): element is SecuritySchemeElement =>
|
|
161
|
-
element instanceof SecuritySchemeElement;
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* @public
|
|
165
|
-
*/
|
|
166
|
-
export const isServerElement = (element: unknown): element is ServerElement =>
|
|
167
|
-
element instanceof ServerElement;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* @public
|
|
171
|
-
*/
|
|
172
|
-
export const isServerVariableElement = (element: unknown): element is ServerVariableElement =>
|
|
173
|
-
element instanceof ServerVariableElement;
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* @public
|
|
177
|
-
*/
|
|
178
|
-
export const isMediaTypeElement = (element: unknown): element is MediaTypeElement =>
|
|
179
|
-
element instanceof MediaTypeElement;
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* @public
|
|
183
|
-
*/
|
|
184
|
-
export const isServersElement = (element: unknown): element is ServersElement =>
|
|
185
|
-
element instanceof ServersElement;
|
package/src/refractor/index.ts
DELETED
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
import { resolveSpecification, dispatchRefractorPlugins } from '@speclynx/apidom-core';
|
|
2
|
-
import { Element, refract as baseRefract } from '@speclynx/apidom-datamodel';
|
|
3
|
-
import { traverse, getNodePrimitiveType } from '@speclynx/apidom-traverse';
|
|
4
|
-
import { path } from 'ramda';
|
|
5
|
-
|
|
6
|
-
import type VisitorClass from './visitors/Visitor.ts';
|
|
7
|
-
import specification from './specification.ts';
|
|
8
|
-
import createToolbox, { type Toolbox } from './toolbox.ts';
|
|
9
|
-
import type CallbackElement from '../elements/Callback.ts';
|
|
10
|
-
import type ComponentsElement from '../elements/Components.ts';
|
|
11
|
-
import type ContactElement from '../elements/Contact.ts';
|
|
12
|
-
import type DiscriminatorElement from '../elements/Discriminator.ts';
|
|
13
|
-
import type EncodingElement from '../elements/Encoding.ts';
|
|
14
|
-
import type ExampleElement from '../elements/Example.ts';
|
|
15
|
-
import type ExternalDocumentationElement from '../elements/ExternalDocumentation.ts';
|
|
16
|
-
import type HeaderElement from '../elements/Header.ts';
|
|
17
|
-
import type InfoElement from '../elements/Info.ts';
|
|
18
|
-
import type LicenseElement from '../elements/License.ts';
|
|
19
|
-
import type LinkElement from '../elements/Link.ts';
|
|
20
|
-
import type MediaTypeElement from '../elements/MediaType.ts';
|
|
21
|
-
import type OAuthFlowElement from '../elements/OAuthFlow.ts';
|
|
22
|
-
import type OAuthFlowsElement from '../elements/OAuthFlows.ts';
|
|
23
|
-
import type OpenApi3_0Element from '../elements/OpenApi3-0.ts';
|
|
24
|
-
import type OperationElement from '../elements/Operation.ts';
|
|
25
|
-
import type ParameterElement from '../elements/Parameter.ts';
|
|
26
|
-
import type PathItemElement from '../elements/PathItem.ts';
|
|
27
|
-
import type PathsElement from '../elements/Paths.ts';
|
|
28
|
-
import type ReferenceElement from '../elements/Reference.ts';
|
|
29
|
-
import type RequestBodyElement from '../elements/RequestBody.ts';
|
|
30
|
-
import type ResponseElement from '../elements/Response.ts';
|
|
31
|
-
import type ResponsesElement from '../elements/Responses.ts';
|
|
32
|
-
import type SchemaElement from '../elements/Schema.ts';
|
|
33
|
-
import type SecurityRequirementElement from '../elements/SecurityRequirement.ts';
|
|
34
|
-
import type SecuritySchemeElement from '../elements/SecurityScheme.ts';
|
|
35
|
-
import type ServerElement from '../elements/Server.ts';
|
|
36
|
-
import type ServerVariableElement from '../elements/ServerVariable.ts';
|
|
37
|
-
import type TagElement from '../elements/Tag.ts';
|
|
38
|
-
import type XmlElement from '../elements/Xml.ts';
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export type RefractorPlugin = (toolbox: Toolbox) => {
|
|
44
|
-
visitor?: object;
|
|
45
|
-
pre?: () => void;
|
|
46
|
-
post?: () => void;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @public
|
|
51
|
-
*/
|
|
52
|
-
export interface RefractorOptions {
|
|
53
|
-
readonly element?: string;
|
|
54
|
-
readonly plugins?: RefractorPlugin[];
|
|
55
|
-
readonly specificationObj?: typeof specification;
|
|
56
|
-
readonly consume?: boolean;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @public
|
|
61
|
-
*/
|
|
62
|
-
const refract = <T extends Element>(
|
|
63
|
-
value: unknown,
|
|
64
|
-
{
|
|
65
|
-
element = 'openApi3_0',
|
|
66
|
-
plugins = [],
|
|
67
|
-
specificationObj = specification,
|
|
68
|
-
consume = false,
|
|
69
|
-
}: RefractorOptions = {},
|
|
70
|
-
): T => {
|
|
71
|
-
const genericElement = baseRefract(value);
|
|
72
|
-
const resolvedSpec = resolveSpecification(specificationObj);
|
|
73
|
-
const elementMap = resolvedSpec.elementMap as Record<string, string[]>;
|
|
74
|
-
const specPath = elementMap[element];
|
|
75
|
-
|
|
76
|
-
if (!specPath) {
|
|
77
|
-
throw new Error(`Unknown element type: "${element}"`);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* This is where generic ApiDOM becomes semantic (namespace applied).
|
|
82
|
-
* We don't allow consumers to hook into this translation.
|
|
83
|
-
* Though we allow consumers to define their own plugins on already transformed ApiDOM.
|
|
84
|
-
*/
|
|
85
|
-
const RootVisitorClass = path(specPath, resolvedSpec) as new (
|
|
86
|
-
options: Record<string, unknown>,
|
|
87
|
-
) => InstanceType<typeof VisitorClass>;
|
|
88
|
-
const rootVisitor = new RootVisitorClass({ specObj: resolvedSpec, consume });
|
|
89
|
-
|
|
90
|
-
traverse(genericElement, rootVisitor, { nodeTypeGetter: getNodePrimitiveType });
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Running plugins visitors means extra single traversal === performance hit.
|
|
94
|
-
*/
|
|
95
|
-
return dispatchRefractorPlugins(rootVisitor.element, plugins, {
|
|
96
|
-
toolboxCreator: createToolbox,
|
|
97
|
-
}) as T;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Refracts a value into an OpenApi3_0Element.
|
|
102
|
-
* @public
|
|
103
|
-
*/
|
|
104
|
-
export const refractOpenApi3_0 = <T extends Element = OpenApi3_0Element>(
|
|
105
|
-
value: unknown,
|
|
106
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
107
|
-
): T => refract(value, { ...options, element: 'openApi3_0' });
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Refracts a value into an InfoElement.
|
|
111
|
-
* @public
|
|
112
|
-
*/
|
|
113
|
-
export const refractInfo = <T extends Element = InfoElement>(
|
|
114
|
-
value: unknown,
|
|
115
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
116
|
-
): T => refract(value, { ...options, element: 'info' });
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Refracts a value into a ContactElement.
|
|
120
|
-
* @public
|
|
121
|
-
*/
|
|
122
|
-
export const refractContact = <T extends Element = ContactElement>(
|
|
123
|
-
value: unknown,
|
|
124
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
125
|
-
): T => refract(value, { ...options, element: 'contact' });
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Refracts a value into a LicenseElement.
|
|
129
|
-
* @public
|
|
130
|
-
*/
|
|
131
|
-
export const refractLicense = <T extends Element = LicenseElement>(
|
|
132
|
-
value: unknown,
|
|
133
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
134
|
-
): T => refract(value, { ...options, element: 'license' });
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Refracts a value into a ServerElement.
|
|
138
|
-
* @public
|
|
139
|
-
*/
|
|
140
|
-
export const refractServer = <T extends Element = ServerElement>(
|
|
141
|
-
value: unknown,
|
|
142
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
143
|
-
): T => refract(value, { ...options, element: 'server' });
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Refracts a value into a ServerVariableElement.
|
|
147
|
-
* @public
|
|
148
|
-
*/
|
|
149
|
-
export const refractServerVariable = <T extends Element = ServerVariableElement>(
|
|
150
|
-
value: unknown,
|
|
151
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
152
|
-
): T => refract(value, { ...options, element: 'serverVariable' });
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Refracts a value into a ComponentsElement.
|
|
156
|
-
* @public
|
|
157
|
-
*/
|
|
158
|
-
export const refractComponents = <T extends Element = ComponentsElement>(
|
|
159
|
-
value: unknown,
|
|
160
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
161
|
-
): T => refract(value, { ...options, element: 'components' });
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Refracts a value into a PathsElement.
|
|
165
|
-
* @public
|
|
166
|
-
*/
|
|
167
|
-
export const refractPaths = <T extends Element = PathsElement>(
|
|
168
|
-
value: unknown,
|
|
169
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
170
|
-
): T => refract(value, { ...options, element: 'paths' });
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Refracts a value into a PathItemElement.
|
|
174
|
-
* @public
|
|
175
|
-
*/
|
|
176
|
-
export const refractPathItem = <T extends Element = PathItemElement>(
|
|
177
|
-
value: unknown,
|
|
178
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
179
|
-
): T => refract(value, { ...options, element: 'pathItem' });
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Refracts a value into an OperationElement.
|
|
183
|
-
* @public
|
|
184
|
-
*/
|
|
185
|
-
export const refractOperation = <T extends Element = OperationElement>(
|
|
186
|
-
value: unknown,
|
|
187
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
188
|
-
): T => refract(value, { ...options, element: 'operation' });
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Refracts a value into an ExternalDocumentationElement.
|
|
192
|
-
* @public
|
|
193
|
-
*/
|
|
194
|
-
export const refractExternalDocumentation = <T extends Element = ExternalDocumentationElement>(
|
|
195
|
-
value: unknown,
|
|
196
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
197
|
-
): T => refract(value, { ...options, element: 'externalDocumentation' });
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Refracts a value into a ParameterElement.
|
|
201
|
-
* @public
|
|
202
|
-
*/
|
|
203
|
-
export const refractParameter = <T extends Element = ParameterElement>(
|
|
204
|
-
value: unknown,
|
|
205
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
206
|
-
): T => refract(value, { ...options, element: 'parameter' });
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Refracts a value into a RequestBodyElement.
|
|
210
|
-
* @public
|
|
211
|
-
*/
|
|
212
|
-
export const refractRequestBody = <T extends Element = RequestBodyElement>(
|
|
213
|
-
value: unknown,
|
|
214
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
215
|
-
): T => refract(value, { ...options, element: 'requestBody' });
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Refracts a value into a MediaTypeElement.
|
|
219
|
-
* @public
|
|
220
|
-
*/
|
|
221
|
-
export const refractMediaType = <T extends Element = MediaTypeElement>(
|
|
222
|
-
value: unknown,
|
|
223
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
224
|
-
): T => refract(value, { ...options, element: 'mediaType' });
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Refracts a value into an EncodingElement.
|
|
228
|
-
* @public
|
|
229
|
-
*/
|
|
230
|
-
export const refractEncoding = <T extends Element = EncodingElement>(
|
|
231
|
-
value: unknown,
|
|
232
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
233
|
-
): T => refract(value, { ...options, element: 'encoding' });
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Refracts a value into a ResponsesElement.
|
|
237
|
-
* @public
|
|
238
|
-
*/
|
|
239
|
-
export const refractResponses = <T extends Element = ResponsesElement>(
|
|
240
|
-
value: unknown,
|
|
241
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
242
|
-
): T => refract(value, { ...options, element: 'responses' });
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Refracts a value into a ResponseElement.
|
|
246
|
-
* @public
|
|
247
|
-
*/
|
|
248
|
-
export const refractResponse = <T extends Element = ResponseElement>(
|
|
249
|
-
value: unknown,
|
|
250
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
251
|
-
): T => refract(value, { ...options, element: 'response' });
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Refracts a value into a CallbackElement.
|
|
255
|
-
* @public
|
|
256
|
-
*/
|
|
257
|
-
export const refractCallback = <T extends Element = CallbackElement>(
|
|
258
|
-
value: unknown,
|
|
259
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
260
|
-
): T => refract(value, { ...options, element: 'callback' });
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Refracts a value into an ExampleElement.
|
|
264
|
-
* @public
|
|
265
|
-
*/
|
|
266
|
-
export const refractExample = <T extends Element = ExampleElement>(
|
|
267
|
-
value: unknown,
|
|
268
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
269
|
-
): T => refract(value, { ...options, element: 'example' });
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Refracts a value into a LinkElement.
|
|
273
|
-
* @public
|
|
274
|
-
*/
|
|
275
|
-
export const refractLink = <T extends Element = LinkElement>(
|
|
276
|
-
value: unknown,
|
|
277
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
278
|
-
): T => refract(value, { ...options, element: 'link' });
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Refracts a value into a HeaderElement.
|
|
282
|
-
* @public
|
|
283
|
-
*/
|
|
284
|
-
export const refractHeader = <T extends Element = HeaderElement>(
|
|
285
|
-
value: unknown,
|
|
286
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
287
|
-
): T => refract(value, { ...options, element: 'header' });
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Refracts a value into a TagElement.
|
|
291
|
-
* @public
|
|
292
|
-
*/
|
|
293
|
-
export const refractTag = <T extends Element = TagElement>(
|
|
294
|
-
value: unknown,
|
|
295
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
296
|
-
): T => refract(value, { ...options, element: 'tag' });
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Refracts a value into a ReferenceElement.
|
|
300
|
-
* @public
|
|
301
|
-
*/
|
|
302
|
-
export const refractReference = <T extends Element = ReferenceElement>(
|
|
303
|
-
value: unknown,
|
|
304
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
305
|
-
): T => refract(value, { ...options, element: 'reference' });
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Refracts a value into a SchemaElement.
|
|
309
|
-
* @public
|
|
310
|
-
*/
|
|
311
|
-
export const refractSchema = <T extends Element = SchemaElement>(
|
|
312
|
-
value: unknown,
|
|
313
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
314
|
-
): T => refract(value, { ...options, element: 'schema' });
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Refracts a value into a DiscriminatorElement.
|
|
318
|
-
* @public
|
|
319
|
-
*/
|
|
320
|
-
export const refractDiscriminator = <T extends Element = DiscriminatorElement>(
|
|
321
|
-
value: unknown,
|
|
322
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
323
|
-
): T => refract(value, { ...options, element: 'discriminator' });
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Refracts a value into an XmlElement.
|
|
327
|
-
* @public
|
|
328
|
-
*/
|
|
329
|
-
export const refractXml = <T extends Element = XmlElement>(
|
|
330
|
-
value: unknown,
|
|
331
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
332
|
-
): T => refract(value, { ...options, element: 'xml' });
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Refracts a value into a SecuritySchemeElement.
|
|
336
|
-
* @public
|
|
337
|
-
*/
|
|
338
|
-
export const refractSecurityScheme = <T extends Element = SecuritySchemeElement>(
|
|
339
|
-
value: unknown,
|
|
340
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
341
|
-
): T => refract(value, { ...options, element: 'securityScheme' });
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Refracts a value into an OAuthFlowsElement.
|
|
345
|
-
* @public
|
|
346
|
-
*/
|
|
347
|
-
export const refractOAuthFlows = <T extends Element = OAuthFlowsElement>(
|
|
348
|
-
value: unknown,
|
|
349
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
350
|
-
): T => refract(value, { ...options, element: 'oAuthFlows' });
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* Refracts a value into an OAuthFlowElement.
|
|
354
|
-
* @public
|
|
355
|
-
*/
|
|
356
|
-
export const refractOAuthFlow = <T extends Element = OAuthFlowElement>(
|
|
357
|
-
value: unknown,
|
|
358
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
359
|
-
): T => refract(value, { ...options, element: 'oAuthFlow' });
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Refracts a value into a SecurityRequirementElement.
|
|
363
|
-
* @public
|
|
364
|
-
*/
|
|
365
|
-
export const refractSecurityRequirement = <T extends Element = SecurityRequirementElement>(
|
|
366
|
-
value: unknown,
|
|
367
|
-
options: Omit<RefractorOptions, 'element'> = {},
|
|
368
|
-
): T => refract(value, { ...options, element: 'securityRequirement' });
|
|
369
|
-
|
|
370
|
-
export default refract;
|