@swagger-api/apidom-ns-openapi-2 0.83.0 → 0.85.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 +13 -0
- package/cjs/index.cjs +2 -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 +7763 -7595
- package/dist/apidom-ns-openapi-2.browser.min.js +1 -1
- package/es/index.mjs +1 -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 +3 -4
package/es/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { isRefElement, isLinkElement as isLinkPrimitiveElement, isMemberElement, isObjectElement, isArrayElement, isBooleanElement, isNullElement, isElement, isNumberElement, isStringElement } from '@swagger-api/apidom-core';
|
|
2
|
-
export { isJSONReferenceElement, JSONReferenceElement } from '@swagger-api/apidom-ns-json-schema-draft-4';
|
|
2
|
+
export { isJSONReferenceElement, isJSONReferenceLikeElement, JSONReferenceElement } from '@swagger-api/apidom-ns-json-schema-draft-4';
|
|
3
3
|
export { default as mediaTypes, OpenAPIMediaTypes } from "./media-types.mjs"; // eslint-disable-next-line no-restricted-exports
|
|
4
4
|
export { default } from "./namespace.mjs";
|
|
5
5
|
export { default as refractorPluginReplaceEmptyElement } from "./refractor/plugins/replace-empty-element.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArrayElement, ObjectElement, isStringElement, isElement, isMemberElement, isArrayElement, includesClasses, cloneDeep, toValue } from '@swagger-api/apidom-core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* OpenAPI 2.0 specification elements.
|
|
@@ -319,39 +319,28 @@ const findElementFactory = (ancestor, keyName) => {
|
|
|
319
319
|
const keyMapping = schema[elementType] || schema[toValue(ancestor.classes.first)];
|
|
320
320
|
return typeof keyMapping === 'undefined' ? undefined : Object.prototype.hasOwnProperty.call(keyMapping, '[key: *]') ? keyMapping['[key: *]'] : keyMapping[keyName];
|
|
321
321
|
};
|
|
322
|
-
const plugin = () => () => {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
context: ancestor
|
|
337
|
-
}, undefined, cloneDeep(originalValue.meta), cloneDeep(originalValue.attributes)), cloneDeep(element.meta), cloneDeep(element.attributes));
|
|
338
|
-
},
|
|
339
|
-
StringElement(element, ...rest) {
|
|
340
|
-
if (!isEmptyElement(element)) return undefined;
|
|
341
|
-
const [,,, ancestors] = rest;
|
|
342
|
-
const ancestor = ancestors[ancestors.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
|
|
343
|
-
|
|
344
|
-
// we're only interested in empty elements in ArrayElements
|
|
345
|
-
if (!isArrayElement(ancestor)) return undefined;
|
|
346
|
-
const elementFactory = findElementFactory(ancestor, '<*>');
|
|
347
|
-
|
|
348
|
-
// no element factory found
|
|
349
|
-
if (typeof elementFactory === 'undefined') return undefined;
|
|
350
|
-
return elementFactory.call({
|
|
351
|
-
context: element
|
|
352
|
-
}, undefined, cloneDeep(element.meta), cloneDeep(element.attributes));
|
|
322
|
+
const plugin = () => () => ({
|
|
323
|
+
visitor: {
|
|
324
|
+
StringElement(element, key, parent, path, ancestors) {
|
|
325
|
+
if (!isEmptyElement(element)) return undefined;
|
|
326
|
+
const lineage = [...ancestors, parent].filter(isElement);
|
|
327
|
+
const parentElement = lineage[lineage.length - 1]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
|
|
328
|
+
let elementFactory;
|
|
329
|
+
let context;
|
|
330
|
+
if (isArrayElement(parentElement)) {
|
|
331
|
+
context = element;
|
|
332
|
+
elementFactory = findElementFactory(parentElement, '<*>');
|
|
333
|
+
} else if (isMemberElement(parentElement)) {
|
|
334
|
+
context = lineage[lineage.length - 2]; // @TODO(vladimir.gorej@gmail.com): can be replaced by Array.prototype.at in future
|
|
335
|
+
elementFactory = findElementFactory(context, toValue(parentElement.key));
|
|
353
336
|
}
|
|
337
|
+
|
|
338
|
+
// no element factory found
|
|
339
|
+
if (typeof elementFactory !== 'function') return undefined;
|
|
340
|
+
return elementFactory.call({
|
|
341
|
+
context
|
|
342
|
+
}, undefined, cloneDeep(element.meta), cloneDeep(element.attributes));
|
|
354
343
|
}
|
|
355
|
-
}
|
|
356
|
-
};
|
|
344
|
+
}
|
|
345
|
+
});
|
|
357
346
|
export default plugin;
|
|
@@ -10,22 +10,14 @@ import { keyMap, getNodeType } from "../../traversal/visitor.mjs";
|
|
|
10
10
|
*/
|
|
11
11
|
const SpecificationVisitor = stampit(Visitor, {
|
|
12
12
|
props: {
|
|
13
|
-
passingOptionsNames: ['specObj', 'openApiGenericElement', 'openApiSemanticElement'],
|
|
14
13
|
specObj: null,
|
|
15
|
-
|
|
16
|
-
openApiSemanticElement: null
|
|
14
|
+
passingOptionsNames: ['specObj']
|
|
17
15
|
},
|
|
18
16
|
init({
|
|
19
|
-
// @ts-
|
|
20
|
-
specObj = this.specObj
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
openApiGenericElement = this.openApiGenericElement,
|
|
23
|
-
// @ts-ignore
|
|
24
|
-
openApiSemanticElement = this.openApiSemanticElement
|
|
17
|
+
// @ts-ignoreh
|
|
18
|
+
specObj = this.specObj
|
|
25
19
|
}) {
|
|
26
20
|
this.specObj = specObj;
|
|
27
|
-
this.openApiGenericElement = openApiGenericElement;
|
|
28
|
-
this.openApiSemanticElement = openApiSemanticElement;
|
|
29
21
|
},
|
|
30
22
|
methods: {
|
|
31
23
|
retrievePassingOptions() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swagger-api/apidom-ns-openapi-2",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.85.0",
|
|
4
4
|
"description": "OpenAPI 2.0 namespace for ApiDOM.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"license": "Apache-2.0",
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/runtime-corejs3": "^7.20.7",
|
|
45
|
-
"@swagger-api/apidom-core": "^0.
|
|
46
|
-
"@swagger-api/apidom-error": "^0.
|
|
47
|
-
"@swagger-api/apidom-ns-json-schema-draft-4": "^0.
|
|
45
|
+
"@swagger-api/apidom-core": "^0.85.0",
|
|
46
|
+
"@swagger-api/apidom-error": "^0.85.0",
|
|
47
|
+
"@swagger-api/apidom-ns-json-schema-draft-4": "^0.85.0",
|
|
48
48
|
"@types/ramda": "~0.29.6",
|
|
49
|
-
"ramda": "~0.29.
|
|
49
|
+
"ramda": "~0.29.1",
|
|
50
50
|
"ramda-adjunct": "^4.1.1",
|
|
51
51
|
"stampit": "^4.3.2"
|
|
52
52
|
},
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"README.md",
|
|
61
61
|
"CHANGELOG.md"
|
|
62
62
|
],
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "beedab14f203c2b029ff83d4c6532669b0783aa1"
|
|
64
64
|
}
|
package/types/dist.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="@swagger-api/apidom-core/types/minim" />
|
|
2
2
|
import * as _swagger_api_apidom_core from '@swagger-api/apidom-core';
|
|
3
|
-
import { MediaTypes, NamespacePluginOptions,
|
|
3
|
+
import { MediaTypes, NamespacePluginOptions, StringElement, Element, Meta, Attributes, ObjectElement, ArrayElement, BooleanElement, NumberElement, MemberElement } from '@swagger-api/apidom-core';
|
|
4
4
|
export { isArrayElement, isBooleanElement, isElement, isLinkElement as isLinkPrimitiveElement, isMemberElement, isNullElement, isNumberElement, isObjectElement, isRefElement, isStringElement } from '@swagger-api/apidom-core';
|
|
5
5
|
import { JSONSchemaElement, JSONReferenceElement, MediaElement } from '@swagger-api/apidom-ns-json-schema-draft-4';
|
|
6
|
-
export { JSONReferenceElement, isJSONReferenceElement } from '@swagger-api/apidom-ns-json-schema-draft-4';
|
|
6
|
+
export { JSONReferenceElement, isJSONReferenceElement, isJSONReferenceLikeElement } from '@swagger-api/apidom-ns-json-schema-draft-4';
|
|
7
7
|
import * as minim from 'minim';
|
|
8
8
|
import * as stampit from 'stampit';
|
|
9
9
|
import stampit__default from 'stampit';
|
|
@@ -22,8 +22,7 @@ declare const openApi2: {
|
|
|
22
22
|
|
|
23
23
|
declare const plugin: () => () => {
|
|
24
24
|
visitor: {
|
|
25
|
-
|
|
26
|
-
StringElement(element: StringElement, ...rest: any): any;
|
|
25
|
+
StringElement(element: StringElement, key: any, parent: any, path: any, ancestors: any[]): any;
|
|
27
26
|
};
|
|
28
27
|
};
|
|
29
28
|
|