@swagger-api/apidom-ns-openapi-2 0.93.0 → 0.94.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 +4 -0
- package/cjs/refractor/index.cjs +5 -7
- package/cjs/refractor/visitors/FallbackVisitor.cjs +6 -8
- package/cjs/refractor/visitors/SpecificationExtensionVisitor.cjs +6 -9
- package/cjs/refractor/visitors/SpecificationVisitor.cjs +59 -61
- package/cjs/refractor/visitors/Visitor.cjs +12 -13
- package/cjs/refractor/visitors/generics/AlternatingVisitor.cjs +20 -16
- package/cjs/refractor/visitors/generics/FixedFieldsVisitor.cjs +44 -44
- package/cjs/refractor/visitors/generics/MapVisitor.cjs +5 -5
- package/cjs/refractor/visitors/generics/MixedFieldsVisitor.cjs +35 -30
- package/cjs/refractor/visitors/generics/PatternedFieldsVisitor.cjs +48 -46
- package/cjs/refractor/visitors/open-api-2/BasePathVisitor.cjs +6 -10
- package/cjs/refractor/visitors/open-api-2/ConsumesVisitor.cjs +8 -10
- package/cjs/refractor/visitors/open-api-2/HostVisitor.cjs +6 -10
- package/cjs/refractor/visitors/open-api-2/ProducesVisitor.cjs +8 -10
- package/cjs/refractor/visitors/open-api-2/SchemesVisitor.cjs +8 -10
- package/cjs/refractor/visitors/open-api-2/SecurityVisitor.cjs +15 -16
- package/cjs/refractor/visitors/open-api-2/SwaggerVisitor.cjs +10 -12
- package/cjs/refractor/visitors/open-api-2/TagsVisitor.cjs +16 -17
- package/cjs/refractor/visitors/open-api-2/contact/index.cjs +8 -9
- package/cjs/refractor/visitors/open-api-2/definitions/index.cjs +18 -20
- package/cjs/refractor/visitors/open-api-2/example/index.cjs +7 -8
- package/cjs/refractor/visitors/open-api-2/external-documentation/index.cjs +7 -8
- package/cjs/refractor/visitors/open-api-2/header/index.cjs +8 -9
- package/cjs/refractor/visitors/open-api-2/headers/index.cjs +7 -8
- package/cjs/refractor/visitors/open-api-2/index.cjs +8 -9
- package/cjs/refractor/visitors/open-api-2/info/VersionVisitor.cjs +7 -11
- package/cjs/refractor/visitors/open-api-2/info/index.cjs +8 -9
- package/cjs/refractor/visitors/open-api-2/items/index.cjs +10 -9
- package/cjs/refractor/visitors/open-api-2/license/index.cjs +8 -9
- package/cjs/refractor/visitors/open-api-2/operation/ConsumesVisitor.cjs +8 -10
- package/cjs/refractor/visitors/open-api-2/operation/ParametersVisitor.cjs +18 -19
- package/cjs/refractor/visitors/open-api-2/operation/ProducesVisitor.cjs +8 -10
- package/cjs/refractor/visitors/open-api-2/operation/SchemesVisitor.cjs +8 -10
- package/cjs/refractor/visitors/open-api-2/operation/SecurityVisitor.cjs +15 -16
- package/cjs/refractor/visitors/open-api-2/operation/TagsVisitor.cjs +8 -10
- package/cjs/refractor/visitors/open-api-2/operation/index.cjs +6 -7
- package/cjs/refractor/visitors/open-api-2/parameter/index.cjs +8 -9
- package/cjs/refractor/visitors/open-api-2/parameters-definitions/index.cjs +6 -7
- package/cjs/refractor/visitors/open-api-2/path-item/$RefVisitor.cjs +6 -10
- package/cjs/refractor/visitors/open-api-2/path-item/ParametersVisitor.cjs +18 -19
- package/cjs/refractor/visitors/open-api-2/path-item/index.cjs +21 -23
- package/cjs/refractor/visitors/open-api-2/paths/index.cjs +21 -22
- package/cjs/refractor/visitors/open-api-2/reference/$RefVisitor.cjs +6 -10
- package/cjs/refractor/visitors/open-api-2/reference/index.cjs +14 -18
- package/cjs/refractor/visitors/open-api-2/response/index.cjs +8 -9
- package/cjs/refractor/visitors/open-api-2/responses/DefaultVisitor.cjs +16 -18
- package/cjs/refractor/visitors/open-api-2/responses/index.cjs +28 -29
- package/cjs/refractor/visitors/open-api-2/responses-definitions/index.cjs +6 -7
- package/cjs/refractor/visitors/open-api-2/schema/AllOfVisitor.cjs +1 -3
- package/cjs/refractor/visitors/open-api-2/schema/ItemsVisitor.cjs +1 -3
- package/cjs/refractor/visitors/open-api-2/schema/PropertiesVisitor.cjs +1 -3
- package/cjs/refractor/visitors/open-api-2/schema/SchemaOrJSONReferenceVisitor.cjs +1 -3
- package/cjs/refractor/visitors/open-api-2/schema/index.cjs +8 -9
- package/cjs/refractor/visitors/open-api-2/scopes/index.cjs +7 -8
- package/cjs/refractor/visitors/open-api-2/security-definitions/index.cjs +7 -7
- package/cjs/refractor/visitors/open-api-2/security-requirement/index.cjs +6 -7
- package/cjs/refractor/visitors/open-api-2/security-scheme/index.cjs +8 -9
- package/cjs/refractor/visitors/open-api-2/tag/index.cjs +8 -9
- package/cjs/refractor/visitors/open-api-2/xml/index.cjs +8 -9
- package/dist/apidom-ns-openapi-2.browser.js +3363 -3171
- package/dist/apidom-ns-openapi-2.browser.min.js +1 -1
- package/es/refractor/index.mjs +5 -7
- package/es/refractor/visitors/FallbackVisitor.mjs +5 -8
- package/es/refractor/visitors/SpecificationExtensionVisitor.mjs +6 -9
- package/es/refractor/visitors/SpecificationVisitor.mjs +59 -62
- package/es/refractor/visitors/Visitor.mjs +12 -12
- package/es/refractor/visitors/generics/AlternatingVisitor.mjs +20 -16
- package/es/refractor/visitors/generics/FixedFieldsVisitor.mjs +44 -44
- package/es/refractor/visitors/generics/MapVisitor.mjs +5 -5
- package/es/refractor/visitors/generics/MixedFieldsVisitor.mjs +35 -30
- package/es/refractor/visitors/generics/PatternedFieldsVisitor.mjs +48 -46
- package/es/refractor/visitors/open-api-2/BasePathVisitor.mjs +6 -10
- package/es/refractor/visitors/open-api-2/ConsumesVisitor.mjs +8 -10
- package/es/refractor/visitors/open-api-2/HostVisitor.mjs +6 -10
- package/es/refractor/visitors/open-api-2/ProducesVisitor.mjs +8 -10
- package/es/refractor/visitors/open-api-2/SchemesVisitor.mjs +8 -10
- package/es/refractor/visitors/open-api-2/SecurityVisitor.mjs +15 -16
- package/es/refractor/visitors/open-api-2/SwaggerVisitor.mjs +10 -12
- package/es/refractor/visitors/open-api-2/TagsVisitor.mjs +16 -17
- package/es/refractor/visitors/open-api-2/contact/index.mjs +8 -9
- package/es/refractor/visitors/open-api-2/definitions/index.mjs +18 -20
- package/es/refractor/visitors/open-api-2/example/index.mjs +7 -8
- package/es/refractor/visitors/open-api-2/external-documentation/index.mjs +7 -8
- package/es/refractor/visitors/open-api-2/header/index.mjs +8 -9
- package/es/refractor/visitors/open-api-2/headers/index.mjs +7 -8
- package/es/refractor/visitors/open-api-2/index.mjs +8 -9
- package/es/refractor/visitors/open-api-2/info/VersionVisitor.mjs +7 -11
- package/es/refractor/visitors/open-api-2/info/index.mjs +8 -9
- package/es/refractor/visitors/open-api-2/items/index.mjs +10 -9
- package/es/refractor/visitors/open-api-2/license/index.mjs +8 -9
- package/es/refractor/visitors/open-api-2/operation/ConsumesVisitor.mjs +8 -10
- package/es/refractor/visitors/open-api-2/operation/ParametersVisitor.mjs +18 -19
- package/es/refractor/visitors/open-api-2/operation/ProducesVisitor.mjs +8 -10
- package/es/refractor/visitors/open-api-2/operation/SchemesVisitor.mjs +8 -10
- package/es/refractor/visitors/open-api-2/operation/SecurityVisitor.mjs +15 -16
- package/es/refractor/visitors/open-api-2/operation/TagsVisitor.mjs +8 -10
- package/es/refractor/visitors/open-api-2/operation/index.mjs +6 -7
- package/es/refractor/visitors/open-api-2/parameter/index.mjs +8 -9
- package/es/refractor/visitors/open-api-2/parameters-definitions/index.mjs +6 -7
- package/es/refractor/visitors/open-api-2/path-item/$RefVisitor.mjs +6 -10
- package/es/refractor/visitors/open-api-2/path-item/ParametersVisitor.mjs +18 -19
- package/es/refractor/visitors/open-api-2/path-item/index.mjs +21 -23
- package/es/refractor/visitors/open-api-2/paths/index.mjs +21 -22
- package/es/refractor/visitors/open-api-2/reference/$RefVisitor.mjs +6 -10
- package/es/refractor/visitors/open-api-2/reference/index.mjs +14 -18
- package/es/refractor/visitors/open-api-2/response/index.mjs +8 -9
- package/es/refractor/visitors/open-api-2/responses/DefaultVisitor.mjs +16 -18
- package/es/refractor/visitors/open-api-2/responses/index.mjs +28 -29
- package/es/refractor/visitors/open-api-2/responses-definitions/index.mjs +6 -7
- package/es/refractor/visitors/open-api-2/schema/AllOfVisitor.mjs +1 -2
- package/es/refractor/visitors/open-api-2/schema/ItemsVisitor.mjs +1 -2
- package/es/refractor/visitors/open-api-2/schema/PropertiesVisitor.mjs +1 -2
- package/es/refractor/visitors/open-api-2/schema/SchemaOrJSONReferenceVisitor.mjs +1 -2
- package/es/refractor/visitors/open-api-2/schema/index.mjs +8 -9
- package/es/refractor/visitors/open-api-2/scopes/index.mjs +7 -8
- package/es/refractor/visitors/open-api-2/security-definitions/index.mjs +7 -7
- package/es/refractor/visitors/open-api-2/security-requirement/index.mjs +6 -7
- package/es/refractor/visitors/open-api-2/security-scheme/index.mjs +8 -9
- package/es/refractor/visitors/open-api-2/tag/index.mjs +8 -9
- package/es/refractor/visitors/open-api-2/xml/index.mjs +8 -9
- package/package.json +6 -6
- package/types/dist.d.ts +915 -513
package/es/refractor/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { invokeArgs } from 'ramda-adjunct';
|
|
2
1
|
import { visit, dereference, refract as baseRefract, dispatchRefractorPlugins } from '@swagger-api/apidom-core';
|
|
2
|
+
import { path } from 'ramda';
|
|
3
3
|
import specification from "./specification.mjs";
|
|
4
4
|
import { keyMap, getNodeType } from "../traversal/visitor.mjs";
|
|
5
5
|
import createToolbox from "./toolbox.mjs";
|
|
@@ -15,13 +15,11 @@ const refract = (value, {
|
|
|
15
15
|
* We don't allow consumers to hook into this translation.
|
|
16
16
|
* Though we allow consumers to define their onw plugins on already transformed ApiDOM.
|
|
17
17
|
*/
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
state: {
|
|
22
|
-
specObj: resolvedSpec
|
|
23
|
-
}
|
|
18
|
+
const RootVistorClass = path(specPath, resolvedSpec);
|
|
19
|
+
const rootVisitor = new RootVistorClass({
|
|
20
|
+
specObj: resolvedSpec
|
|
24
21
|
});
|
|
22
|
+
visit(element, rootVisitor);
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
25
|
* Running plugins visitors means extra single traversal === performance hit.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import stampit from 'stampit';
|
|
2
1
|
import { BREAK, cloneDeep } from '@swagger-api/apidom-core';
|
|
3
2
|
import Visitor from "./Visitor.mjs";
|
|
4
3
|
/**
|
|
@@ -7,12 +6,10 @@ import Visitor from "./Visitor.mjs";
|
|
|
7
6
|
* different Element is provided FallBackVisitor is responsible to assigning
|
|
8
7
|
* this Element as current element.
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return BREAK;
|
|
15
|
-
}
|
|
9
|
+
class FallbackVisitor extends Visitor {
|
|
10
|
+
enter(element) {
|
|
11
|
+
this.element = cloneDeep(element);
|
|
12
|
+
return BREAK;
|
|
16
13
|
}
|
|
17
|
-
}
|
|
14
|
+
}
|
|
18
15
|
export default FallbackVisitor;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import stampit from 'stampit';
|
|
2
1
|
import { BREAK, cloneDeep } from '@swagger-api/apidom-core';
|
|
3
2
|
import SpecificationVisitor from "./SpecificationVisitor.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return BREAK;
|
|
10
|
-
}
|
|
3
|
+
class SpecificationExtensionVisitor extends SpecificationVisitor {
|
|
4
|
+
MemberElement(memberElement) {
|
|
5
|
+
this.element = cloneDeep(memberElement);
|
|
6
|
+
this.element.classes.push('specification-extension');
|
|
7
|
+
return BREAK;
|
|
11
8
|
}
|
|
12
|
-
}
|
|
9
|
+
}
|
|
13
10
|
export default SpecificationExtensionVisitor;
|
|
@@ -1,74 +1,71 @@
|
|
|
1
|
-
import stampit from 'stampit';
|
|
2
1
|
import { pathSatisfies, path, pick } from 'ramda';
|
|
3
|
-
import { isFunction
|
|
2
|
+
import { isFunction } from 'ramda-adjunct';
|
|
4
3
|
import { visit, cloneDeep } from '@swagger-api/apidom-core';
|
|
5
|
-
import Visitor from "./Visitor.mjs";
|
|
6
4
|
import { keyMap, getNodeType } from "../../traversal/visitor.mjs";
|
|
5
|
+
import Visitor from "./Visitor.mjs";
|
|
6
|
+
import FallbackVisitor from "./FallbackVisitor.mjs";
|
|
7
7
|
/**
|
|
8
8
|
* This is a base Type for every visitor that does
|
|
9
9
|
* internal look-ups to retrieve other child visitors.
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// @ts-ignoreh
|
|
18
|
-
specObj = this.specObj
|
|
11
|
+
class SpecificationVisitor extends Visitor {
|
|
12
|
+
specObj;
|
|
13
|
+
passingOptionsNames = ['specObj'];
|
|
14
|
+
constructor({
|
|
15
|
+
specObj,
|
|
16
|
+
...rest
|
|
19
17
|
}) {
|
|
18
|
+
super({
|
|
19
|
+
...rest
|
|
20
|
+
});
|
|
20
21
|
this.specObj = specObj;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return Object.keys(fixedFields);
|
|
30
|
-
}
|
|
31
|
-
return [];
|
|
32
|
-
},
|
|
33
|
-
retrieveVisitor(specPath) {
|
|
34
|
-
if (pathSatisfies(isFunction, ['visitors', ...specPath], this.specObj)) {
|
|
35
|
-
return path(['visitors', ...specPath], this.specObj);
|
|
36
|
-
}
|
|
37
|
-
return path(['visitors', ...specPath, '$visitor'], this.specObj);
|
|
38
|
-
},
|
|
39
|
-
retrieveVisitorInstance(specPath, options = {}) {
|
|
40
|
-
const passingOpts = this.retrievePassingOptions();
|
|
41
|
-
return this.retrieveVisitor(specPath)({
|
|
42
|
-
...passingOpts,
|
|
43
|
-
...options
|
|
44
|
-
});
|
|
45
|
-
},
|
|
46
|
-
toRefractedElement(specPath, element, options = {}) {
|
|
47
|
-
/**
|
|
48
|
-
* This is `Visitor shortcut`: mechanism for short circuiting the traversal and replacing
|
|
49
|
-
* it by basic node cloning.
|
|
50
|
-
*
|
|
51
|
-
* Visiting the element is equivalent to cloning it if the prototype of a visitor
|
|
52
|
-
* is the same as the prototype of FallbackVisitor. If that's the case, we can avoid
|
|
53
|
-
* bootstrapping the traversal cycle for fields that don't require any special visiting.
|
|
54
|
-
*/
|
|
55
|
-
const visitor = this.retrieveVisitorInstance(specPath, options);
|
|
56
|
-
const visitorPrototype = Object.getPrototypeOf(visitor);
|
|
57
|
-
if (isUndefined(this.fallbackVisitorPrototype)) {
|
|
58
|
-
this.fallbackVisitorPrototype = Object.getPrototypeOf(this.retrieveVisitorInstance(['value']));
|
|
59
|
-
}
|
|
60
|
-
if (this.fallbackVisitorPrototype === visitorPrototype) {
|
|
61
|
-
return cloneDeep(element);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// standard processing continues
|
|
65
|
-
visit(element, visitor, {
|
|
66
|
-
keyMap,
|
|
67
|
-
nodeTypeGetter: getNodeType,
|
|
68
|
-
...options
|
|
69
|
-
});
|
|
70
|
-
return visitor.element;
|
|
22
|
+
}
|
|
23
|
+
retrievePassingOptions() {
|
|
24
|
+
return pick(this.passingOptionsNames, this);
|
|
25
|
+
}
|
|
26
|
+
retrieveFixedFields(specPath) {
|
|
27
|
+
const fixedFields = path(['visitors', ...specPath, 'fixedFields'], this.specObj);
|
|
28
|
+
if (typeof fixedFields === 'object' && fixedFields !== null) {
|
|
29
|
+
return Object.keys(fixedFields);
|
|
71
30
|
}
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
retrieveVisitor(specPath) {
|
|
34
|
+
if (pathSatisfies(isFunction, ['visitors', ...specPath], this.specObj)) {
|
|
35
|
+
return path(['visitors', ...specPath], this.specObj);
|
|
36
|
+
}
|
|
37
|
+
return path(['visitors', ...specPath, '$visitor'], this.specObj);
|
|
38
|
+
}
|
|
39
|
+
retrieveVisitorInstance(specPath, options = {}) {
|
|
40
|
+
const passingOpts = this.retrievePassingOptions();
|
|
41
|
+
const VisitorClz = this.retrieveVisitor(specPath);
|
|
42
|
+
const visitorOpts = {
|
|
43
|
+
...passingOpts,
|
|
44
|
+
...options
|
|
45
|
+
};
|
|
46
|
+
return new VisitorClz(visitorOpts);
|
|
47
|
+
}
|
|
48
|
+
toRefractedElement(specPath, element, options = {}) {
|
|
49
|
+
/**
|
|
50
|
+
* This is `Visitor shortcut`: mechanism for short circuiting the traversal and replacing
|
|
51
|
+
* it by basic node cloning.
|
|
52
|
+
*
|
|
53
|
+
* Visiting the element is equivalent to cloning it if the prototype of a visitor
|
|
54
|
+
* is the same as the prototype of FallbackVisitor. If that's the case, we can avoid
|
|
55
|
+
* bootstrapping the traversal cycle for fields that don't require any special visiting.
|
|
56
|
+
*/
|
|
57
|
+
const visitor = this.retrieveVisitorInstance(specPath, options);
|
|
58
|
+
if (visitor instanceof FallbackVisitor && (visitor === null || visitor === void 0 ? void 0 : visitor.constructor) === FallbackVisitor) {
|
|
59
|
+
return cloneDeep(element);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
visit(element, visitor, {
|
|
64
|
+
keyMap,
|
|
65
|
+
nodeTypeGetter: getNodeType,
|
|
66
|
+
...options
|
|
67
|
+
});
|
|
68
|
+
return visitor.element;
|
|
72
69
|
}
|
|
73
|
-
}
|
|
70
|
+
}
|
|
74
71
|
export default SpecificationVisitor;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import stampit from 'stampit';
|
|
2
1
|
import { hasElementSourceMap } from '@swagger-api/apidom-core';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
class Visitor {
|
|
3
|
+
element;
|
|
4
|
+
constructor(options = {}) {
|
|
5
|
+
Object.assign(this, options);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line class-methods-use-this
|
|
9
|
+
copyMetaAndAttributes(from, to) {
|
|
10
|
+
// copy sourcemaps
|
|
11
|
+
if (hasElementSourceMap(from)) {
|
|
12
|
+
to.meta.set('sourceMap', from.meta.get('sourceMap'));
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
export default Visitor;
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import stampit from 'stampit';
|
|
2
1
|
import { ifElse, always } from 'ramda';
|
|
3
2
|
import { dispatch, stubUndefined } from 'ramda-adjunct';
|
|
4
3
|
import { BREAK } from '@swagger-api/apidom-core';
|
|
5
4
|
import SpecificationVisitor from "../SpecificationVisitor.mjs";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const specPath = dispatch(functions)(element);
|
|
17
|
-
this.element = this.toRefractedElement(specPath, element);
|
|
18
|
-
return BREAK;
|
|
19
|
-
}
|
|
5
|
+
class AlternatingVisitor extends SpecificationVisitor {
|
|
6
|
+
alternator;
|
|
7
|
+
constructor({
|
|
8
|
+
alternator,
|
|
9
|
+
...rest
|
|
10
|
+
}) {
|
|
11
|
+
super({
|
|
12
|
+
...rest
|
|
13
|
+
});
|
|
14
|
+
this.alternator = alternator || [];
|
|
20
15
|
}
|
|
21
|
-
|
|
16
|
+
enter(element) {
|
|
17
|
+
const functions = this.alternator.map(({
|
|
18
|
+
predicate,
|
|
19
|
+
specPath
|
|
20
|
+
}) => ifElse(predicate, always(specPath), stubUndefined));
|
|
21
|
+
const specPath = dispatch(functions)(element);
|
|
22
|
+
this.element = this.toRefractedElement(specPath, element);
|
|
23
|
+
return BREAK;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
22
26
|
export default AlternatingVisitor;
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import stampit from 'stampit';
|
|
2
|
-
import { noop } from 'ramda-adjunct';
|
|
3
1
|
import { isStringElement, MemberElement, BREAK, cloneDeep, toValue } from '@swagger-api/apidom-core';
|
|
4
2
|
import SpecificationVisitor from "../SpecificationVisitor.mjs";
|
|
5
3
|
import { isSwaggerExtension } from "../../predicates.mjs";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
specificationExtensionPredicate = this.specificationExtensionPredicate
|
|
22
|
-
} = {}) {
|
|
4
|
+
class FixedFieldsVisitor extends SpecificationVisitor {
|
|
5
|
+
specPath;
|
|
6
|
+
ignoredFields;
|
|
7
|
+
canSupportSpecificationExtensions = true;
|
|
8
|
+
specificationExtensionPredicate = isSwaggerExtension;
|
|
9
|
+
constructor({
|
|
10
|
+
specPath,
|
|
11
|
+
ignoredFields,
|
|
12
|
+
canSupportSpecificationExtensions,
|
|
13
|
+
specificationExtensionPredicate,
|
|
14
|
+
...rest
|
|
15
|
+
}) {
|
|
16
|
+
super({
|
|
17
|
+
...rest
|
|
18
|
+
});
|
|
23
19
|
this.specPath = specPath;
|
|
24
|
-
this.ignoredFields = ignoredFields;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
methods: {
|
|
29
|
-
ObjectElement(objectElement) {
|
|
30
|
-
const specPath = this.specPath(objectElement);
|
|
31
|
-
const fields = this.retrieveFixedFields(specPath);
|
|
32
|
-
objectElement.forEach((value, key, memberElement) => {
|
|
33
|
-
if (isStringElement(key) && fields.includes(toValue(key)) && !this.ignoredFields.includes(toValue(key))) {
|
|
34
|
-
const fixedFieldElement = this.toRefractedElement([...specPath, 'fixedFields', toValue(key)], value);
|
|
35
|
-
const newMemberElement = new MemberElement(cloneDeep(key), fixedFieldElement);
|
|
36
|
-
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
37
|
-
newMemberElement.classes.push('fixed-field');
|
|
38
|
-
this.element.content.push(newMemberElement);
|
|
39
|
-
} else if (this.canSupportSpecificationExtensions && this.specificationExtensionPredicate(memberElement)) {
|
|
40
|
-
const extensionElement = this.toRefractedElement(['document', 'extension'], memberElement);
|
|
41
|
-
this.element.content.push(extensionElement);
|
|
42
|
-
} else if (!this.ignoredFields.includes(toValue(key))) {
|
|
43
|
-
this.element.content.push(cloneDeep(memberElement));
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
this.copyMetaAndAttributes(objectElement, this.element);
|
|
47
|
-
return BREAK;
|
|
20
|
+
this.ignoredFields = ignoredFields || [];
|
|
21
|
+
if (typeof canSupportSpecificationExtensions === 'boolean') {
|
|
22
|
+
this.canSupportSpecificationExtensions = canSupportSpecificationExtensions;
|
|
48
23
|
}
|
|
24
|
+
if (typeof specificationExtensionPredicate === 'function') {
|
|
25
|
+
this.specificationExtensionPredicate = specificationExtensionPredicate;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
ObjectElement(objectElement) {
|
|
29
|
+
const specPath = this.specPath(objectElement);
|
|
30
|
+
const fields = this.retrieveFixedFields(specPath);
|
|
31
|
+
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
objectElement.forEach((value, key, memberElement) => {
|
|
34
|
+
if (isStringElement(key) && fields.includes(toValue(key)) && !this.ignoredFields.includes(toValue(key))) {
|
|
35
|
+
const fixedFieldElement = this.toRefractedElement([...specPath, 'fixedFields', toValue(key)], value);
|
|
36
|
+
const newMemberElement = new MemberElement(cloneDeep(key), fixedFieldElement);
|
|
37
|
+
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
38
|
+
newMemberElement.classes.push('fixed-field');
|
|
39
|
+
this.element.content.push(newMemberElement);
|
|
40
|
+
} else if (this.canSupportSpecificationExtensions && this.specificationExtensionPredicate(memberElement)) {
|
|
41
|
+
const extensionElement = this.toRefractedElement(['document', 'extension'], memberElement);
|
|
42
|
+
this.element.content.push(extensionElement);
|
|
43
|
+
} else if (!this.ignoredFields.includes(toValue(key))) {
|
|
44
|
+
this.element.content.push(cloneDeep(memberElement));
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
this.copyMetaAndAttributes(objectElement, this.element);
|
|
48
|
+
return BREAK;
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|
|
51
51
|
export default FixedFieldsVisitor;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import stampit from 'stampit';
|
|
2
1
|
import { isNonEmptyString } from 'ramda-adjunct';
|
|
3
2
|
import PatternedFieldsVisitor from "./PatternedFieldsVisitor.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
class MapVisitor extends PatternedFieldsVisitor {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
super(options);
|
|
6
|
+
this.fieldPatternPredicate = isNonEmptyString;
|
|
7
7
|
}
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
9
|
export default MapVisitor;
|
|
@@ -1,37 +1,42 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Mixin } from 'ts-mixer';
|
|
2
2
|
import { difference } from 'ramda';
|
|
3
|
-
import { noop } from 'ramda-adjunct';
|
|
4
3
|
import { BREAK } from '@swagger-api/apidom-core';
|
|
5
4
|
import FixedFieldsVisitor from "./FixedFieldsVisitor.mjs";
|
|
6
5
|
import PatternedFieldsVisitor from "./PatternedFieldsVisitor.mjs";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
6
|
+
class MixedFieldsVisitor extends Mixin(FixedFieldsVisitor, PatternedFieldsVisitor) {
|
|
7
|
+
specPathFixedFields;
|
|
8
|
+
specPathPatternedFields;
|
|
9
|
+
constructor({
|
|
10
|
+
specPathFixedFields,
|
|
11
|
+
specPathPatternedFields,
|
|
12
|
+
...rest
|
|
13
|
+
}) {
|
|
14
|
+
super({
|
|
15
|
+
...rest
|
|
16
|
+
});
|
|
17
|
+
this.specPathFixedFields = specPathFixedFields;
|
|
18
|
+
this.specPathPatternedFields = specPathPatternedFields;
|
|
19
|
+
}
|
|
20
|
+
ObjectElement(objectElement) {
|
|
21
|
+
const {
|
|
22
|
+
specPath,
|
|
23
|
+
ignoredFields
|
|
24
|
+
} = this;
|
|
25
|
+
try {
|
|
26
|
+
this.specPath = this.specPathFixedFields;
|
|
27
|
+
const fixedFields = this.retrieveFixedFields(this.specPath(objectElement));
|
|
28
|
+
// let FixedFieldsVisitor only process fixed fields and leave rest to PatternedFieldsVisitor
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
this.ignoredFields = [...ignoredFields, ...difference(objectElement.keys(), fixedFields)];
|
|
31
|
+
FixedFieldsVisitor.prototype.ObjectElement.call(this, objectElement);
|
|
32
|
+
this.specPath = this.specPathPatternedFields;
|
|
33
|
+
this.ignoredFields = fixedFields;
|
|
34
|
+
PatternedFieldsVisitor.prototype.ObjectElement.call(this, objectElement);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
this.specPath = specPath;
|
|
37
|
+
throw e;
|
|
34
38
|
}
|
|
39
|
+
return BREAK;
|
|
35
40
|
}
|
|
36
|
-
}
|
|
41
|
+
}
|
|
37
42
|
export default MixedFieldsVisitor;
|
|
@@ -1,53 +1,55 @@
|
|
|
1
|
-
import stampit from 'stampit';
|
|
2
1
|
import { F as stubFalse } from 'ramda';
|
|
3
|
-
import { noop } from 'ramda-adjunct';
|
|
4
2
|
import { MemberElement, BREAK, cloneDeep, toValue } from '@swagger-api/apidom-core';
|
|
5
3
|
import SpecificationVisitor from "../SpecificationVisitor.mjs";
|
|
6
4
|
import { isSwaggerExtension } from "../../predicates.mjs";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} = {}) {
|
|
5
|
+
class PatternedFieldsVisitor extends SpecificationVisitor {
|
|
6
|
+
specPath;
|
|
7
|
+
ignoredFields;
|
|
8
|
+
fieldPatternPredicate = stubFalse;
|
|
9
|
+
canSupportSpecificationExtensions = false;
|
|
10
|
+
specificationExtensionPredicate = isSwaggerExtension;
|
|
11
|
+
constructor({
|
|
12
|
+
specPath,
|
|
13
|
+
ignoredFields,
|
|
14
|
+
fieldPatternPredicate,
|
|
15
|
+
canSupportSpecificationExtensions,
|
|
16
|
+
specificationExtensionPredicate,
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
19
|
+
super({
|
|
20
|
+
...rest
|
|
21
|
+
});
|
|
25
22
|
this.specPath = specPath;
|
|
26
|
-
this.ignoredFields = ignoredFields;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
methods: {
|
|
31
|
-
ObjectElement(objectElement) {
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
objectElement.forEach((value, key, memberElement) => {
|
|
34
|
-
if (this.canSupportSpecificationExtensions && this.specificationExtensionPredicate(memberElement)) {
|
|
35
|
-
const extensionElement = this.toRefractedElement(['document', 'extension'], memberElement);
|
|
36
|
-
this.element.content.push(extensionElement);
|
|
37
|
-
} else if (!this.ignoredFields.includes(toValue(key)) && this.fieldPatternPredicate(toValue(key))) {
|
|
38
|
-
const specPath = this.specPath(value);
|
|
39
|
-
const patternedFieldElement = this.toRefractedElement(specPath, value);
|
|
40
|
-
const newMemberElement = new MemberElement(cloneDeep(key), patternedFieldElement);
|
|
41
|
-
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
42
|
-
newMemberElement.classes.push('patterned-field');
|
|
43
|
-
this.element.content.push(newMemberElement);
|
|
44
|
-
} else if (!this.ignoredFields.includes(toValue(key))) {
|
|
45
|
-
this.element.content.push(cloneDeep(memberElement));
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
this.copyMetaAndAttributes(objectElement, this.element);
|
|
49
|
-
return BREAK;
|
|
23
|
+
this.ignoredFields = ignoredFields || [];
|
|
24
|
+
if (typeof fieldPatternPredicate === 'function') {
|
|
25
|
+
this.fieldPatternPredicate = fieldPatternPredicate;
|
|
50
26
|
}
|
|
27
|
+
if (typeof canSupportSpecificationExtensions === 'boolean') {
|
|
28
|
+
this.canSupportSpecificationExtensions = canSupportSpecificationExtensions;
|
|
29
|
+
}
|
|
30
|
+
if (typeof specificationExtensionPredicate === 'function') {
|
|
31
|
+
this.specificationExtensionPredicate = specificationExtensionPredicate;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
ObjectElement(objectElement) {
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
objectElement.forEach((value, key, memberElement) => {
|
|
37
|
+
if (this.canSupportSpecificationExtensions && this.specificationExtensionPredicate(memberElement)) {
|
|
38
|
+
const extensionElement = this.toRefractedElement(['document', 'extension'], memberElement);
|
|
39
|
+
this.element.content.push(extensionElement);
|
|
40
|
+
} else if (!this.ignoredFields.includes(toValue(key)) && this.fieldPatternPredicate(toValue(key))) {
|
|
41
|
+
const specPath = this.specPath(value);
|
|
42
|
+
const patternedFieldElement = this.toRefractedElement(specPath, value);
|
|
43
|
+
const newMemberElement = new MemberElement(cloneDeep(key), patternedFieldElement);
|
|
44
|
+
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
45
|
+
newMemberElement.classes.push('patterned-field');
|
|
46
|
+
this.element.content.push(newMemberElement);
|
|
47
|
+
} else if (!this.ignoredFields.includes(toValue(key))) {
|
|
48
|
+
this.element.content.push(cloneDeep(memberElement));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
this.copyMetaAndAttributes(objectElement, this.element);
|
|
52
|
+
return BREAK;
|
|
51
53
|
}
|
|
52
|
-
}
|
|
53
|
-
export default
|
|
54
|
+
}
|
|
55
|
+
export default PatternedFieldsVisitor;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import stampit from 'stampit';
|
|
2
|
-
import { BREAK, cloneDeep } from '@swagger-api/apidom-core';
|
|
3
1
|
import FallbackVisitor from "../FallbackVisitor.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return BREAK;
|
|
10
|
-
}
|
|
2
|
+
class BasePathVisitor extends FallbackVisitor {
|
|
3
|
+
StringElement(stringElement) {
|
|
4
|
+
const result = super.enter(stringElement);
|
|
5
|
+
this.element.classes.push('swagger-base-path');
|
|
6
|
+
return result;
|
|
11
7
|
}
|
|
12
|
-
}
|
|
8
|
+
}
|
|
13
9
|
export default BasePathVisitor;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import stampit from 'stampit';
|
|
2
1
|
import { BREAK, cloneDeep } from '@swagger-api/apidom-core';
|
|
3
2
|
import SwaggerConsumesElement from "../../../elements/nces/SwaggerConsumes.mjs";
|
|
4
3
|
import FallbackVisitor from "../FallbackVisitor.mjs";
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
class ConsumesVisitor extends FallbackVisitor {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super(options);
|
|
7
7
|
this.element = new SwaggerConsumesElement();
|
|
8
|
-
},
|
|
9
|
-
methods: {
|
|
10
|
-
ArrayElement(arrayElement) {
|
|
11
|
-
this.element = this.element.concat(cloneDeep(arrayElement));
|
|
12
|
-
return BREAK;
|
|
13
|
-
}
|
|
14
8
|
}
|
|
15
|
-
|
|
9
|
+
ArrayElement(arrayElement) {
|
|
10
|
+
this.element = this.element.concat(cloneDeep(arrayElement));
|
|
11
|
+
return BREAK;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
16
14
|
export default ConsumesVisitor;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import stampit from 'stampit';
|
|
2
|
-
import { BREAK, cloneDeep } from '@swagger-api/apidom-core';
|
|
3
1
|
import FallbackVisitor from "../FallbackVisitor.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return BREAK;
|
|
10
|
-
}
|
|
2
|
+
class HostVisitor extends FallbackVisitor {
|
|
3
|
+
StringElement(stringElement) {
|
|
4
|
+
const result = super.enter(stringElement);
|
|
5
|
+
this.element.classes.push('swagger-host');
|
|
6
|
+
return result;
|
|
11
7
|
}
|
|
12
|
-
}
|
|
8
|
+
}
|
|
13
9
|
export default HostVisitor;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import stampit from 'stampit';
|
|
2
1
|
import { BREAK, cloneDeep } from '@swagger-api/apidom-core';
|
|
3
2
|
import SwaggerProducesElement from "../../../elements/nces/SwaggerProduces.mjs";
|
|
4
3
|
import FallbackVisitor from "../FallbackVisitor.mjs";
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
class ProducesVisitor extends FallbackVisitor {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super(options);
|
|
7
7
|
this.element = new SwaggerProducesElement();
|
|
8
|
-
},
|
|
9
|
-
methods: {
|
|
10
|
-
ArrayElement(arrayElement) {
|
|
11
|
-
this.element = this.element.concat(cloneDeep(arrayElement));
|
|
12
|
-
return BREAK;
|
|
13
|
-
}
|
|
14
8
|
}
|
|
15
|
-
|
|
9
|
+
ArrayElement(arrayElement) {
|
|
10
|
+
this.element = this.element.concat(cloneDeep(arrayElement));
|
|
11
|
+
return BREAK;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
16
14
|
export default ProducesVisitor;
|