@swagger-api/apidom-ns-openapi-2 0.83.0 → 0.84.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 +7 -0
- package/cjs/index.cjs +6 -1
- package/cjs/predicates.cjs +35 -1
- package/cjs/refractor/plugins/replace-empty-element.cjs +22 -33
- package/cjs/refractor/visitors/SpecificationVisitor.cjs +3 -11
- package/cjs/refractor/visitors/Visitor.cjs +0 -1
- package/dist/apidom-ns-openapi-2.browser.js +7846 -7635
- package/dist/apidom-ns-openapi-2.browser.min.js +1 -1
- package/es/index.mjs +2 -2
- package/es/predicates.mjs +32 -1
- package/es/refractor/plugins/replace-empty-element.mjs +23 -34
- package/es/refractor/visitors/SpecificationVisitor.mjs +3 -11
- package/es/refractor/visitors/Visitor.mjs +0 -1
- package/package.json +6 -6
- package/types/dist.d.ts +34 -33
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.84.0](https://github.com/swagger-api/apidom/compare/v0.83.0...v0.84.0) (2023-11-24)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **ns-workflows-1:** add support for Info Object ([#3393](https://github.com/swagger-api/apidom/issues/3393)) ([5508c54](https://github.com/swagger-api/apidom/commit/5508c5479844c4328867f84481f56c445ec13225)), closes [#3392](https://github.com/swagger-api/apidom/issues/3392)
|
|
11
|
+
- **reference:** add OpenAPI 2.0 dereference strategy ([#3435](https://github.com/swagger-api/apidom/issues/3435)) ([aa3710b](https://github.com/swagger-api/apidom/commit/aa3710be00fef5ecc177c7d9e2ae570a077e8b68)), closes [#3102](https://github.com/swagger-api/apidom/issues/3102)
|
|
12
|
+
|
|
6
13
|
# [0.83.0](https://github.com/swagger-api/apidom/compare/v0.82.2...v0.83.0) (2023-11-07)
|
|
7
14
|
|
|
8
15
|
**Note:** Version bump only for package @swagger-api/apidom-ns-openapi-2
|
package/cjs/index.cjs
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
4
|
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
exports.
|
|
6
|
+
exports.refractorPluginReplaceEmptyElement = exports.refract = exports.mediaTypes = exports.keyMap = exports.isXmlElement = exports.isTagElement = exports.isSwaggerVersionElement = exports.isSwaggerExtension = exports.isSwaggerElement = exports.isStringElement = exports.isSecuritySchemeElement = exports.isSecurityRequirementElement = exports.isSecurityDefinitionsElement = exports.isScopesElement = exports.isSchemaElement = exports.isResponsesElement = exports.isResponsesDefinitionsElement = exports.isResponseElement = exports.isReferenceLikeElement = exports.isReferenceElementExternal = exports.isReferenceElement = exports.isRefElement = exports.isPathsElement = exports.isPathItemElementExternal = exports.isPathItemElement = exports.isParametersDefinitionsElement = exports.isParameterElement = exports.isOperationElement = exports.isObjectElement = exports.isNumberElement = exports.isNullElement = exports.isMemberElement = exports.isLinkPrimitiveElement = exports.isLicenseElement = exports.isJSONReferenceLikeElement = exports.isJSONReferenceElementExternal = exports.isJSONReferenceElement = exports.isItemsElement = exports.isInfoElement = exports.isHeadersElement = exports.isHeaderElement = exports.isExternalDocumentationElement = exports.isExampleElement = exports.isElement = exports.isDefinitionsElement = exports.isContactElement = exports.isBooleanElement = exports.isArrayElement = exports.getNodeType = exports.default = exports.createRefractor = exports.XmlElement = exports.Visitor = exports.TagElement = exports.SwaggerVersionElement = exports.SwaggerTagsElement = exports.SwaggerSecurityElement = exports.SwaggerSchemesElement = exports.SwaggerProducesElement = exports.SwaggerElement = exports.SwaggerConsumesElement = exports.SpecificationVisitor = exports.SecuritySchemeElement = exports.SecurityRequirementElement = exports.SecurityDefinitionsElement = exports.ScopesElement = exports.SchemaElement = exports.ResponsesElement = exports.ResponsesDefinitionsElement = exports.ResponseElement = exports.ReferenceElement = exports.PatternedFieldsVisitor = exports.PathsElement = exports.PathItemParametersElement = exports.PathItemElement = exports.ParametersDefinitionsElement = exports.ParameterElement = exports.OperationTagsElement = exports.OperationSecurityElement = exports.OperationSchemesElement = exports.OperationProducesElement = exports.OperationParametersElement = exports.OperationElement = exports.OperationConsumesElement = exports.OpenAPIMediaTypes = exports.MixedFieldsVisitor = exports.MapVisitor = exports.LicenseElement = exports.JSONReferenceElement = exports.ItemsElement = exports.InfoElement = exports.HeadersElement = exports.HeaderElement = exports.FixedFieldsVisitor = exports.FallbackVisitor = exports.ExternalDocumentationElement = exports.ExampleElement = exports.DefinitionsElement = exports.ContactElement = exports.AlternatingVisitor = void 0;
|
|
7
|
+
exports.specificationObj = void 0;
|
|
7
8
|
var _apidomCore = require("@swagger-api/apidom-core");
|
|
8
9
|
exports.isRefElement = _apidomCore.isRefElement;
|
|
9
10
|
exports.isLinkPrimitiveElement = _apidomCore.isLinkElement;
|
|
@@ -17,6 +18,7 @@ exports.isNumberElement = _apidomCore.isNumberElement;
|
|
|
17
18
|
exports.isStringElement = _apidomCore.isStringElement;
|
|
18
19
|
var _apidomNsJsonSchemaDraft = require("@swagger-api/apidom-ns-json-schema-draft-4");
|
|
19
20
|
exports.isJSONReferenceElement = _apidomNsJsonSchemaDraft.isJSONReferenceElement;
|
|
21
|
+
exports.isJSONReferenceLikeElement = _apidomNsJsonSchemaDraft.isJSONReferenceLikeElement;
|
|
20
22
|
exports.JSONReferenceElement = _apidomNsJsonSchemaDraft.JSONReferenceElement;
|
|
21
23
|
var _mediaTypes = _interopRequireWildcard(require("./media-types.cjs"));
|
|
22
24
|
exports.mediaTypes = _mediaTypes.default;
|
|
@@ -38,6 +40,7 @@ exports.isContactElement = _predicates.isContactElement;
|
|
|
38
40
|
exports.isLicenseElement = _predicates.isLicenseElement;
|
|
39
41
|
exports.isPathsElement = _predicates.isPathsElement;
|
|
40
42
|
exports.isPathItemElement = _predicates.isPathItemElement;
|
|
43
|
+
exports.isPathItemElementExternal = _predicates.isPathItemElementExternal;
|
|
41
44
|
exports.isOperationElement = _predicates.isOperationElement;
|
|
42
45
|
exports.isExternalDocumentationElement = _predicates.isExternalDocumentationElement;
|
|
43
46
|
exports.isParameterElement = _predicates.isParameterElement;
|
|
@@ -49,7 +52,9 @@ exports.isExampleElement = _predicates.isExampleElement;
|
|
|
49
52
|
exports.isHeaderElement = _predicates.isHeaderElement;
|
|
50
53
|
exports.isTagElement = _predicates.isTagElement;
|
|
51
54
|
exports.isReferenceElement = _predicates.isReferenceElement;
|
|
55
|
+
exports.isReferenceElementExternal = _predicates.isReferenceElementExternal;
|
|
52
56
|
exports.isSchemaElement = _predicates.isSchemaElement;
|
|
57
|
+
exports.isJSONReferenceElementExternal = _predicates.isJSONReferenceElementExternal;
|
|
53
58
|
exports.isXmlElement = _predicates.isXmlElement;
|
|
54
59
|
exports.isDefinitionsElement = _predicates.isDefinitionsElement;
|
|
55
60
|
exports.isParametersDefinitionsElement = _predicates.isParametersDefinitionsElement;
|
package/cjs/predicates.cjs
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.isXmlElement = exports.isTagElement = exports.isSwaggerVersionElement = exports.isSwaggerElement = exports.isSecuritySchemeElement = exports.isSecurityRequirementElement = exports.isSecurityDefinitionsElement = exports.isScopesElement = exports.isSchemaElement = exports.isResponsesElement = exports.isResponsesDefinitionsElement = exports.isResponseElement = exports.isReferenceElement = exports.isPathsElement = exports.isPathItemElement = exports.isParametersDefinitionsElement = exports.isParameterElement = exports.isOperationElement = exports.isLicenseElement = exports.isItemsElement = exports.isInfoElement = exports.isHeadersElement = exports.isHeaderElement = exports.isExternalDocumentationElement = exports.isExampleElement = exports.isDefinitionsElement = exports.isContactElement = void 0;
|
|
5
|
+
exports.isXmlElement = exports.isTagElement = exports.isSwaggerVersionElement = exports.isSwaggerElement = exports.isSecuritySchemeElement = exports.isSecurityRequirementElement = exports.isSecurityDefinitionsElement = exports.isScopesElement = exports.isSchemaElement = exports.isResponsesElement = exports.isResponsesDefinitionsElement = exports.isResponseElement = exports.isReferenceElementExternal = exports.isReferenceElement = exports.isPathsElement = exports.isPathItemElementExternal = exports.isPathItemElement = exports.isParametersDefinitionsElement = exports.isParameterElement = exports.isOperationElement = exports.isLicenseElement = exports.isJSONReferenceElementExternal = exports.isItemsElement = exports.isInfoElement = exports.isHeadersElement = exports.isHeaderElement = exports.isExternalDocumentationElement = exports.isExampleElement = exports.isDefinitionsElement = exports.isContactElement = void 0;
|
|
6
6
|
var _apidomCore = require("@swagger-api/apidom-core");
|
|
7
|
+
var _apidomNsJsonSchemaDraft = require("@swagger-api/apidom-ns-json-schema-draft-4");
|
|
7
8
|
var _Swagger = _interopRequireDefault(require("./elements/Swagger.cjs"));
|
|
8
9
|
var _SwaggerVersion = _interopRequireDefault(require("./elements/SwaggerVersion.cjs"));
|
|
9
10
|
var _Info = _interopRequireDefault(require("./elements/Info.cjs"));
|
|
@@ -80,6 +81,17 @@ const isPathItemElement = exports.isPathItemElement = (0, _apidomCore.createPred
|
|
|
80
81
|
}) => {
|
|
81
82
|
return element => element instanceof _PathItem.default || hasBasicElementProps(element) && isElementType('pathItem', element) && primitiveEq('object', element);
|
|
82
83
|
});
|
|
84
|
+
const isPathItemElementExternal = element => {
|
|
85
|
+
if (!isPathItemElement(element)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
if (!(0, _apidomCore.isStringElement)(element.$ref)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
const value = (0, _apidomCore.toValue)(element.$ref);
|
|
92
|
+
return typeof value === 'string' && value.length > 0 && !value.startsWith('#');
|
|
93
|
+
};
|
|
94
|
+
exports.isPathItemElementExternal = isPathItemElementExternal;
|
|
83
95
|
const isOperationElement = exports.isOperationElement = (0, _apidomCore.createPredicate)(({
|
|
84
96
|
hasBasicElementProps,
|
|
85
97
|
isElementType,
|
|
@@ -157,6 +169,17 @@ const isReferenceElement = exports.isReferenceElement = (0, _apidomCore.createPr
|
|
|
157
169
|
}) => {
|
|
158
170
|
return element => element instanceof _Reference.default || hasBasicElementProps(element) && isElementType('reference', element) && primitiveEq('object', element);
|
|
159
171
|
});
|
|
172
|
+
const isReferenceElementExternal = element => {
|
|
173
|
+
if (!isReferenceElement(element)) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
if (!(0, _apidomCore.isStringElement)(element.$ref)) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
const value = (0, _apidomCore.toValue)(element.$ref);
|
|
180
|
+
return typeof value === 'string' && value.length > 0 && !value.startsWith('#');
|
|
181
|
+
};
|
|
182
|
+
exports.isReferenceElementExternal = isReferenceElementExternal;
|
|
160
183
|
const isSchemaElement = exports.isSchemaElement = (0, _apidomCore.createPredicate)(({
|
|
161
184
|
hasBasicElementProps,
|
|
162
185
|
isElementType,
|
|
@@ -164,6 +187,17 @@ const isSchemaElement = exports.isSchemaElement = (0, _apidomCore.createPredicat
|
|
|
164
187
|
}) => {
|
|
165
188
|
return element => element instanceof _Schema.default || hasBasicElementProps(element) && isElementType('schema', element) && primitiveEq('object', element);
|
|
166
189
|
});
|
|
190
|
+
const isJSONReferenceElementExternal = element => {
|
|
191
|
+
if (!(0, _apidomNsJsonSchemaDraft.isJSONReferenceElement)(element)) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
if (!(0, _apidomCore.isStringElement)(element.$ref)) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
const value = (0, _apidomCore.toValue)(element.$ref);
|
|
198
|
+
return typeof value === 'string' && value.length > 0 && !value.startsWith('#');
|
|
199
|
+
};
|
|
200
|
+
exports.isJSONReferenceElementExternal = isJSONReferenceElementExternal;
|
|
167
201
|
const isXmlElement = exports.isXmlElement = (0, _apidomCore.createPredicate)(({
|
|
168
202
|
hasBasicElementProps,
|
|
169
203
|
isElementType,
|
|
@@ -327,39 +327,28 @@ const findElementFactory = (ancestor, keyName) => {
|
|
|
327
327
|
const keyMapping = schema[elementType] || schema[(0, _apidomCore.toValue)(ancestor.classes.first)];
|
|
328
328
|
return typeof keyMapping === 'undefined' ? undefined : Object.prototype.hasOwnProperty.call(keyMapping, '[key: *]') ? keyMapping['[key: *]'] : keyMapping[keyName];
|
|
329
329
|
};
|
|
330
|
-
const plugin = () => () => {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
context: ancestor
|
|
345
|
-
}, undefined, (0, _apidomCore.cloneDeep)(originalValue.meta), (0, _apidomCore.cloneDeep)(originalValue.attributes)), (0, _apidomCore.cloneDeep)(element.meta), (0, _apidomCore.cloneDeep)(element.attributes));
|
|
346
|
-
},
|
|
347
|
-
StringElement(element, ...rest) {
|
|
348
|
-
if (!isEmptyElement(element)) return undefined;
|
|
349
|
-
const [,,, ancestors] = rest;
|
|
350
|
-
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
|
|
351
|
-
|
|
352
|
-
// we're only interested in empty elements in ArrayElements
|
|
353
|
-
if (!(0, _apidomCore.isArrayElement)(ancestor)) return undefined;
|
|
354
|
-
const elementFactory = findElementFactory(ancestor, '<*>');
|
|
355
|
-
|
|
356
|
-
// no element factory found
|
|
357
|
-
if (typeof elementFactory === 'undefined') return undefined;
|
|
358
|
-
return elementFactory.call({
|
|
359
|
-
context: element
|
|
360
|
-
}, undefined, (0, _apidomCore.cloneDeep)(element.meta), (0, _apidomCore.cloneDeep)(element.attributes));
|
|
330
|
+
const plugin = () => () => ({
|
|
331
|
+
visitor: {
|
|
332
|
+
StringElement(element, key, parent, path, ancestors) {
|
|
333
|
+
if (!isEmptyElement(element)) return undefined;
|
|
334
|
+
const lineage = [...ancestors, parent].filter(_apidomCore.isElement);
|
|
335
|
+
const parentElement = lineage[lineage.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
|
|
336
|
+
let elementFactory;
|
|
337
|
+
let context;
|
|
338
|
+
if ((0, _apidomCore.isArrayElement)(parentElement)) {
|
|
339
|
+
context = element;
|
|
340
|
+
elementFactory = findElementFactory(parentElement, '<*>');
|
|
341
|
+
} else if ((0, _apidomCore.isMemberElement)(parentElement)) {
|
|
342
|
+
context = lineage[lineage.length - 2]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
|
|
343
|
+
elementFactory = findElementFactory(context, (0, _apidomCore.toValue)(parentElement.key));
|
|
361
344
|
}
|
|
345
|
+
|
|
346
|
+
// no element factory found
|
|
347
|
+
if (typeof elementFactory !== 'function') return undefined;
|
|
348
|
+
return elementFactory.call({
|
|
349
|
+
context
|
|
350
|
+
}, undefined, (0, _apidomCore.cloneDeep)(element.meta), (0, _apidomCore.cloneDeep)(element.attributes));
|
|
362
351
|
}
|
|
363
|
-
}
|
|
364
|
-
};
|
|
352
|
+
}
|
|
353
|
+
});
|
|
365
354
|
var _default = exports.default = plugin;
|
|
@@ -15,22 +15,14 @@ var _visitor = require("../../traversal/visitor.cjs");
|
|
|
15
15
|
*/
|
|
16
16
|
const SpecificationVisitor = (0, _stampit.default)(_Visitor.default, {
|
|
17
17
|
props: {
|
|
18
|
-
passingOptionsNames: ['specObj', 'openApiGenericElement', 'openApiSemanticElement'],
|
|
19
18
|
specObj: null,
|
|
20
|
-
|
|
21
|
-
openApiSemanticElement: null
|
|
19
|
+
passingOptionsNames: ['specObj']
|
|
22
20
|
},
|
|
23
21
|
init({
|
|
24
|
-
// @ts-
|
|
25
|
-
specObj = this.specObj
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
openApiGenericElement = this.openApiGenericElement,
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
openApiSemanticElement = this.openApiSemanticElement
|
|
22
|
+
// @ts-ignoreh
|
|
23
|
+
specObj = this.specObj
|
|
30
24
|
}) {
|
|
31
25
|
this.specObj = specObj;
|
|
32
|
-
this.openApiGenericElement = openApiGenericElement;
|
|
33
|
-
this.openApiSemanticElement = openApiSemanticElement;
|
|
34
26
|
},
|
|
35
27
|
methods: {
|
|
36
28
|
retrievePassingOptions() {
|