@speclynx/apidom-ns-openapi-2 3.2.1 → 4.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 +4 -0
- package/dist/apidom-ns-openapi-2.browser.js +24 -20
- package/package.json +7 -7
- package/src/elements/Contact.cjs +0 -33
- package/src/elements/Contact.mjs +0 -30
- package/src/elements/Definitions.cjs +0 -15
- package/src/elements/Definitions.mjs +0 -12
- package/src/elements/Example.cjs +0 -15
- package/src/elements/Example.mjs +0 -12
- package/src/elements/ExternalDocumentation.cjs +0 -27
- package/src/elements/ExternalDocumentation.mjs +0 -24
- package/src/elements/Header.cjs +0 -185
- package/src/elements/Header.mjs +0 -182
- package/src/elements/Headers.cjs +0 -15
- package/src/elements/Headers.mjs +0 -12
- package/src/elements/Info.cjs +0 -52
- package/src/elements/Info.mjs +0 -48
- package/src/elements/Items.cjs +0 -190
- package/src/elements/Items.mjs +0 -187
- package/src/elements/License.cjs +0 -27
- package/src/elements/License.mjs +0 -24
- package/src/elements/Operation.cjs +0 -78
- package/src/elements/Operation.mjs +0 -74
- package/src/elements/Parameter.cjs +0 -230
- package/src/elements/Parameter.mjs +0 -226
- package/src/elements/ParametersDefinitions.cjs +0 -15
- package/src/elements/ParametersDefinitions.mjs +0 -12
- package/src/elements/PathItem.cjs +0 -69
- package/src/elements/PathItem.mjs +0 -65
- package/src/elements/Paths.cjs +0 -15
- package/src/elements/Paths.mjs +0 -12
- package/src/elements/Reference.cjs +0 -22
- package/src/elements/Reference.mjs +0 -19
- package/src/elements/Response.cjs +0 -39
- package/src/elements/Response.mjs +0 -35
- package/src/elements/Responses.cjs +0 -21
- package/src/elements/Responses.mjs +0 -17
- package/src/elements/ResponsesDefinitions.cjs +0 -15
- package/src/elements/ResponsesDefinitions.mjs +0 -12
- package/src/elements/Schema.cjs +0 -151
- package/src/elements/Schema.mjs +0 -147
- package/src/elements/Scopes.cjs +0 -15
- package/src/elements/Scopes.mjs +0 -12
- package/src/elements/SecurityDefinitions.cjs +0 -15
- package/src/elements/SecurityDefinitions.mjs +0 -12
- package/src/elements/SecurityRequirement.cjs +0 -15
- package/src/elements/SecurityRequirement.mjs +0 -12
- package/src/elements/SecurityScheme.cjs +0 -63
- package/src/elements/SecurityScheme.mjs +0 -60
- package/src/elements/Swagger.cjs +0 -106
- package/src/elements/Swagger.mjs +0 -102
- package/src/elements/SwaggerVersion.cjs +0 -17
- package/src/elements/SwaggerVersion.mjs +0 -14
- package/src/elements/Tag.cjs +0 -33
- package/src/elements/Tag.mjs +0 -29
- package/src/elements/Xml.cjs +0 -45
- package/src/elements/Xml.mjs +0 -42
- package/src/elements/nces/OperationConsumes.cjs +0 -16
- package/src/elements/nces/OperationConsumes.mjs +0 -13
- package/src/elements/nces/OperationParameters.cjs +0 -17
- package/src/elements/nces/OperationParameters.mjs +0 -14
- package/src/elements/nces/OperationProduces.cjs +0 -16
- package/src/elements/nces/OperationProduces.mjs +0 -13
- package/src/elements/nces/OperationSchemes.cjs +0 -16
- package/src/elements/nces/OperationSchemes.mjs +0 -13
- package/src/elements/nces/OperationSecurity.cjs +0 -17
- package/src/elements/nces/OperationSecurity.mjs +0 -14
- package/src/elements/nces/OperationTags.cjs +0 -17
- package/src/elements/nces/OperationTags.mjs +0 -14
- package/src/elements/nces/PathItemParameters.cjs +0 -17
- package/src/elements/nces/PathItemParameters.mjs +0 -14
- package/src/elements/nces/SwaggerConsumes.cjs +0 -16
- package/src/elements/nces/SwaggerConsumes.mjs +0 -13
- package/src/elements/nces/SwaggerProduces.cjs +0 -16
- package/src/elements/nces/SwaggerProduces.mjs +0 -13
- package/src/elements/nces/SwaggerSchemes.cjs +0 -16
- package/src/elements/nces/SwaggerSchemes.mjs +0 -13
- package/src/elements/nces/SwaggerSecurity.cjs +0 -17
- package/src/elements/nces/SwaggerSecurity.mjs +0 -14
- package/src/elements/nces/SwaggerTags.cjs +0 -16
- package/src/elements/nces/SwaggerTags.mjs +0 -13
- package/src/index.cjs +0 -156
- package/src/index.mjs +0 -32
- package/src/media-types.cjs +0 -34
- package/src/media-types.mjs +0 -30
- package/src/namespace.cjs +0 -71
- package/src/namespace.mjs +0 -66
- package/src/predicates.cjs +0 -193
- package/src/predicates.mjs +0 -161
- package/src/refractor/index.cjs +0 -316
- package/src/refractor/index.mjs +0 -283
- package/src/refractor/inspect.cjs +0 -157
- package/src/refractor/inspect.mjs +0 -126
- package/src/refractor/plugins/replace-empty-element.cjs +0 -366
- package/src/refractor/plugins/replace-empty-element.mjs +0 -358
- package/src/refractor/predicates.cjs +0 -26
- package/src/refractor/predicates.mjs +0 -21
- package/src/refractor/specification.cjs +0 -519
- package/src/refractor/specification.mjs +0 -513
- package/src/refractor/toolbox.cjs +0 -28
- package/src/refractor/toolbox.mjs +0 -21
- package/src/refractor/visitors/FallbackVisitor.cjs +0 -24
- package/src/refractor/visitors/FallbackVisitor.mjs +0 -18
- package/src/refractor/visitors/SpecificationExtensionVisitor.cjs +0 -18
- package/src/refractor/visitors/SpecificationExtensionVisitor.mjs +0 -13
- package/src/refractor/visitors/SpecificationVisitor.cjs +0 -75
- package/src/refractor/visitors/SpecificationVisitor.mjs +0 -69
- package/src/refractor/visitors/Visitor.cjs +0 -36
- package/src/refractor/visitors/Visitor.mjs +0 -33
- package/src/refractor/visitors/generics/AlternatingVisitor.cjs +0 -42
- package/src/refractor/visitors/generics/AlternatingVisitor.mjs +0 -35
- package/src/refractor/visitors/generics/FixedFieldsVisitor.cjs +0 -73
- package/src/refractor/visitors/generics/FixedFieldsVisitor.mjs +0 -66
- package/src/refractor/visitors/generics/MapVisitor.cjs +0 -21
- package/src/refractor/visitors/generics/MapVisitor.mjs +0 -15
- package/src/refractor/visitors/generics/MixedFieldsVisitor.cjs +0 -67
- package/src/refractor/visitors/generics/MixedFieldsVisitor.mjs +0 -61
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.cjs +0 -72
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.mjs +0 -66
- package/src/refractor/visitors/open-api-2/BasePathVisitor.cjs +0 -16
- package/src/refractor/visitors/open-api-2/BasePathVisitor.mjs +0 -11
- package/src/refractor/visitors/open-api-2/ConsumesVisitor.cjs +0 -23
- package/src/refractor/visitors/open-api-2/ConsumesVisitor.mjs +0 -18
- package/src/refractor/visitors/open-api-2/HostVisitor.cjs +0 -16
- package/src/refractor/visitors/open-api-2/HostVisitor.mjs +0 -11
- package/src/refractor/visitors/open-api-2/ProducesVisitor.cjs +0 -23
- package/src/refractor/visitors/open-api-2/ProducesVisitor.mjs +0 -18
- package/src/refractor/visitors/open-api-2/SchemesVisitor.cjs +0 -23
- package/src/refractor/visitors/open-api-2/SchemesVisitor.mjs +0 -18
- package/src/refractor/visitors/open-api-2/SecurityVisitor.cjs +0 -27
- package/src/refractor/visitors/open-api-2/SecurityVisitor.mjs +0 -22
- package/src/refractor/visitors/open-api-2/SwaggerVisitor.cjs +0 -21
- package/src/refractor/visitors/open-api-2/SwaggerVisitor.mjs +0 -16
- package/src/refractor/visitors/open-api-2/TagsVisitor.cjs +0 -27
- package/src/refractor/visitors/open-api-2/TagsVisitor.mjs +0 -22
- package/src/refractor/visitors/open-api-2/bases.cjs +0 -72
- package/src/refractor/visitors/open-api-2/bases.mjs +0 -67
- package/src/refractor/visitors/open-api-2/contact/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/contact/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/definitions/index.cjs +0 -31
- package/src/refractor/visitors/open-api-2/definitions/index.mjs +0 -26
- package/src/refractor/visitors/open-api-2/example/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/example/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/external-documentation/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/external-documentation/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/header/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/header/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/headers/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/headers/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/index.cjs +0 -21
- package/src/refractor/visitors/open-api-2/index.mjs +0 -16
- package/src/refractor/visitors/open-api-2/info/VersionVisitor.cjs +0 -17
- package/src/refractor/visitors/open-api-2/info/VersionVisitor.mjs +0 -12
- package/src/refractor/visitors/open-api-2/info/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/info/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/items/index.cjs +0 -22
- package/src/refractor/visitors/open-api-2/items/index.mjs +0 -17
- package/src/refractor/visitors/open-api-2/license/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/license/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/operation/ConsumesVisitor.cjs +0 -23
- package/src/refractor/visitors/open-api-2/operation/ConsumesVisitor.mjs +0 -18
- package/src/refractor/visitors/open-api-2/operation/ParametersVisitor.cjs +0 -32
- package/src/refractor/visitors/open-api-2/operation/ParametersVisitor.mjs +0 -27
- package/src/refractor/visitors/open-api-2/operation/ProducesVisitor.cjs +0 -23
- package/src/refractor/visitors/open-api-2/operation/ProducesVisitor.mjs +0 -18
- package/src/refractor/visitors/open-api-2/operation/SchemesVisitor.cjs +0 -23
- package/src/refractor/visitors/open-api-2/operation/SchemesVisitor.mjs +0 -18
- package/src/refractor/visitors/open-api-2/operation/SecurityVisitor.cjs +0 -27
- package/src/refractor/visitors/open-api-2/operation/SecurityVisitor.mjs +0 -22
- package/src/refractor/visitors/open-api-2/operation/TagsVisitor.cjs +0 -23
- package/src/refractor/visitors/open-api-2/operation/TagsVisitor.mjs +0 -18
- package/src/refractor/visitors/open-api-2/operation/index.cjs +0 -19
- package/src/refractor/visitors/open-api-2/operation/index.mjs +0 -14
- package/src/refractor/visitors/open-api-2/parameter/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/parameter/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/parameters-definitions/index.cjs +0 -19
- package/src/refractor/visitors/open-api-2/parameters-definitions/index.mjs +0 -14
- package/src/refractor/visitors/open-api-2/path-item/$RefVisitor.cjs +0 -16
- package/src/refractor/visitors/open-api-2/path-item/$RefVisitor.mjs +0 -11
- package/src/refractor/visitors/open-api-2/path-item/ParametersVisitor.cjs +0 -32
- package/src/refractor/visitors/open-api-2/path-item/ParametersVisitor.mjs +0 -27
- package/src/refractor/visitors/open-api-2/path-item/index.cjs +0 -39
- package/src/refractor/visitors/open-api-2/path-item/index.mjs +0 -34
- package/src/refractor/visitors/open-api-2/paths/index.cjs +0 -37
- package/src/refractor/visitors/open-api-2/paths/index.mjs +0 -32
- package/src/refractor/visitors/open-api-2/reference/$RefVisitor.cjs +0 -16
- package/src/refractor/visitors/open-api-2/reference/$RefVisitor.mjs +0 -11
- package/src/refractor/visitors/open-api-2/reference/index.cjs +0 -29
- package/src/refractor/visitors/open-api-2/reference/index.mjs +0 -24
- package/src/refractor/visitors/open-api-2/response/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/response/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/responses/DefaultVisitor.cjs +0 -36
- package/src/refractor/visitors/open-api-2/responses/DefaultVisitor.mjs +0 -31
- package/src/refractor/visitors/open-api-2/responses/index.cjs +0 -45
- package/src/refractor/visitors/open-api-2/responses/index.mjs +0 -40
- package/src/refractor/visitors/open-api-2/responses-definitions/index.cjs +0 -19
- package/src/refractor/visitors/open-api-2/responses-definitions/index.mjs +0 -14
- package/src/refractor/visitors/open-api-2/schema/AllOfVisitor.cjs +0 -24
- package/src/refractor/visitors/open-api-2/schema/AllOfVisitor.mjs +0 -20
- package/src/refractor/visitors/open-api-2/schema/ItemsVisitor.cjs +0 -26
- package/src/refractor/visitors/open-api-2/schema/ItemsVisitor.mjs +0 -23
- package/src/refractor/visitors/open-api-2/schema/PropertiesVisitor.cjs +0 -24
- package/src/refractor/visitors/open-api-2/schema/PropertiesVisitor.mjs +0 -20
- package/src/refractor/visitors/open-api-2/schema/SchemaOrJSONReferenceVisitor.cjs +0 -23
- package/src/refractor/visitors/open-api-2/schema/SchemaOrJSONReferenceVisitor.mjs +0 -19
- package/src/refractor/visitors/open-api-2/schema/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/schema/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/scopes/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/scopes/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/security-definitions/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/security-definitions/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/security-requirement/index.cjs +0 -19
- package/src/refractor/visitors/open-api-2/security-requirement/index.mjs +0 -14
- package/src/refractor/visitors/open-api-2/security-scheme/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/security-scheme/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/tag/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/tag/index.mjs +0 -15
- package/src/refractor/visitors/open-api-2/xml/index.cjs +0 -20
- package/src/refractor/visitors/open-api-2/xml/index.mjs +0 -15
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
-
exports.__esModule = true;
|
|
5
|
-
exports.default = void 0;
|
|
6
|
-
var _ramda = require("ramda");
|
|
7
|
-
var _ramdaAdjunct = require("ramda-adjunct");
|
|
8
|
-
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
9
|
-
var _apidomTraverse = require("@speclynx/apidom-traverse");
|
|
10
|
-
var _Visitor = _interopRequireDefault(require("./Visitor.cjs"));
|
|
11
|
-
var _FallbackVisitor = _interopRequireDefault(require("./FallbackVisitor.cjs"));
|
|
12
|
-
/**
|
|
13
|
-
* This is a base Type for every visitor that does
|
|
14
|
-
* internal look-ups to retrieve other child visitors.
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
class SpecificationVisitor extends _Visitor.default {
|
|
22
|
-
specObj;
|
|
23
|
-
passingOptionsNames = ['specObj', 'consume'];
|
|
24
|
-
constructor({
|
|
25
|
-
specObj,
|
|
26
|
-
...rest
|
|
27
|
-
}) {
|
|
28
|
-
super({
|
|
29
|
-
...rest
|
|
30
|
-
});
|
|
31
|
-
this.specObj = specObj;
|
|
32
|
-
}
|
|
33
|
-
retrievePassingOptions() {
|
|
34
|
-
return (0, _ramda.pick)(this.passingOptionsNames, this);
|
|
35
|
-
}
|
|
36
|
-
retrieveFixedFields(specPath) {
|
|
37
|
-
const fixedFields = (0, _ramda.path)(['visitors', ...specPath, 'fixedFields'], this.specObj);
|
|
38
|
-
if (typeof fixedFields === 'object' && fixedFields !== null) {
|
|
39
|
-
return Object.keys(fixedFields);
|
|
40
|
-
}
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
retrieveVisitor(specPath) {
|
|
44
|
-
if ((0, _ramda.pathSatisfies)(_ramdaAdjunct.isFunction, ['visitors', ...specPath], this.specObj)) {
|
|
45
|
-
return (0, _ramda.path)(['visitors', ...specPath], this.specObj);
|
|
46
|
-
}
|
|
47
|
-
return (0, _ramda.path)(['visitors', ...specPath, '$visitor'], this.specObj);
|
|
48
|
-
}
|
|
49
|
-
retrieveVisitorInstance(specPath, options = {}) {
|
|
50
|
-
const passingOpts = this.retrievePassingOptions();
|
|
51
|
-
const VisitorClz = this.retrieveVisitor(specPath);
|
|
52
|
-
const visitorOpts = {
|
|
53
|
-
...passingOpts,
|
|
54
|
-
...options
|
|
55
|
-
};
|
|
56
|
-
return new VisitorClz(visitorOpts);
|
|
57
|
-
}
|
|
58
|
-
toRefractedElement(specPath, element, options = {}) {
|
|
59
|
-
/**
|
|
60
|
-
* This is `Visitor shortcut`: mechanism for short circuiting the traversal and replacing
|
|
61
|
-
* it by basic node cloning.
|
|
62
|
-
*
|
|
63
|
-
* Visiting the element is equivalent to cloning it if the prototype of a visitor
|
|
64
|
-
* is the same as the prototype of FallbackVisitor. If that's the case, we can avoid
|
|
65
|
-
* bootstrapping the traversal cycle for fields that don't require any special visiting.
|
|
66
|
-
*/
|
|
67
|
-
const visitor = this.retrieveVisitorInstance(specPath, options);
|
|
68
|
-
if (visitor instanceof _FallbackVisitor.default && visitor?.constructor === _FallbackVisitor.default) {
|
|
69
|
-
return this.consume ? element : (0, _apidomDatamodel.cloneDeep)(element);
|
|
70
|
-
}
|
|
71
|
-
(0, _apidomTraverse.traverse)(element, visitor);
|
|
72
|
-
return visitor.element;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
var _default = exports.default = SpecificationVisitor;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { pathSatisfies, path, pick } from 'ramda';
|
|
2
|
-
import { isFunction } from 'ramda-adjunct';
|
|
3
|
-
import { cloneDeep } from '@speclynx/apidom-datamodel';
|
|
4
|
-
import { traverse } from '@speclynx/apidom-traverse';
|
|
5
|
-
import Visitor from "./Visitor.mjs";
|
|
6
|
-
import FallbackVisitor from "./FallbackVisitor.mjs";
|
|
7
|
-
/**
|
|
8
|
-
* This is a base Type for every visitor that does
|
|
9
|
-
* internal look-ups to retrieve other child visitors.
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
class SpecificationVisitor extends Visitor {
|
|
16
|
-
specObj;
|
|
17
|
-
passingOptionsNames = ['specObj', 'consume'];
|
|
18
|
-
constructor({
|
|
19
|
-
specObj,
|
|
20
|
-
...rest
|
|
21
|
-
}) {
|
|
22
|
-
super({
|
|
23
|
-
...rest
|
|
24
|
-
});
|
|
25
|
-
this.specObj = specObj;
|
|
26
|
-
}
|
|
27
|
-
retrievePassingOptions() {
|
|
28
|
-
return pick(this.passingOptionsNames, this);
|
|
29
|
-
}
|
|
30
|
-
retrieveFixedFields(specPath) {
|
|
31
|
-
const fixedFields = path(['visitors', ...specPath, 'fixedFields'], this.specObj);
|
|
32
|
-
if (typeof fixedFields === 'object' && fixedFields !== null) {
|
|
33
|
-
return Object.keys(fixedFields);
|
|
34
|
-
}
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
retrieveVisitor(specPath) {
|
|
38
|
-
if (pathSatisfies(isFunction, ['visitors', ...specPath], this.specObj)) {
|
|
39
|
-
return path(['visitors', ...specPath], this.specObj);
|
|
40
|
-
}
|
|
41
|
-
return path(['visitors', ...specPath, '$visitor'], this.specObj);
|
|
42
|
-
}
|
|
43
|
-
retrieveVisitorInstance(specPath, options = {}) {
|
|
44
|
-
const passingOpts = this.retrievePassingOptions();
|
|
45
|
-
const VisitorClz = this.retrieveVisitor(specPath);
|
|
46
|
-
const visitorOpts = {
|
|
47
|
-
...passingOpts,
|
|
48
|
-
...options
|
|
49
|
-
};
|
|
50
|
-
return new VisitorClz(visitorOpts);
|
|
51
|
-
}
|
|
52
|
-
toRefractedElement(specPath, element, options = {}) {
|
|
53
|
-
/**
|
|
54
|
-
* This is `Visitor shortcut`: mechanism for short circuiting the traversal and replacing
|
|
55
|
-
* it by basic node cloning.
|
|
56
|
-
*
|
|
57
|
-
* Visiting the element is equivalent to cloning it if the prototype of a visitor
|
|
58
|
-
* is the same as the prototype of FallbackVisitor. If that's the case, we can avoid
|
|
59
|
-
* bootstrapping the traversal cycle for fields that don't require any special visiting.
|
|
60
|
-
*/
|
|
61
|
-
const visitor = this.retrieveVisitorInstance(specPath, options);
|
|
62
|
-
if (visitor instanceof FallbackVisitor && visitor?.constructor === FallbackVisitor) {
|
|
63
|
-
return this.consume ? element : cloneDeep(element);
|
|
64
|
-
}
|
|
65
|
-
traverse(element, visitor);
|
|
66
|
-
return visitor.element;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
export default SpecificationVisitor;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.default = void 0;
|
|
5
|
-
var _apidomCore = require("@speclynx/apidom-core");
|
|
6
|
-
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
class Visitor {
|
|
15
|
-
element;
|
|
16
|
-
consume = false;
|
|
17
|
-
consumeSafe = false;
|
|
18
|
-
constructor(options = {}) {
|
|
19
|
-
Object.assign(this, options);
|
|
20
|
-
}
|
|
21
|
-
copyMetaAndAttributes(from, to) {
|
|
22
|
-
if (!from.isMetaEmpty && !to.isMetaEmpty) {
|
|
23
|
-
to.meta = to.meta.merge(from.meta);
|
|
24
|
-
} else if (!from.isMetaEmpty) {
|
|
25
|
-
to.meta = from.meta.cloneDeep();
|
|
26
|
-
}
|
|
27
|
-
if (!from.isAttributesEmpty && !to.isAttributesEmpty) {
|
|
28
|
-
to.attributes = (0, _apidomCore.deepmerge)(to.attributes, from.attributes);
|
|
29
|
-
} else if (!from.isAttributesEmpty) {
|
|
30
|
-
to.attributes = (0, _apidomDatamodel.cloneDeep)(from.attributes);
|
|
31
|
-
}
|
|
32
|
-
_apidomDatamodel.SourceMapElement.transfer(from, to);
|
|
33
|
-
_apidomDatamodel.StyleElement.transfer(from, to);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
var _default = exports.default = Visitor;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { deepmerge } from '@speclynx/apidom-core';
|
|
2
|
-
import { SourceMapElement, StyleElement, cloneDeep } from '@speclynx/apidom-datamodel';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
class Visitor {
|
|
12
|
-
element;
|
|
13
|
-
consume = false;
|
|
14
|
-
consumeSafe = false;
|
|
15
|
-
constructor(options = {}) {
|
|
16
|
-
Object.assign(this, options);
|
|
17
|
-
}
|
|
18
|
-
copyMetaAndAttributes(from, to) {
|
|
19
|
-
if (!from.isMetaEmpty && !to.isMetaEmpty) {
|
|
20
|
-
to.meta = to.meta.merge(from.meta);
|
|
21
|
-
} else if (!from.isMetaEmpty) {
|
|
22
|
-
to.meta = from.meta.cloneDeep();
|
|
23
|
-
}
|
|
24
|
-
if (!from.isAttributesEmpty && !to.isAttributesEmpty) {
|
|
25
|
-
to.attributes = deepmerge(to.attributes, from.attributes);
|
|
26
|
-
} else if (!from.isAttributesEmpty) {
|
|
27
|
-
to.attributes = cloneDeep(from.attributes);
|
|
28
|
-
}
|
|
29
|
-
SourceMapElement.transfer(from, to);
|
|
30
|
-
StyleElement.transfer(from, to);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export default Visitor;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
-
exports.__esModule = true;
|
|
5
|
-
exports.default = void 0;
|
|
6
|
-
var _ramda = require("ramda");
|
|
7
|
-
var _ramdaAdjunct = require("ramda-adjunct");
|
|
8
|
-
var _SpecificationVisitor = _interopRequireDefault(require("../SpecificationVisitor.cjs"));
|
|
9
|
-
/**
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
class AlternatingVisitor extends _SpecificationVisitor.default {
|
|
21
|
-
alternator;
|
|
22
|
-
constructor({
|
|
23
|
-
alternator,
|
|
24
|
-
...rest
|
|
25
|
-
}) {
|
|
26
|
-
super({
|
|
27
|
-
...rest
|
|
28
|
-
});
|
|
29
|
-
this.alternator = alternator || [];
|
|
30
|
-
}
|
|
31
|
-
enter(path) {
|
|
32
|
-
const element = path.node;
|
|
33
|
-
const functions = this.alternator.map(({
|
|
34
|
-
predicate,
|
|
35
|
-
specPath
|
|
36
|
-
}) => (0, _ramda.ifElse)(predicate, (0, _ramda.always)(specPath), _ramdaAdjunct.stubUndefined));
|
|
37
|
-
const specPath = (0, _ramdaAdjunct.dispatch)(functions)(element);
|
|
38
|
-
this.element = this.toRefractedElement(specPath, element);
|
|
39
|
-
path.stop();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
var _default = exports.default = AlternatingVisitor;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ifElse, always } from 'ramda';
|
|
2
|
-
import { dispatch, stubUndefined } from 'ramda-adjunct';
|
|
3
|
-
import SpecificationVisitor from "../SpecificationVisitor.mjs";
|
|
4
|
-
/**
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
class AlternatingVisitor extends SpecificationVisitor {
|
|
14
|
-
alternator;
|
|
15
|
-
constructor({
|
|
16
|
-
alternator,
|
|
17
|
-
...rest
|
|
18
|
-
}) {
|
|
19
|
-
super({
|
|
20
|
-
...rest
|
|
21
|
-
});
|
|
22
|
-
this.alternator = alternator || [];
|
|
23
|
-
}
|
|
24
|
-
enter(path) {
|
|
25
|
-
const element = path.node;
|
|
26
|
-
const functions = this.alternator.map(({
|
|
27
|
-
predicate,
|
|
28
|
-
specPath
|
|
29
|
-
}) => ifElse(predicate, always(specPath), stubUndefined));
|
|
30
|
-
const specPath = dispatch(functions)(element);
|
|
31
|
-
this.element = this.toRefractedElement(specPath, element);
|
|
32
|
-
path.stop();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export default AlternatingVisitor;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
-
exports.__esModule = true;
|
|
5
|
-
exports.default = void 0;
|
|
6
|
-
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
7
|
-
var _apidomCore = require("@speclynx/apidom-core");
|
|
8
|
-
var _SpecificationVisitor = _interopRequireDefault(require("../SpecificationVisitor.cjs"));
|
|
9
|
-
var _predicates = require("../../predicates.cjs");
|
|
10
|
-
/**
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
class FixedFieldsVisitor extends _SpecificationVisitor.default {
|
|
22
|
-
specPath;
|
|
23
|
-
ignoredFields;
|
|
24
|
-
canSupportSpecificationExtensions = true;
|
|
25
|
-
specificationExtensionPredicate = _predicates.isSwaggerExtension;
|
|
26
|
-
constructor({
|
|
27
|
-
specPath,
|
|
28
|
-
ignoredFields,
|
|
29
|
-
canSupportSpecificationExtensions,
|
|
30
|
-
specificationExtensionPredicate,
|
|
31
|
-
...rest
|
|
32
|
-
}) {
|
|
33
|
-
super({
|
|
34
|
-
...rest
|
|
35
|
-
});
|
|
36
|
-
this.specPath = specPath;
|
|
37
|
-
this.ignoredFields = ignoredFields || [];
|
|
38
|
-
if (typeof canSupportSpecificationExtensions === 'boolean') {
|
|
39
|
-
this.canSupportSpecificationExtensions = canSupportSpecificationExtensions;
|
|
40
|
-
}
|
|
41
|
-
if (typeof specificationExtensionPredicate === 'function') {
|
|
42
|
-
this.specificationExtensionPredicate = specificationExtensionPredicate;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
ObjectElement(path) {
|
|
46
|
-
const objectElement = path.node;
|
|
47
|
-
const specPath = this.specPath(objectElement);
|
|
48
|
-
const fields = this.retrieveFixedFields(specPath);
|
|
49
|
-
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
objectElement.forEach((value, key, memberElement) => {
|
|
52
|
-
const keyValue = (0, _apidomCore.toValue)(key);
|
|
53
|
-
if ((0, _apidomDatamodel.isStringElement)(key) && fields.includes(keyValue) && !this.ignoredFields.includes(keyValue)) {
|
|
54
|
-
const fixedFieldElement = this.toRefractedElement([...specPath, 'fixedFields', keyValue], value);
|
|
55
|
-
const newMemberElement = new _apidomDatamodel.MemberElement(this.consume ? key : (0, _apidomDatamodel.cloneDeep)(key), fixedFieldElement);
|
|
56
|
-
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
57
|
-
this.element.content.push(newMemberElement);
|
|
58
|
-
// consume: release processed generic subtree
|
|
59
|
-
if (this.consume && this.consumeSafe && !memberElement.isFrozen) memberElement.value = undefined;
|
|
60
|
-
} else if (this.canSupportSpecificationExtensions && this.specificationExtensionPredicate(memberElement)) {
|
|
61
|
-
const extensionElement = this.toRefractedElement(['document', 'extension'], memberElement);
|
|
62
|
-
this.element.content.push(extensionElement);
|
|
63
|
-
// consume: release processed generic subtree
|
|
64
|
-
if (this.consume && this.consumeSafe && !memberElement.isFrozen) memberElement.value = undefined;
|
|
65
|
-
} else if (!this.ignoredFields.includes(keyValue)) {
|
|
66
|
-
this.element.content.push(this.consume ? memberElement : (0, _apidomDatamodel.cloneDeep)(memberElement));
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
this.copyMetaAndAttributes(objectElement, this.element);
|
|
70
|
-
path.stop();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
var _default = exports.default = FixedFieldsVisitor;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { isStringElement, MemberElement, cloneDeep } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import { toValue } from '@speclynx/apidom-core';
|
|
3
|
-
import SpecificationVisitor from "../SpecificationVisitor.mjs";
|
|
4
|
-
import { isSwaggerExtension } from "../../predicates.mjs";
|
|
5
|
-
/**
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
class FixedFieldsVisitor extends SpecificationVisitor {
|
|
15
|
-
specPath;
|
|
16
|
-
ignoredFields;
|
|
17
|
-
canSupportSpecificationExtensions = true;
|
|
18
|
-
specificationExtensionPredicate = isSwaggerExtension;
|
|
19
|
-
constructor({
|
|
20
|
-
specPath,
|
|
21
|
-
ignoredFields,
|
|
22
|
-
canSupportSpecificationExtensions,
|
|
23
|
-
specificationExtensionPredicate,
|
|
24
|
-
...rest
|
|
25
|
-
}) {
|
|
26
|
-
super({
|
|
27
|
-
...rest
|
|
28
|
-
});
|
|
29
|
-
this.specPath = specPath;
|
|
30
|
-
this.ignoredFields = ignoredFields || [];
|
|
31
|
-
if (typeof canSupportSpecificationExtensions === 'boolean') {
|
|
32
|
-
this.canSupportSpecificationExtensions = canSupportSpecificationExtensions;
|
|
33
|
-
}
|
|
34
|
-
if (typeof specificationExtensionPredicate === 'function') {
|
|
35
|
-
this.specificationExtensionPredicate = specificationExtensionPredicate;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
ObjectElement(path) {
|
|
39
|
-
const objectElement = path.node;
|
|
40
|
-
const specPath = this.specPath(objectElement);
|
|
41
|
-
const fields = this.retrieveFixedFields(specPath);
|
|
42
|
-
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
objectElement.forEach((value, key, memberElement) => {
|
|
45
|
-
const keyValue = toValue(key);
|
|
46
|
-
if (isStringElement(key) && fields.includes(keyValue) && !this.ignoredFields.includes(keyValue)) {
|
|
47
|
-
const fixedFieldElement = this.toRefractedElement([...specPath, 'fixedFields', keyValue], value);
|
|
48
|
-
const newMemberElement = new MemberElement(this.consume ? key : cloneDeep(key), fixedFieldElement);
|
|
49
|
-
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
50
|
-
this.element.content.push(newMemberElement);
|
|
51
|
-
// consume: release processed generic subtree
|
|
52
|
-
if (this.consume && this.consumeSafe && !memberElement.isFrozen) memberElement.value = undefined;
|
|
53
|
-
} else if (this.canSupportSpecificationExtensions && this.specificationExtensionPredicate(memberElement)) {
|
|
54
|
-
const extensionElement = this.toRefractedElement(['document', 'extension'], memberElement);
|
|
55
|
-
this.element.content.push(extensionElement);
|
|
56
|
-
// consume: release processed generic subtree
|
|
57
|
-
if (this.consume && this.consumeSafe && !memberElement.isFrozen) memberElement.value = undefined;
|
|
58
|
-
} else if (!this.ignoredFields.includes(keyValue)) {
|
|
59
|
-
this.element.content.push(this.consume ? memberElement : cloneDeep(memberElement));
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
this.copyMetaAndAttributes(objectElement, this.element);
|
|
63
|
-
path.stop();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
export default FixedFieldsVisitor;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
-
exports.__esModule = true;
|
|
5
|
-
exports.default = void 0;
|
|
6
|
-
var _ramdaAdjunct = require("ramda-adjunct");
|
|
7
|
-
var _PatternedFieldsVisitor = _interopRequireDefault(require("./PatternedFieldsVisitor.cjs"));
|
|
8
|
-
/**
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
class MapVisitor extends _PatternedFieldsVisitor.default {
|
|
16
|
-
constructor(options) {
|
|
17
|
-
super(options);
|
|
18
|
-
this.fieldPatternPredicate = _ramdaAdjunct.isNonEmptyString;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
var _default = exports.default = MapVisitor;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { isNonEmptyString } from 'ramda-adjunct';
|
|
2
|
-
import PatternedFieldsVisitor from "./PatternedFieldsVisitor.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
class MapVisitor extends PatternedFieldsVisitor {
|
|
10
|
-
constructor(options) {
|
|
11
|
-
super(options);
|
|
12
|
-
this.fieldPatternPredicate = isNonEmptyString;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export default MapVisitor;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
-
exports.__esModule = true;
|
|
5
|
-
exports.default = exports.MixedFieldsVisitorBase = void 0;
|
|
6
|
-
var _tsMixer = require("ts-mixer");
|
|
7
|
-
var _ramda = require("ramda");
|
|
8
|
-
var _apidomCore = require("@speclynx/apidom-core");
|
|
9
|
-
var _FixedFieldsVisitor = _interopRequireDefault(require("./FixedFieldsVisitor.cjs"));
|
|
10
|
-
var _PatternedFieldsVisitor = _interopRequireDefault(require("./PatternedFieldsVisitor.cjs"));
|
|
11
|
-
/**
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Base class for MixedFieldsVisitor combining FixedFieldsVisitor and PatternedFieldsVisitor.
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
const MixedFieldsVisitorBase = exports.MixedFieldsVisitorBase = (0, _tsMixer.Mixin)(_FixedFieldsVisitor.default, _PatternedFieldsVisitor.default);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
class MixedFieldsVisitor extends MixedFieldsVisitorBase {
|
|
25
|
-
specPathFixedFields;
|
|
26
|
-
specPathPatternedFields;
|
|
27
|
-
constructor({
|
|
28
|
-
specPathFixedFields,
|
|
29
|
-
specPathPatternedFields,
|
|
30
|
-
...rest
|
|
31
|
-
}) {
|
|
32
|
-
super({
|
|
33
|
-
...rest
|
|
34
|
-
});
|
|
35
|
-
this.specPathFixedFields = specPathFixedFields;
|
|
36
|
-
this.specPathPatternedFields = specPathPatternedFields;
|
|
37
|
-
}
|
|
38
|
-
ObjectElement(path) {
|
|
39
|
-
const objectElement = path.node;
|
|
40
|
-
const {
|
|
41
|
-
specPath,
|
|
42
|
-
ignoredFields
|
|
43
|
-
} = this;
|
|
44
|
-
try {
|
|
45
|
-
this.specPath = this.specPathFixedFields;
|
|
46
|
-
const fixedFields = this.retrieveFixedFields(this.specPath(objectElement));
|
|
47
|
-
// let FixedFieldsVisitor only process fixed fields and leave rest to PatternedFieldsVisitor
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
this.ignoredFields = [...ignoredFields, ...(0, _ramda.difference)(objectElement.keys(), fixedFields)];
|
|
50
|
-
_FixedFieldsVisitor.default.prototype.ObjectElement.call(this, path);
|
|
51
|
-
this.specPath = this.specPathPatternedFields;
|
|
52
|
-
this.ignoredFields = fixedFields;
|
|
53
|
-
_PatternedFieldsVisitor.default.prototype.ObjectElement.call(this, path);
|
|
54
|
-
|
|
55
|
-
// reorder this.element members by original objectElement keys
|
|
56
|
-
const objectElementKeys = objectElement.keys();
|
|
57
|
-
this.element.content.sort((a, b) => {
|
|
58
|
-
return objectElementKeys.indexOf((0, _apidomCore.toValue)(a.key)) - objectElementKeys.indexOf((0, _apidomCore.toValue)(b.key));
|
|
59
|
-
});
|
|
60
|
-
} catch (e) {
|
|
61
|
-
this.specPath = specPath;
|
|
62
|
-
throw e;
|
|
63
|
-
}
|
|
64
|
-
path.stop();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
var _default = exports.default = MixedFieldsVisitor;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Mixin } from 'ts-mixer';
|
|
2
|
-
import { difference } from 'ramda';
|
|
3
|
-
import { toValue } from '@speclynx/apidom-core';
|
|
4
|
-
import FixedFieldsVisitor from "./FixedFieldsVisitor.mjs";
|
|
5
|
-
import PatternedFieldsVisitor from "./PatternedFieldsVisitor.mjs";
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Base class for MixedFieldsVisitor combining FixedFieldsVisitor and PatternedFieldsVisitor.
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
export const MixedFieldsVisitorBase = Mixin(FixedFieldsVisitor, PatternedFieldsVisitor);
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
class MixedFieldsVisitor extends MixedFieldsVisitorBase {
|
|
19
|
-
specPathFixedFields;
|
|
20
|
-
specPathPatternedFields;
|
|
21
|
-
constructor({
|
|
22
|
-
specPathFixedFields,
|
|
23
|
-
specPathPatternedFields,
|
|
24
|
-
...rest
|
|
25
|
-
}) {
|
|
26
|
-
super({
|
|
27
|
-
...rest
|
|
28
|
-
});
|
|
29
|
-
this.specPathFixedFields = specPathFixedFields;
|
|
30
|
-
this.specPathPatternedFields = specPathPatternedFields;
|
|
31
|
-
}
|
|
32
|
-
ObjectElement(path) {
|
|
33
|
-
const objectElement = path.node;
|
|
34
|
-
const {
|
|
35
|
-
specPath,
|
|
36
|
-
ignoredFields
|
|
37
|
-
} = this;
|
|
38
|
-
try {
|
|
39
|
-
this.specPath = this.specPathFixedFields;
|
|
40
|
-
const fixedFields = this.retrieveFixedFields(this.specPath(objectElement));
|
|
41
|
-
// let FixedFieldsVisitor only process fixed fields and leave rest to PatternedFieldsVisitor
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
this.ignoredFields = [...ignoredFields, ...difference(objectElement.keys(), fixedFields)];
|
|
44
|
-
FixedFieldsVisitor.prototype.ObjectElement.call(this, path);
|
|
45
|
-
this.specPath = this.specPathPatternedFields;
|
|
46
|
-
this.ignoredFields = fixedFields;
|
|
47
|
-
PatternedFieldsVisitor.prototype.ObjectElement.call(this, path);
|
|
48
|
-
|
|
49
|
-
// reorder this.element members by original objectElement keys
|
|
50
|
-
const objectElementKeys = objectElement.keys();
|
|
51
|
-
this.element.content.sort((a, b) => {
|
|
52
|
-
return objectElementKeys.indexOf(toValue(a.key)) - objectElementKeys.indexOf(toValue(b.key));
|
|
53
|
-
});
|
|
54
|
-
} catch (e) {
|
|
55
|
-
this.specPath = specPath;
|
|
56
|
-
throw e;
|
|
57
|
-
}
|
|
58
|
-
path.stop();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export default MixedFieldsVisitor;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
-
exports.__esModule = true;
|
|
5
|
-
exports.default = void 0;
|
|
6
|
-
var _ramda = require("ramda");
|
|
7
|
-
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
8
|
-
var _apidomCore = require("@speclynx/apidom-core");
|
|
9
|
-
var _SpecificationVisitor = _interopRequireDefault(require("../SpecificationVisitor.cjs"));
|
|
10
|
-
var _predicates = require("../../predicates.cjs");
|
|
11
|
-
/**
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
class PatternedFieldsVisitor extends _SpecificationVisitor.default {
|
|
19
|
-
specPath;
|
|
20
|
-
ignoredFields;
|
|
21
|
-
fieldPatternPredicate = _ramda.F;
|
|
22
|
-
canSupportSpecificationExtensions = false;
|
|
23
|
-
specificationExtensionPredicate = _predicates.isSwaggerExtension;
|
|
24
|
-
constructor({
|
|
25
|
-
specPath,
|
|
26
|
-
ignoredFields,
|
|
27
|
-
fieldPatternPredicate,
|
|
28
|
-
canSupportSpecificationExtensions,
|
|
29
|
-
specificationExtensionPredicate,
|
|
30
|
-
...rest
|
|
31
|
-
}) {
|
|
32
|
-
super({
|
|
33
|
-
...rest
|
|
34
|
-
});
|
|
35
|
-
this.specPath = specPath;
|
|
36
|
-
this.ignoredFields = ignoredFields || [];
|
|
37
|
-
if (typeof fieldPatternPredicate === 'function') {
|
|
38
|
-
this.fieldPatternPredicate = fieldPatternPredicate;
|
|
39
|
-
}
|
|
40
|
-
if (typeof canSupportSpecificationExtensions === 'boolean') {
|
|
41
|
-
this.canSupportSpecificationExtensions = canSupportSpecificationExtensions;
|
|
42
|
-
}
|
|
43
|
-
if (typeof specificationExtensionPredicate === 'function') {
|
|
44
|
-
this.specificationExtensionPredicate = specificationExtensionPredicate;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
ObjectElement(path) {
|
|
48
|
-
const objectElement = path.node;
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
objectElement.forEach((value, key, memberElement) => {
|
|
51
|
-
const keyValue = (0, _apidomCore.toValue)(key);
|
|
52
|
-
if (this.canSupportSpecificationExtensions && this.specificationExtensionPredicate(memberElement)) {
|
|
53
|
-
const extensionElement = this.toRefractedElement(['document', 'extension'], memberElement);
|
|
54
|
-
this.element.content.push(extensionElement);
|
|
55
|
-
} else if (!this.ignoredFields.includes(keyValue) && this.fieldPatternPredicate(keyValue)) {
|
|
56
|
-
const specPath = this.specPath(value);
|
|
57
|
-
const patternedFieldElement = this.toRefractedElement(specPath, value);
|
|
58
|
-
const newMemberElement = new _apidomDatamodel.MemberElement(this.consume ? key : (0, _apidomDatamodel.cloneDeep)(key), patternedFieldElement);
|
|
59
|
-
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
60
|
-
newMemberElement.classes.push('patterned-field');
|
|
61
|
-
this.element.content.push(newMemberElement);
|
|
62
|
-
// consume: release processed generic subtree
|
|
63
|
-
if (this.consume && this.consumeSafe && !memberElement.isFrozen) memberElement.value = undefined;
|
|
64
|
-
} else if (!this.ignoredFields.includes(keyValue)) {
|
|
65
|
-
this.element.content.push(this.consume ? memberElement : (0, _apidomDatamodel.cloneDeep)(memberElement));
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
this.copyMetaAndAttributes(objectElement, this.element);
|
|
69
|
-
path.stop();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
var _default = exports.default = PatternedFieldsVisitor;
|