@speclynx/apidom-ns-openapi-3-1 2.13.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/apidom-ns-openapi-3-1.browser.js +322 -154
- package/dist/apidom-ns-openapi-3-1.browser.min.js +1 -1
- package/package.json +8 -8
- package/src/refractor/index.cjs +4 -2
- package/src/refractor/index.mjs +4 -2
- package/src/refractor/plugins/normalize-operation-ids.cjs +3 -3
- package/src/refractor/plugins/normalize-operation-ids.mjs +3 -3
- package/src/refractor/plugins/replace-empty-element.cjs +3 -2
- package/src/refractor/plugins/replace-empty-element.mjs +3 -2
- package/src/refractor/visitors/open-api-3-1/index.cjs +9 -0
- package/src/refractor/visitors/open-api-3-1/index.mjs +9 -0
- package/src/refractor/visitors/open-api-3-1/schema/index.cjs +2 -2
- package/src/refractor/visitors/open-api-3-1/schema/index.mjs +2 -2
- package/types/apidom-ns-openapi-3-1.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-ns-openapi-3-1",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "OpenAPI 3.1.x namespace for ApiDOM.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"license": "Apache-2.0",
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@babel/runtime-corejs3": "^7.28.4",
|
|
49
|
-
"@speclynx/apidom-core": "
|
|
50
|
-
"@speclynx/apidom-datamodel": "
|
|
51
|
-
"@speclynx/apidom-json-pointer": "
|
|
52
|
-
"@speclynx/apidom-ns-json-schema-2020-12": "
|
|
53
|
-
"@speclynx/apidom-ns-openapi-3-0": "
|
|
54
|
-
"@speclynx/apidom-traverse": "
|
|
49
|
+
"@speclynx/apidom-core": "3.0.0",
|
|
50
|
+
"@speclynx/apidom-datamodel": "3.0.0",
|
|
51
|
+
"@speclynx/apidom-json-pointer": "3.0.0",
|
|
52
|
+
"@speclynx/apidom-ns-json-schema-2020-12": "3.0.0",
|
|
53
|
+
"@speclynx/apidom-ns-openapi-3-0": "3.0.0",
|
|
54
|
+
"@speclynx/apidom-traverse": "3.0.0",
|
|
55
55
|
"ramda": "~0.32.0",
|
|
56
56
|
"ramda-adjunct": "^6.0.0",
|
|
57
57
|
"ts-mixer": "^6.0.4"
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"README.md",
|
|
67
67
|
"CHANGELOG.md"
|
|
68
68
|
],
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "cb94ec84ea789d121801065876e7a91799a363d0"
|
|
70
70
|
}
|
package/src/refractor/index.cjs
CHANGED
|
@@ -23,7 +23,8 @@ var _toolbox = _interopRequireDefault(require("./toolbox.cjs"));
|
|
|
23
23
|
const refract = (value, {
|
|
24
24
|
element = 'openApi3_1',
|
|
25
25
|
plugins = [],
|
|
26
|
-
specificationObj = _specification.default
|
|
26
|
+
specificationObj = _specification.default,
|
|
27
|
+
consume = false
|
|
27
28
|
} = {}) => {
|
|
28
29
|
const genericElement = (0, _apidomDatamodel.refract)(value);
|
|
29
30
|
const resolvedSpec = (0, _apidomCore.resolveSpecification)(specificationObj);
|
|
@@ -40,7 +41,8 @@ const refract = (value, {
|
|
|
40
41
|
*/
|
|
41
42
|
const RootVisitorClass = (0, _ramda.path)(specPath, resolvedSpec);
|
|
42
43
|
const rootVisitor = new RootVisitorClass({
|
|
43
|
-
specObj: resolvedSpec
|
|
44
|
+
specObj: resolvedSpec,
|
|
45
|
+
consume
|
|
44
46
|
});
|
|
45
47
|
(0, _apidomTraverse.traverse)(genericElement, rootVisitor, {
|
|
46
48
|
nodeTypeGetter: _apidomTraverse.getNodePrimitiveType
|
package/src/refractor/index.mjs
CHANGED
|
@@ -16,7 +16,8 @@ import createToolbox from "./toolbox.mjs";
|
|
|
16
16
|
const refract = (value, {
|
|
17
17
|
element = 'openApi3_1',
|
|
18
18
|
plugins = [],
|
|
19
|
-
specificationObj = specification
|
|
19
|
+
specificationObj = specification,
|
|
20
|
+
consume = false
|
|
20
21
|
} = {}) => {
|
|
21
22
|
const genericElement = baseRefract(value);
|
|
22
23
|
const resolvedSpec = resolveSpecification(specificationObj);
|
|
@@ -33,7 +34,8 @@ const refract = (value, {
|
|
|
33
34
|
*/
|
|
34
35
|
const RootVisitorClass = path(specPath, resolvedSpec);
|
|
35
36
|
const rootVisitor = new RootVisitorClass({
|
|
36
|
-
specObj: resolvedSpec
|
|
37
|
+
specObj: resolvedSpec,
|
|
38
|
+
consume
|
|
37
39
|
});
|
|
38
40
|
traverse(genericElement, rootVisitor, {
|
|
39
41
|
nodeTypeGetter: getNodePrimitiveType
|
|
@@ -89,7 +89,7 @@ const plugin = ({
|
|
|
89
89
|
if (typeof linkElement.operationId === 'undefined') return;
|
|
90
90
|
const linkOperationId = String((0, _apidomCore.toValue)(linkElement.operationId));
|
|
91
91
|
const operationElement = normalizedOperations.find(normalizedOperationElement => {
|
|
92
|
-
const originalOperationId =
|
|
92
|
+
const originalOperationId = normalizedOperationElement.meta.get('originalOperationId');
|
|
93
93
|
return originalOperationId === linkOperationId;
|
|
94
94
|
});
|
|
95
95
|
|
|
@@ -110,7 +110,7 @@ const plugin = ({
|
|
|
110
110
|
enter(path) {
|
|
111
111
|
const pathItemElement = path.node;
|
|
112
112
|
// `path` meta may not be always available, e.g. in Callback Object or Components Object
|
|
113
|
-
const pathTemplate = (0, _ramda.defaultTo)('path',
|
|
113
|
+
const pathTemplate = (0, _ramda.defaultTo)('path', pathItemElement.meta.get('path'));
|
|
114
114
|
pathTemplates.push(pathTemplate);
|
|
115
115
|
},
|
|
116
116
|
leave() {
|
|
@@ -136,7 +136,7 @@ const plugin = ({
|
|
|
136
136
|
// perform operationId normalization
|
|
137
137
|
const pathTemplate = (0, _ramda.last)(pathTemplates);
|
|
138
138
|
// `http-method` meta may not be always available, e.g. in Callback Object or Components Object
|
|
139
|
-
const method = (0, _ramda.defaultTo)('method',
|
|
139
|
+
const method = (0, _ramda.defaultTo)('method', operationElement.meta.get('http-method'));
|
|
140
140
|
const normalizedOperationId = operationIdNormalizer(originalOperationId, pathTemplate, method);
|
|
141
141
|
|
|
142
142
|
// normalization is not necessary
|
|
@@ -84,7 +84,7 @@ const plugin = ({
|
|
|
84
84
|
if (typeof linkElement.operationId === 'undefined') return;
|
|
85
85
|
const linkOperationId = String(toValue(linkElement.operationId));
|
|
86
86
|
const operationElement = normalizedOperations.find(normalizedOperationElement => {
|
|
87
|
-
const originalOperationId =
|
|
87
|
+
const originalOperationId = normalizedOperationElement.meta.get('originalOperationId');
|
|
88
88
|
return originalOperationId === linkOperationId;
|
|
89
89
|
});
|
|
90
90
|
|
|
@@ -105,7 +105,7 @@ const plugin = ({
|
|
|
105
105
|
enter(path) {
|
|
106
106
|
const pathItemElement = path.node;
|
|
107
107
|
// `path` meta may not be always available, e.g. in Callback Object or Components Object
|
|
108
|
-
const pathTemplate = defaultTo('path',
|
|
108
|
+
const pathTemplate = defaultTo('path', pathItemElement.meta.get('path'));
|
|
109
109
|
pathTemplates.push(pathTemplate);
|
|
110
110
|
},
|
|
111
111
|
leave() {
|
|
@@ -131,7 +131,7 @@ const plugin = ({
|
|
|
131
131
|
// perform operationId normalization
|
|
132
132
|
const pathTemplate = last(pathTemplates);
|
|
133
133
|
// `http-method` meta may not be always available, e.g. in Callback Object or Components Object
|
|
134
|
-
const method = defaultTo('method',
|
|
134
|
+
const method = defaultTo('method', operationElement.meta.get('http-method'));
|
|
135
135
|
const normalizedOperationId = operationIdNormalizer(originalOperationId, pathTemplate, method);
|
|
136
136
|
|
|
137
137
|
// normalization is not necessary
|
|
@@ -627,7 +627,8 @@ const schema = {
|
|
|
627
627
|
};
|
|
628
628
|
const findElementFactory = (ancestor, keyName) => {
|
|
629
629
|
const elementType = (0, _apidomTraverse.getNodeType)(ancestor);
|
|
630
|
-
const
|
|
630
|
+
const classType = ancestor.isMetaEmpty ? undefined : ancestor.classes.at(0);
|
|
631
|
+
const keyMapping = schema[elementType] || schema[classType];
|
|
631
632
|
return typeof keyMapping === 'undefined' ? undefined : Object.hasOwn(keyMapping, '[key: *]') ? keyMapping['[key: *]'] : keyMapping[keyName];
|
|
632
633
|
};
|
|
633
634
|
|
|
@@ -657,7 +658,7 @@ const plugin = () => () => {
|
|
|
657
658
|
if (typeof elementFactory !== 'function') return;
|
|
658
659
|
const newElement = elementFactory.call({
|
|
659
660
|
context
|
|
660
|
-
}, undefined,
|
|
661
|
+
}, undefined, element.isMetaEmpty ? undefined : element.meta.cloneDeep(), element.isAttributesEmpty ? undefined : (0, _apidomDatamodel.cloneDeep)(element.attributes));
|
|
661
662
|
_apidomDatamodel.SourceMapElement.transfer(element, newElement);
|
|
662
663
|
_apidomDatamodel.StyleElement.transfer(element, newElement);
|
|
663
664
|
path.replaceWith(newElement);
|
|
@@ -619,7 +619,8 @@ const schema = {
|
|
|
619
619
|
};
|
|
620
620
|
const findElementFactory = (ancestor, keyName) => {
|
|
621
621
|
const elementType = getNodeType(ancestor);
|
|
622
|
-
const
|
|
622
|
+
const classType = ancestor.isMetaEmpty ? undefined : ancestor.classes.at(0);
|
|
623
|
+
const keyMapping = schema[elementType] || schema[classType];
|
|
623
624
|
return typeof keyMapping === 'undefined' ? undefined : Object.hasOwn(keyMapping, '[key: *]') ? keyMapping['[key: *]'] : keyMapping[keyName];
|
|
624
625
|
};
|
|
625
626
|
|
|
@@ -649,7 +650,7 @@ const plugin = () => () => {
|
|
|
649
650
|
if (typeof elementFactory !== 'function') return;
|
|
650
651
|
const newElement = elementFactory.call({
|
|
651
652
|
context
|
|
652
|
-
}, undefined,
|
|
653
|
+
}, undefined, element.isMetaEmpty ? undefined : element.meta.cloneDeep(), element.isAttributesEmpty ? undefined : cloneDeep(element.attributes));
|
|
653
654
|
SourceMapElement.transfer(element, newElement);
|
|
654
655
|
StyleElement.transfer(element, newElement);
|
|
655
656
|
path.replaceWith(newElement);
|
|
@@ -4,6 +4,8 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.default = void 0;
|
|
6
6
|
var _ramda = require("ramda");
|
|
7
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
8
|
+
var _apidomCore = require("@speclynx/apidom-core");
|
|
7
9
|
var _apidomNsOpenapi = require("@speclynx/apidom-ns-openapi-3-0");
|
|
8
10
|
var _OpenApi = _interopRequireDefault(require("../../../elements/OpenApi3-1.cjs"));
|
|
9
11
|
var _bases = require("./bases.cjs");
|
|
@@ -21,11 +23,18 @@ class OpenApi3_1Visitor extends _bases.BaseFixedFieldsVisitor {
|
|
|
21
23
|
this.element = new _OpenApi.default();
|
|
22
24
|
this.specPath = (0, _ramda.always)(['document', 'objects', 'OpenApi']);
|
|
23
25
|
this.canSupportSpecificationExtensions = true;
|
|
26
|
+
this.consumeSafe = true;
|
|
24
27
|
this.openApiSemanticElement = this.element;
|
|
25
28
|
}
|
|
26
29
|
ObjectElement(path) {
|
|
27
30
|
const objectElement = path.node;
|
|
28
31
|
this.openApiGenericElement = objectElement;
|
|
32
|
+
// precompute values from generic root before consume may release fields
|
|
33
|
+
if ((0, _apidomDatamodel.isStringElement)(objectElement.get('jsonSchemaDialect'))) {
|
|
34
|
+
this.sourceContext = {
|
|
35
|
+
jsonSchemaDialect: (0, _apidomCore.toValue)(objectElement.get('jsonSchemaDialect'))
|
|
36
|
+
};
|
|
37
|
+
}
|
|
29
38
|
_apidomNsOpenapi.FixedFieldsVisitor.prototype.ObjectElement.call(this, path);
|
|
30
39
|
}
|
|
31
40
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { always } from 'ramda';
|
|
2
|
+
import { isStringElement } from '@speclynx/apidom-datamodel';
|
|
3
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
2
4
|
import { FixedFieldsVisitor } from '@speclynx/apidom-ns-openapi-3-0';
|
|
3
5
|
import OpenApi3_1Element from "../../../elements/OpenApi3-1.mjs";
|
|
4
6
|
import { BaseFixedFieldsVisitor } from "./bases.mjs";
|
|
@@ -15,11 +17,18 @@ class OpenApi3_1Visitor extends BaseFixedFieldsVisitor {
|
|
|
15
17
|
this.element = new OpenApi3_1Element();
|
|
16
18
|
this.specPath = always(['document', 'objects', 'OpenApi']);
|
|
17
19
|
this.canSupportSpecificationExtensions = true;
|
|
20
|
+
this.consumeSafe = true;
|
|
18
21
|
this.openApiSemanticElement = this.element;
|
|
19
22
|
}
|
|
20
23
|
ObjectElement(path) {
|
|
21
24
|
const objectElement = path.node;
|
|
22
25
|
this.openApiGenericElement = objectElement;
|
|
26
|
+
// precompute values from generic root before consume may release fields
|
|
27
|
+
if (isStringElement(objectElement.get('jsonSchemaDialect'))) {
|
|
28
|
+
this.sourceContext = {
|
|
29
|
+
jsonSchemaDialect: toValue(objectElement.get('jsonSchemaDialect'))
|
|
30
|
+
};
|
|
31
|
+
}
|
|
23
32
|
FixedFieldsVisitor.prototype.ObjectElement.call(this, path);
|
|
24
33
|
}
|
|
25
34
|
}
|
|
@@ -59,8 +59,8 @@ class SchemaVisitor extends _bases.BaseSchemaVisitor {
|
|
|
59
59
|
(0, _predicates.isJsonSchemaDialectElement)(this.openApiSemanticElement.jsonSchemaDialect)) {
|
|
60
60
|
// @ts-ignore
|
|
61
61
|
jsonSchemaDialect = (0, _apidomCore.toValue)(this.openApiSemanticElement.jsonSchemaDialect);
|
|
62
|
-
} else if (this.
|
|
63
|
-
jsonSchemaDialect =
|
|
62
|
+
} else if (this.sourceContext?.jsonSchemaDialect !== undefined) {
|
|
63
|
+
jsonSchemaDialect = this.sourceContext.jsonSchemaDialect;
|
|
64
64
|
} else {
|
|
65
65
|
jsonSchemaDialect = (0, _apidomCore.toValue)(this.jsonSchemaDefaultDialect);
|
|
66
66
|
}
|
|
@@ -53,8 +53,8 @@ class SchemaVisitor extends BaseSchemaVisitor {
|
|
|
53
53
|
isJsonSchemaDialectElement(this.openApiSemanticElement.jsonSchemaDialect)) {
|
|
54
54
|
// @ts-ignore
|
|
55
55
|
jsonSchemaDialect = toValue(this.openApiSemanticElement.jsonSchemaDialect);
|
|
56
|
-
} else if (this.
|
|
57
|
-
jsonSchemaDialect =
|
|
56
|
+
} else if (this.sourceContext?.jsonSchemaDialect !== undefined) {
|
|
57
|
+
jsonSchemaDialect = this.sourceContext.jsonSchemaDialect;
|
|
58
58
|
} else {
|
|
59
59
|
jsonSchemaDialect = toValue(this.jsonSchemaDefaultDialect);
|
|
60
60
|
}
|
|
@@ -1367,7 +1367,7 @@ export { ReferenceVisitorOptions }
|
|
|
1367
1367
|
/**
|
|
1368
1368
|
* @public
|
|
1369
1369
|
*/
|
|
1370
|
-
export declare const refract: <T extends Element_2>(value: unknown, { element, plugins, specificationObj }?: RefractorOptions) => T;
|
|
1370
|
+
export declare const refract: <T extends Element_2>(value: unknown, { element, plugins, specificationObj, consume, }?: RefractorOptions) => T;
|
|
1371
1371
|
|
|
1372
1372
|
/**
|
|
1373
1373
|
* Refracts a value into a CallbackElement.
|
|
@@ -1478,6 +1478,7 @@ export declare interface RefractorOptions {
|
|
|
1478
1478
|
readonly element?: string;
|
|
1479
1479
|
readonly plugins?: RefractorPlugin[];
|
|
1480
1480
|
readonly specificationObj?: typeof specificationObj;
|
|
1481
|
+
readonly consume?: boolean;
|
|
1481
1482
|
}
|
|
1482
1483
|
|
|
1483
1484
|
/**
|