@speclynx/apidom-ns-json-schema-draft-4 4.0.1 → 4.0.3
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 +10 -0
- package/package.json +6 -7
- package/src/elements/JSONReference.cjs +29 -0
- package/src/elements/JSONReference.mjs +25 -0
- package/src/elements/JSONReference.ts +33 -0
- package/src/elements/JSONSchema.cjs +296 -0
- package/src/elements/JSONSchema.mjs +292 -0
- package/src/elements/JSONSchema.ts +391 -0
- package/src/elements/LinkDescription.cjs +65 -0
- package/src/elements/LinkDescription.mjs +61 -0
- package/src/elements/LinkDescription.ts +85 -0
- package/src/elements/Media.cjs +29 -0
- package/src/elements/Media.mjs +25 -0
- package/src/elements/Media.ts +35 -0
- package/src/index.cjs +69 -0
- package/src/index.mjs +23 -0
- package/src/index.ts +142 -0
- package/src/media-types.cjs +34 -0
- package/src/media-types.mjs +30 -0
- package/src/media-types.ts +40 -0
- package/src/namespace.cjs +25 -0
- package/src/namespace.mjs +20 -0
- package/src/namespace.ts +24 -0
- package/src/predicates.cjs +32 -0
- package/src/predicates.mjs +23 -0
- package/src/predicates.ts +28 -0
- package/src/refractor/index.cjs +96 -0
- package/src/refractor/index.mjs +85 -0
- package/src/refractor/index.ts +110 -0
- package/src/refractor/inspect.cjs +55 -0
- package/src/refractor/inspect.mjs +47 -0
- package/src/refractor/inspect.ts +61 -0
- package/src/refractor/plugins/replace-empty-element.cjs +208 -0
- package/src/refractor/plugins/replace-empty-element.mjs +202 -0
- package/src/refractor/plugins/replace-empty-element.ts +233 -0
- package/src/refractor/predicates.cjs +16 -0
- package/src/refractor/predicates.mjs +12 -0
- package/src/refractor/predicates.ts +17 -0
- package/src/refractor/specification.cjs +193 -0
- package/src/refractor/specification.mjs +188 -0
- package/src/refractor/specification.ts +134 -0
- package/src/refractor/toolbox.cjs +28 -0
- package/src/refractor/toolbox.mjs +21 -0
- package/src/refractor/toolbox.ts +24 -0
- package/src/refractor/visitors/FallbackVisitor.cjs +25 -0
- package/src/refractor/visitors/FallbackVisitor.mjs +19 -0
- package/src/refractor/visitors/FallbackVisitor.ts +25 -0
- package/src/refractor/visitors/SpecificationVisitor.cjs +75 -0
- package/src/refractor/visitors/SpecificationVisitor.mjs +69 -0
- package/src/refractor/visitors/SpecificationVisitor.ts +82 -0
- package/src/refractor/visitors/Visitor.cjs +36 -0
- package/src/refractor/visitors/Visitor.mjs +33 -0
- package/src/refractor/visitors/Visitor.ts +49 -0
- package/src/refractor/visitors/generics/AlternatingVisitor.cjs +42 -0
- package/src/refractor/visitors/generics/AlternatingVisitor.mjs +35 -0
- package/src/refractor/visitors/generics/AlternatingVisitor.ts +45 -0
- package/src/refractor/visitors/generics/FixedFieldsVisitor.cjs +57 -0
- package/src/refractor/visitors/generics/FixedFieldsVisitor.mjs +50 -0
- package/src/refractor/visitors/generics/FixedFieldsVisitor.ts +79 -0
- package/src/refractor/visitors/generics/MapVisitor.cjs +21 -0
- package/src/refractor/visitors/generics/MapVisitor.mjs +15 -0
- package/src/refractor/visitors/generics/MapVisitor.ts +25 -0
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.cjs +58 -0
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.mjs +52 -0
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.ts +76 -0
- package/src/refractor/visitors/json-schema/AllOfVisitor.cjs +32 -0
- package/src/refractor/visitors/json-schema/AllOfVisitor.mjs +27 -0
- package/src/refractor/visitors/json-schema/AllOfVisitor.ts +44 -0
- package/src/refractor/visitors/json-schema/AnyOfVisitor.cjs +32 -0
- package/src/refractor/visitors/json-schema/AnyOfVisitor.mjs +27 -0
- package/src/refractor/visitors/json-schema/AnyOfVisitor.ts +44 -0
- package/src/refractor/visitors/json-schema/DefinitionsVisitor.cjs +23 -0
- package/src/refractor/visitors/json-schema/DefinitionsVisitor.mjs +18 -0
- package/src/refractor/visitors/json-schema/DefinitionsVisitor.ts +36 -0
- package/src/refractor/visitors/json-schema/DependenciesVisitor.cjs +23 -0
- package/src/refractor/visitors/json-schema/DependenciesVisitor.mjs +18 -0
- package/src/refractor/visitors/json-schema/DependenciesVisitor.ts +36 -0
- package/src/refractor/visitors/json-schema/EnumVisitor.cjs +16 -0
- package/src/refractor/visitors/json-schema/EnumVisitor.mjs +11 -0
- package/src/refractor/visitors/json-schema/EnumVisitor.ts +20 -0
- package/src/refractor/visitors/json-schema/ItemsVisitor.cjs +35 -0
- package/src/refractor/visitors/json-schema/ItemsVisitor.mjs +30 -0
- package/src/refractor/visitors/json-schema/ItemsVisitor.ts +52 -0
- package/src/refractor/visitors/json-schema/JSONSchemaOrJSONReferenceVisitor.cjs +24 -0
- package/src/refractor/visitors/json-schema/JSONSchemaOrJSONReferenceVisitor.mjs +19 -0
- package/src/refractor/visitors/json-schema/JSONSchemaOrJSONReferenceVisitor.ts +21 -0
- package/src/refractor/visitors/json-schema/LinksVisitor.cjs +30 -0
- package/src/refractor/visitors/json-schema/LinksVisitor.mjs +25 -0
- package/src/refractor/visitors/json-schema/LinksVisitor.ts +43 -0
- package/src/refractor/visitors/json-schema/OneOfVisitor.cjs +32 -0
- package/src/refractor/visitors/json-schema/OneOfVisitor.mjs +27 -0
- package/src/refractor/visitors/json-schema/OneOfVisitor.ts +44 -0
- package/src/refractor/visitors/json-schema/ParentSchemaAwareVisitor.cjs +20 -0
- package/src/refractor/visitors/json-schema/ParentSchemaAwareVisitor.mjs +16 -0
- package/src/refractor/visitors/json-schema/ParentSchemaAwareVisitor.ts +21 -0
- package/src/refractor/visitors/json-schema/PatternPropertiesVisitor.cjs +23 -0
- package/src/refractor/visitors/json-schema/PatternPropertiesVisitor.mjs +18 -0
- package/src/refractor/visitors/json-schema/PatternPropertiesVisitor.ts +36 -0
- package/src/refractor/visitors/json-schema/PropertiesVisitor.cjs +23 -0
- package/src/refractor/visitors/json-schema/PropertiesVisitor.mjs +18 -0
- package/src/refractor/visitors/json-schema/PropertiesVisitor.ts +36 -0
- package/src/refractor/visitors/json-schema/RequiredVisitor.cjs +16 -0
- package/src/refractor/visitors/json-schema/RequiredVisitor.mjs +11 -0
- package/src/refractor/visitors/json-schema/RequiredVisitor.ts +20 -0
- package/src/refractor/visitors/json-schema/TypeVisitor.cjs +20 -0
- package/src/refractor/visitors/json-schema/TypeVisitor.mjs +15 -0
- package/src/refractor/visitors/json-schema/TypeVisitor.ts +25 -0
- package/src/refractor/visitors/json-schema/bases.cjs +45 -0
- package/src/refractor/visitors/json-schema/bases.mjs +39 -0
- package/src/refractor/visitors/json-schema/bases.ts +70 -0
- package/src/refractor/visitors/json-schema/index.cjs +65 -0
- package/src/refractor/visitors/json-schema/index.mjs +59 -0
- package/src/refractor/visitors/json-schema/index.ts +85 -0
- package/src/refractor/visitors/json-schema/json-reference/$RefVisitor.cjs +16 -0
- package/src/refractor/visitors/json-schema/json-reference/$RefVisitor.mjs +11 -0
- package/src/refractor/visitors/json-schema/json-reference/$RefVisitor.ts +20 -0
- package/src/refractor/visitors/json-schema/json-reference/index.cjs +33 -0
- package/src/refractor/visitors/json-schema/json-reference/index.mjs +27 -0
- package/src/refractor/visitors/json-schema/json-reference/index.ts +41 -0
- package/src/refractor/visitors/json-schema/link-description/index.cjs +23 -0
- package/src/refractor/visitors/json-schema/link-description/index.mjs +17 -0
- package/src/refractor/visitors/json-schema/link-description/index.ts +30 -0
- package/src/refractor/visitors/json-schema/media/index.cjs +23 -0
- package/src/refractor/visitors/json-schema/media/index.mjs +17 -0
- package/src/refractor/visitors/json-schema/media/index.ts +29 -0
|
@@ -0,0 +1,15 @@
|
|
|
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;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isNonEmptyString } from 'ramda-adjunct';
|
|
2
|
+
|
|
3
|
+
import PatternedFieldsVisitor, {
|
|
4
|
+
PatternedFieldsVisitorOptions,
|
|
5
|
+
SpecPath,
|
|
6
|
+
} from './PatternedFieldsVisitor.ts';
|
|
7
|
+
|
|
8
|
+
export type { SpecPath };
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export interface MapVisitorOptions extends PatternedFieldsVisitorOptions {}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
class MapVisitor extends PatternedFieldsVisitor {
|
|
19
|
+
constructor(options: MapVisitorOptions) {
|
|
20
|
+
super(options);
|
|
21
|
+
this.fieldPatternPredicate = isNonEmptyString;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default MapVisitor;
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class PatternedFieldsVisitor extends _SpecificationVisitor.default {
|
|
18
|
+
specPath;
|
|
19
|
+
ignoredFields;
|
|
20
|
+
fieldPatternPredicate = _ramda.F;
|
|
21
|
+
constructor({
|
|
22
|
+
specPath,
|
|
23
|
+
ignoredFields,
|
|
24
|
+
fieldPatternPredicate,
|
|
25
|
+
...rest
|
|
26
|
+
}) {
|
|
27
|
+
super({
|
|
28
|
+
...rest
|
|
29
|
+
});
|
|
30
|
+
this.specPath = specPath;
|
|
31
|
+
this.ignoredFields = ignoredFields || [];
|
|
32
|
+
if (typeof fieldPatternPredicate === 'function') {
|
|
33
|
+
this.fieldPatternPredicate = fieldPatternPredicate;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
ObjectElement(path) {
|
|
37
|
+
const objectElement = path.node;
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
objectElement.forEach((value, key, memberElement) => {
|
|
40
|
+
const keyValue = (0, _apidomCore.toValue)(key);
|
|
41
|
+
if (!this.ignoredFields.includes(keyValue) && this.fieldPatternPredicate(keyValue)) {
|
|
42
|
+
const specPath = this.specPath(value);
|
|
43
|
+
const patternedFieldElement = this.toRefractedElement(specPath, value);
|
|
44
|
+
const newMemberElement = new _apidomDatamodel.MemberElement(this.consume ? key : (0, _apidomDatamodel.cloneDeep)(key), patternedFieldElement);
|
|
45
|
+
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
46
|
+
newMemberElement.classes.push('patterned-field');
|
|
47
|
+
this.element.content.push(newMemberElement);
|
|
48
|
+
// consume: release processed generic subtree
|
|
49
|
+
if (this.consume && this.consumeSafe && !memberElement.isFrozen) memberElement.value = undefined;
|
|
50
|
+
} else if (!this.ignoredFields.includes(keyValue)) {
|
|
51
|
+
this.element.content.push(this.consume ? memberElement : (0, _apidomDatamodel.cloneDeep)(memberElement));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
this.copyMetaAndAttributes(objectElement, this.element);
|
|
55
|
+
path.stop();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
var _default = exports.default = PatternedFieldsVisitor;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { F as stubFalse } from 'ramda';
|
|
2
|
+
import { MemberElement, cloneDeep } from '@speclynx/apidom-datamodel';
|
|
3
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
4
|
+
import SpecificationVisitor from "../SpecificationVisitor.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class PatternedFieldsVisitor extends SpecificationVisitor {
|
|
12
|
+
specPath;
|
|
13
|
+
ignoredFields;
|
|
14
|
+
fieldPatternPredicate = stubFalse;
|
|
15
|
+
constructor({
|
|
16
|
+
specPath,
|
|
17
|
+
ignoredFields,
|
|
18
|
+
fieldPatternPredicate,
|
|
19
|
+
...rest
|
|
20
|
+
}) {
|
|
21
|
+
super({
|
|
22
|
+
...rest
|
|
23
|
+
});
|
|
24
|
+
this.specPath = specPath;
|
|
25
|
+
this.ignoredFields = ignoredFields || [];
|
|
26
|
+
if (typeof fieldPatternPredicate === 'function') {
|
|
27
|
+
this.fieldPatternPredicate = fieldPatternPredicate;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
ObjectElement(path) {
|
|
31
|
+
const objectElement = path.node;
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
objectElement.forEach((value, key, memberElement) => {
|
|
34
|
+
const keyValue = toValue(key);
|
|
35
|
+
if (!this.ignoredFields.includes(keyValue) && this.fieldPatternPredicate(keyValue)) {
|
|
36
|
+
const specPath = this.specPath(value);
|
|
37
|
+
const patternedFieldElement = this.toRefractedElement(specPath, value);
|
|
38
|
+
const newMemberElement = new MemberElement(this.consume ? key : cloneDeep(key), patternedFieldElement);
|
|
39
|
+
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
40
|
+
newMemberElement.classes.push('patterned-field');
|
|
41
|
+
this.element.content.push(newMemberElement);
|
|
42
|
+
// consume: release processed generic subtree
|
|
43
|
+
if (this.consume && this.consumeSafe && !memberElement.isFrozen) memberElement.value = undefined;
|
|
44
|
+
} else if (!this.ignoredFields.includes(keyValue)) {
|
|
45
|
+
this.element.content.push(this.consume ? memberElement : cloneDeep(memberElement));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
this.copyMetaAndAttributes(objectElement, this.element);
|
|
49
|
+
path.stop();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export default PatternedFieldsVisitor;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { F as stubFalse } from 'ramda';
|
|
2
|
+
import { ObjectElement, Element, MemberElement, cloneDeep } from '@speclynx/apidom-datamodel';
|
|
3
|
+
import { Path } from '@speclynx/apidom-traverse';
|
|
4
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
5
|
+
|
|
6
|
+
import SpecificationVisitor, { SpecificationVisitorOptions } from '../SpecificationVisitor.ts';
|
|
7
|
+
import { SpecPath } from './FixedFieldsVisitor.ts';
|
|
8
|
+
|
|
9
|
+
export type { SpecPath };
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export interface PatternedFieldsVisitorOptions extends SpecificationVisitorOptions {
|
|
15
|
+
readonly specPath: SpecPath;
|
|
16
|
+
readonly ignoredFields?: string[];
|
|
17
|
+
readonly fieldPatternPredicate?: (...args: unknown[]) => boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
class PatternedFieldsVisitor extends SpecificationVisitor {
|
|
24
|
+
protected specPath: SpecPath;
|
|
25
|
+
|
|
26
|
+
protected ignoredFields: string[];
|
|
27
|
+
|
|
28
|
+
protected fieldPatternPredicate: (value: unknown) => boolean = stubFalse;
|
|
29
|
+
|
|
30
|
+
constructor({
|
|
31
|
+
specPath,
|
|
32
|
+
ignoredFields,
|
|
33
|
+
fieldPatternPredicate,
|
|
34
|
+
...rest
|
|
35
|
+
}: PatternedFieldsVisitorOptions) {
|
|
36
|
+
super({ ...rest });
|
|
37
|
+
this.specPath = specPath;
|
|
38
|
+
this.ignoredFields = ignoredFields || [];
|
|
39
|
+
|
|
40
|
+
if (typeof fieldPatternPredicate === 'function') {
|
|
41
|
+
this.fieldPatternPredicate = fieldPatternPredicate;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
ObjectElement(path: Path<ObjectElement>) {
|
|
46
|
+
const objectElement = path.node;
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
objectElement.forEach((value: Element, key: Element, memberElement: MemberElement) => {
|
|
49
|
+
const keyValue = toValue(key) as string;
|
|
50
|
+
if (!this.ignoredFields.includes(keyValue) && this.fieldPatternPredicate(keyValue)) {
|
|
51
|
+
const specPath = this.specPath(value);
|
|
52
|
+
const patternedFieldElement = this.toRefractedElement(specPath, value);
|
|
53
|
+
const newMemberElement = new MemberElement(
|
|
54
|
+
this.consume ? key : cloneDeep(key),
|
|
55
|
+
patternedFieldElement,
|
|
56
|
+
);
|
|
57
|
+
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
58
|
+
newMemberElement.classes.push('patterned-field');
|
|
59
|
+
(this.element.content as Element[]).push(newMemberElement);
|
|
60
|
+
// consume: release processed generic subtree
|
|
61
|
+
if (this.consume && this.consumeSafe && !memberElement.isFrozen)
|
|
62
|
+
memberElement.value = undefined;
|
|
63
|
+
} else if (!this.ignoredFields.includes(keyValue)) {
|
|
64
|
+
(this.element.content as Element[]).push(
|
|
65
|
+
this.consume ? memberElement : cloneDeep(memberElement),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
this.copyMetaAndAttributes(objectElement, this.element);
|
|
71
|
+
|
|
72
|
+
path.stop();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default PatternedFieldsVisitor;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
6
|
+
var _bases = require("./bases.cjs");
|
|
7
|
+
var _predicates = require("../../predicates.cjs");
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
class AllOfVisitor extends _bases.AllOfVisitorBase {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super(options);
|
|
18
|
+
this.element = new _apidomDatamodel.ArrayElement();
|
|
19
|
+
this.element.classes.push('json-schema-allOf');
|
|
20
|
+
}
|
|
21
|
+
ArrayElement(path) {
|
|
22
|
+
const arrayElement = path.node;
|
|
23
|
+
arrayElement.forEach(item => {
|
|
24
|
+
const specPath = (0, _predicates.isJSONReferenceLikeElement)(item) ? ['document', 'objects', 'JSONReference'] : ['document', 'objects', 'JSONSchema'];
|
|
25
|
+
const element = this.toRefractedElement(specPath, item);
|
|
26
|
+
this.element.push(element);
|
|
27
|
+
});
|
|
28
|
+
this.copyMetaAndAttributes(arrayElement, this.element);
|
|
29
|
+
path.stop();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
var _default = exports.default = AllOfVisitor;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ArrayElement } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { AllOfVisitorBase } from "./bases.mjs";
|
|
3
|
+
import { isJSONReferenceLikeElement } from "../../predicates.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
class AllOfVisitor extends AllOfVisitorBase {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
super(options);
|
|
13
|
+
this.element = new ArrayElement();
|
|
14
|
+
this.element.classes.push('json-schema-allOf');
|
|
15
|
+
}
|
|
16
|
+
ArrayElement(path) {
|
|
17
|
+
const arrayElement = path.node;
|
|
18
|
+
arrayElement.forEach(item => {
|
|
19
|
+
const specPath = isJSONReferenceLikeElement(item) ? ['document', 'objects', 'JSONReference'] : ['document', 'objects', 'JSONSchema'];
|
|
20
|
+
const element = this.toRefractedElement(specPath, item);
|
|
21
|
+
this.element.push(element);
|
|
22
|
+
});
|
|
23
|
+
this.copyMetaAndAttributes(arrayElement, this.element);
|
|
24
|
+
path.stop();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export default AllOfVisitor;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ArrayElement, Element } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { Path } from '@speclynx/apidom-traverse';
|
|
3
|
+
|
|
4
|
+
import { FallbackVisitorOptions } from '../FallbackVisitor.ts';
|
|
5
|
+
import { SpecificationVisitorOptions } from '../SpecificationVisitor.ts';
|
|
6
|
+
import { ParentSchemaAwareVisitorOptions } from './ParentSchemaAwareVisitor.ts';
|
|
7
|
+
import { AllOfVisitorBase } from './bases.ts';
|
|
8
|
+
import { isJSONReferenceLikeElement } from '../../predicates.ts';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export interface AllOfVisitorOptions
|
|
14
|
+
extends SpecificationVisitorOptions, ParentSchemaAwareVisitorOptions, FallbackVisitorOptions {}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
class AllOfVisitor extends AllOfVisitorBase {
|
|
20
|
+
declare public readonly element: ArrayElement;
|
|
21
|
+
|
|
22
|
+
constructor(options: AllOfVisitorOptions) {
|
|
23
|
+
super(options);
|
|
24
|
+
this.element = new ArrayElement();
|
|
25
|
+
this.element.classes.push('json-schema-allOf');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
ArrayElement(path: Path<ArrayElement>) {
|
|
29
|
+
const arrayElement = path.node;
|
|
30
|
+
arrayElement.forEach((item: Element): void => {
|
|
31
|
+
const specPath = isJSONReferenceLikeElement(item)
|
|
32
|
+
? ['document', 'objects', 'JSONReference']
|
|
33
|
+
: ['document', 'objects', 'JSONSchema'];
|
|
34
|
+
const element = this.toRefractedElement(specPath, item);
|
|
35
|
+
this.element.push(element);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
this.copyMetaAndAttributes(arrayElement, this.element);
|
|
39
|
+
|
|
40
|
+
path.stop();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default AllOfVisitor;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
6
|
+
var _bases = require("./bases.cjs");
|
|
7
|
+
var _predicates = require("../../predicates.cjs");
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
class AnyOfVisitor extends _bases.AnyOfVisitorBase {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super(options);
|
|
18
|
+
this.element = new _apidomDatamodel.ArrayElement();
|
|
19
|
+
this.element.classes.push('json-schema-anyOf');
|
|
20
|
+
}
|
|
21
|
+
ArrayElement(path) {
|
|
22
|
+
const arrayElement = path.node;
|
|
23
|
+
arrayElement.forEach(item => {
|
|
24
|
+
const specPath = (0, _predicates.isJSONReferenceLikeElement)(item) ? ['document', 'objects', 'JSONReference'] : ['document', 'objects', 'JSONSchema'];
|
|
25
|
+
const element = this.toRefractedElement(specPath, item);
|
|
26
|
+
this.element.push(element);
|
|
27
|
+
});
|
|
28
|
+
this.copyMetaAndAttributes(arrayElement, this.element);
|
|
29
|
+
path.stop();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
var _default = exports.default = AnyOfVisitor;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ArrayElement } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { AnyOfVisitorBase } from "./bases.mjs";
|
|
3
|
+
import { isJSONReferenceLikeElement } from "../../predicates.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
class AnyOfVisitor extends AnyOfVisitorBase {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
super(options);
|
|
13
|
+
this.element = new ArrayElement();
|
|
14
|
+
this.element.classes.push('json-schema-anyOf');
|
|
15
|
+
}
|
|
16
|
+
ArrayElement(path) {
|
|
17
|
+
const arrayElement = path.node;
|
|
18
|
+
arrayElement.forEach(item => {
|
|
19
|
+
const specPath = isJSONReferenceLikeElement(item) ? ['document', 'objects', 'JSONReference'] : ['document', 'objects', 'JSONSchema'];
|
|
20
|
+
const element = this.toRefractedElement(specPath, item);
|
|
21
|
+
this.element.push(element);
|
|
22
|
+
});
|
|
23
|
+
this.copyMetaAndAttributes(arrayElement, this.element);
|
|
24
|
+
path.stop();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export default AnyOfVisitor;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ArrayElement, Element } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { Path } from '@speclynx/apidom-traverse';
|
|
3
|
+
|
|
4
|
+
import { FallbackVisitorOptions } from '../FallbackVisitor.ts';
|
|
5
|
+
import { SpecificationVisitorOptions } from '../SpecificationVisitor.ts';
|
|
6
|
+
import { ParentSchemaAwareVisitorOptions } from './ParentSchemaAwareVisitor.ts';
|
|
7
|
+
import { AnyOfVisitorBase } from './bases.ts';
|
|
8
|
+
import { isJSONReferenceLikeElement } from '../../predicates.ts';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export interface AnyOfVisitorOptions
|
|
14
|
+
extends SpecificationVisitorOptions, ParentSchemaAwareVisitorOptions, FallbackVisitorOptions {}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
class AnyOfVisitor extends AnyOfVisitorBase {
|
|
20
|
+
declare public readonly element: ArrayElement;
|
|
21
|
+
|
|
22
|
+
constructor(options: AnyOfVisitorOptions) {
|
|
23
|
+
super(options);
|
|
24
|
+
this.element = new ArrayElement();
|
|
25
|
+
this.element.classes.push('json-schema-anyOf');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
ArrayElement(path: Path<ArrayElement>) {
|
|
29
|
+
const arrayElement = path.node;
|
|
30
|
+
arrayElement.forEach((item: Element): void => {
|
|
31
|
+
const specPath = isJSONReferenceLikeElement(item)
|
|
32
|
+
? ['document', 'objects', 'JSONReference']
|
|
33
|
+
: ['document', 'objects', 'JSONSchema'];
|
|
34
|
+
const element = this.toRefractedElement(specPath, item);
|
|
35
|
+
this.element.push(element);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
this.copyMetaAndAttributes(arrayElement, this.element);
|
|
39
|
+
|
|
40
|
+
path.stop();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default AnyOfVisitor;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
6
|
+
var _bases = require("./bases.cjs");
|
|
7
|
+
var _predicates = require("../../predicates.cjs");
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
class DefinitionsVisitor extends _bases.DefinitionsVisitorBase {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super(options);
|
|
18
|
+
this.element = new _apidomDatamodel.ObjectElement();
|
|
19
|
+
this.element.classes.push('json-schema-definitions');
|
|
20
|
+
this.specPath = element => (0, _predicates.isJSONReferenceLikeElement)(element) ? ['document', 'objects', 'JSONReference'] : ['document', 'objects', 'JSONSchema'];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
var _default = exports.default = DefinitionsVisitor;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ObjectElement } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { DefinitionsVisitorBase } from "./bases.mjs";
|
|
3
|
+
import { isJSONReferenceLikeElement } from "../../predicates.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
class DefinitionsVisitor extends DefinitionsVisitorBase {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
super(options);
|
|
13
|
+
this.element = new ObjectElement();
|
|
14
|
+
this.element.classes.push('json-schema-definitions');
|
|
15
|
+
this.specPath = element => isJSONReferenceLikeElement(element) ? ['document', 'objects', 'JSONReference'] : ['document', 'objects', 'JSONSchema'];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export default DefinitionsVisitor;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ObjectElement } from '@speclynx/apidom-datamodel';
|
|
2
|
+
|
|
3
|
+
import { FallbackVisitorOptions } from '../FallbackVisitor.ts';
|
|
4
|
+
import { MapVisitorOptions, SpecPath } from '../generics/MapVisitor.ts';
|
|
5
|
+
import { ParentSchemaAwareVisitorOptions } from './ParentSchemaAwareVisitor.ts';
|
|
6
|
+
import { DefinitionsVisitorBase } from './bases.ts';
|
|
7
|
+
import { isJSONReferenceLikeElement } from '../../predicates.ts';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export interface DefinitionsVisitorOptions
|
|
13
|
+
extends MapVisitorOptions, ParentSchemaAwareVisitorOptions, FallbackVisitorOptions {}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
class DefinitionsVisitor extends DefinitionsVisitorBase {
|
|
19
|
+
declare public readonly element: ObjectElement;
|
|
20
|
+
|
|
21
|
+
declare protected readonly specPath: SpecPath<
|
|
22
|
+
['document', 'objects', 'JSONReference'] | ['document', 'objects', 'JSONSchema']
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
constructor(options: DefinitionsVisitorOptions) {
|
|
26
|
+
super(options);
|
|
27
|
+
this.element = new ObjectElement();
|
|
28
|
+
this.element.classes.push('json-schema-definitions');
|
|
29
|
+
this.specPath = (element: unknown) =>
|
|
30
|
+
isJSONReferenceLikeElement(element)
|
|
31
|
+
? ['document', 'objects', 'JSONReference']
|
|
32
|
+
: ['document', 'objects', 'JSONSchema'];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default DefinitionsVisitor;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
6
|
+
var _bases = require("./bases.cjs");
|
|
7
|
+
var _predicates = require("../../predicates.cjs");
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
class DependenciesVisitor extends _bases.DependenciesVisitorBase {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super(options);
|
|
18
|
+
this.element = new _apidomDatamodel.ObjectElement();
|
|
19
|
+
this.element.classes.push('json-schema-dependencies');
|
|
20
|
+
this.specPath = element => (0, _predicates.isJSONReferenceLikeElement)(element) ? ['document', 'objects', 'JSONReference'] : ['document', 'objects', 'JSONSchema'];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
var _default = exports.default = DependenciesVisitor;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ObjectElement } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { DependenciesVisitorBase } from "./bases.mjs";
|
|
3
|
+
import { isJSONReferenceLikeElement } from "../../predicates.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
class DependenciesVisitor extends DependenciesVisitorBase {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
super(options);
|
|
13
|
+
this.element = new ObjectElement();
|
|
14
|
+
this.element.classes.push('json-schema-dependencies');
|
|
15
|
+
this.specPath = element => isJSONReferenceLikeElement(element) ? ['document', 'objects', 'JSONReference'] : ['document', 'objects', 'JSONSchema'];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export default DependenciesVisitor;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ObjectElement } from '@speclynx/apidom-datamodel';
|
|
2
|
+
|
|
3
|
+
import { MapVisitorOptions, SpecPath } from '../generics/MapVisitor.ts';
|
|
4
|
+
import { FallbackVisitorOptions } from '../FallbackVisitor.ts';
|
|
5
|
+
import { ParentSchemaAwareVisitorOptions } from './ParentSchemaAwareVisitor.ts';
|
|
6
|
+
import { DependenciesVisitorBase } from './bases.ts';
|
|
7
|
+
import { isJSONReferenceLikeElement } from '../../predicates.ts';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export interface DependenciesVisitorOptions
|
|
13
|
+
extends MapVisitorOptions, ParentSchemaAwareVisitorOptions, FallbackVisitorOptions {}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
class DependenciesVisitor extends DependenciesVisitorBase {
|
|
19
|
+
declare public readonly element: ObjectElement;
|
|
20
|
+
|
|
21
|
+
declare protected readonly specPath: SpecPath<
|
|
22
|
+
['document', 'objects', 'JSONReference'] | ['document', 'objects', 'JSONSchema']
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
constructor(options: DependenciesVisitorOptions) {
|
|
26
|
+
super(options);
|
|
27
|
+
this.element = new ObjectElement();
|
|
28
|
+
this.element.classes.push('json-schema-dependencies');
|
|
29
|
+
this.specPath = (element: unknown) =>
|
|
30
|
+
isJSONReferenceLikeElement(element)
|
|
31
|
+
? ['document', 'objects', 'JSONReference']
|
|
32
|
+
: ['document', 'objects', 'JSONSchema'];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default DependenciesVisitor;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 _FallbackVisitor = _interopRequireDefault(require("../FallbackVisitor.cjs"));
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
class EnumVisitor extends _FallbackVisitor.default {
|
|
11
|
+
ArrayElement(path) {
|
|
12
|
+
super.enter(path);
|
|
13
|
+
this.element.classes.push('json-schema-enum');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
var _default = exports.default = EnumVisitor;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ArrayElement } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { Path } from '@speclynx/apidom-traverse';
|
|
3
|
+
|
|
4
|
+
import FallbackVisitor, { FallbackVisitorOptions } from '../FallbackVisitor.ts';
|
|
5
|
+
|
|
6
|
+
export type { FallbackVisitorOptions as EnumVisitorOptions };
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class EnumVisitor extends FallbackVisitor {
|
|
12
|
+
declare public readonly element: ArrayElement;
|
|
13
|
+
|
|
14
|
+
ArrayElement(path: Path<ArrayElement>) {
|
|
15
|
+
super.enter(path);
|
|
16
|
+
this.element.classes.push('json-schema-enum');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default EnumVisitor;
|