@speclynx/apidom-ns-json-schema-draft-6 1.12.2 → 2.1.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 +25 -0
- package/NOTICE +16 -7
- package/README.md +24 -24
- package/dist/apidom-ns-json-schema-draft-6.browser.js +1 -1
- package/package.json +11 -9
- package/src/elements/JSONSchema.cjs +14 -6
- package/src/elements/JSONSchema.mjs +14 -6
- package/src/elements/LinkDescription.cjs +4 -0
- package/src/elements/LinkDescription.mjs +4 -0
- package/src/index.cjs +8 -21
- package/src/index.mjs +2 -5
- package/src/predicates.cjs +4 -15
- package/src/predicates.mjs +2 -15
- package/src/refractor/index.cjs +38 -17
- package/src/refractor/index.mjs +33 -15
- package/src/refractor/inspect.cjs +47 -0
- package/src/refractor/inspect.mjs +39 -0
- package/src/refractor/plugins/replace-empty-element.cjs +28 -26
- package/src/refractor/plugins/replace-empty-element.mjs +14 -11
- package/src/refractor/specification.cjs +14 -2
- package/src/refractor/specification.mjs +14 -2
- package/src/refractor/toolbox.cjs +8 -3
- package/src/refractor/toolbox.mjs +6 -2
- package/src/refractor/visitors/json-schema/ExamplesVisitor.cjs +2 -3
- package/src/refractor/visitors/json-schema/ExamplesVisitor.mjs +2 -3
- package/src/refractor/visitors/json-schema/ItemsVisitor.cjs +3 -4
- package/src/refractor/visitors/json-schema/ItemsVisitor.mjs +3 -4
- package/src/refractor/visitors/json-schema/index.cjs +4 -3
- package/src/refractor/visitors/json-schema/index.mjs +4 -3
- package/src/refractor/visitors/json-schema/link-description/index.cjs +2 -0
- package/src/refractor/visitors/json-schema/link-description/index.mjs +2 -0
- package/types/apidom-ns-json-schema-draft-6.d.ts +90 -245
- package/src/refractor/registration.cjs +0 -13
- package/src/refractor/registration.mjs +0 -6
- package/src/traversal/visitor.cjs +0 -17
- package/src/traversal/visitor.mjs +0 -13
|
@@ -3,15 +3,12 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.default = void 0;
|
|
6
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
6
7
|
var _apidomCore = require("@speclynx/apidom-core");
|
|
8
|
+
var _apidomTraverse = require("@speclynx/apidom-traverse");
|
|
7
9
|
var _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-4");
|
|
8
10
|
var _JSONSchema = _interopRequireDefault(require("../../elements/JSONSchema.cjs"));
|
|
9
11
|
var _LinkDescription = _interopRequireDefault(require("../../elements/LinkDescription.cjs"));
|
|
10
|
-
var _visitor = require("../../traversal/visitor.cjs");
|
|
11
|
-
/**
|
|
12
|
-
* JSON Schema Draft 6 specification elements.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
12
|
/**
|
|
16
13
|
* This plugin is specific to YAML 1.2 format, which allows defining key-value pairs
|
|
17
14
|
* with empty key, empty value, or both. If the value is not provided in YAML format,
|
|
@@ -46,7 +43,7 @@ var _visitor = require("../../traversal/visitor.cjs");
|
|
|
46
43
|
* (JSONSchemaElement))
|
|
47
44
|
*/
|
|
48
45
|
|
|
49
|
-
const isEmptyElement = element => (0,
|
|
46
|
+
const isEmptyElement = element => (0, _apidomDatamodel.isStringElement)(element) && (0, _apidomDatamodel.includesClasses)(element, ['yaml-e-node', 'yaml-e-scalar']);
|
|
50
47
|
const schema = {
|
|
51
48
|
JSONSchemaDraft6Element: {
|
|
52
49
|
additionalItems(...args) {
|
|
@@ -59,12 +56,12 @@ const schema = {
|
|
|
59
56
|
return new _JSONSchema.default(...args);
|
|
60
57
|
},
|
|
61
58
|
required(...args) {
|
|
62
|
-
const element = new
|
|
59
|
+
const element = new _apidomDatamodel.ArrayElement(...args);
|
|
63
60
|
element.classes.push('json-schema-required');
|
|
64
61
|
return element;
|
|
65
62
|
},
|
|
66
63
|
properties(...args) {
|
|
67
|
-
const element = new
|
|
64
|
+
const element = new _apidomDatamodel.ObjectElement(...args);
|
|
68
65
|
element.classes.push('json-schema-properties');
|
|
69
66
|
return element;
|
|
70
67
|
},
|
|
@@ -72,12 +69,12 @@ const schema = {
|
|
|
72
69
|
return new _JSONSchema.default(...args);
|
|
73
70
|
},
|
|
74
71
|
patternProperties(...args) {
|
|
75
|
-
const element = new
|
|
72
|
+
const element = new _apidomDatamodel.ObjectElement(...args);
|
|
76
73
|
element.classes.push('json-schema-patternProperties');
|
|
77
74
|
return element;
|
|
78
75
|
},
|
|
79
76
|
dependencies(...args) {
|
|
80
|
-
const element = new
|
|
77
|
+
const element = new _apidomDatamodel.ObjectElement(...args);
|
|
81
78
|
element.classes.push('json-schema-dependencies');
|
|
82
79
|
return element;
|
|
83
80
|
},
|
|
@@ -85,22 +82,22 @@ const schema = {
|
|
|
85
82
|
return new _JSONSchema.default(...args);
|
|
86
83
|
},
|
|
87
84
|
enum(...args) {
|
|
88
|
-
const element = new
|
|
85
|
+
const element = new _apidomDatamodel.ArrayElement(...args);
|
|
89
86
|
element.classes.push('json-schema-enum');
|
|
90
87
|
return element;
|
|
91
88
|
},
|
|
92
89
|
allOf(...args) {
|
|
93
|
-
const element = new
|
|
90
|
+
const element = new _apidomDatamodel.ArrayElement(...args);
|
|
94
91
|
element.classes.push('json-schema-allOf');
|
|
95
92
|
return element;
|
|
96
93
|
},
|
|
97
94
|
anyOf(...args) {
|
|
98
|
-
const element = new
|
|
95
|
+
const element = new _apidomDatamodel.ArrayElement(...args);
|
|
99
96
|
element.classes.push('json-schema-anyOf');
|
|
100
97
|
return element;
|
|
101
98
|
},
|
|
102
99
|
oneOf(...args) {
|
|
103
|
-
const element = new
|
|
100
|
+
const element = new _apidomDatamodel.ArrayElement(...args);
|
|
104
101
|
element.classes.push('json-schema-oneOf');
|
|
105
102
|
return element;
|
|
106
103
|
},
|
|
@@ -108,17 +105,17 @@ const schema = {
|
|
|
108
105
|
return new _JSONSchema.default(...args);
|
|
109
106
|
},
|
|
110
107
|
definitions(...args) {
|
|
111
|
-
const element = new
|
|
108
|
+
const element = new _apidomDatamodel.ObjectElement(...args);
|
|
112
109
|
element.classes.push('json-schema-definitions');
|
|
113
110
|
return element;
|
|
114
111
|
},
|
|
115
112
|
examples(...args) {
|
|
116
|
-
const element = new
|
|
113
|
+
const element = new _apidomDatamodel.ArrayElement(...args);
|
|
117
114
|
element.classes.push('json-schema-examples');
|
|
118
115
|
return element;
|
|
119
116
|
},
|
|
120
117
|
links(...args) {
|
|
121
|
-
const element = new
|
|
118
|
+
const element = new _apidomDatamodel.ArrayElement(...args);
|
|
122
119
|
element.classes.push('json-schema-links');
|
|
123
120
|
return element;
|
|
124
121
|
},
|
|
@@ -179,7 +176,7 @@ const schema = {
|
|
|
179
176
|
}
|
|
180
177
|
};
|
|
181
178
|
const findElementFactory = (ancestor, keyName) => {
|
|
182
|
-
const elementType = (0,
|
|
179
|
+
const elementType = (0, _apidomTraverse.getNodeType)(ancestor); // @ts-ignore
|
|
183
180
|
const keyMapping = schema[elementType] || schema[(0, _apidomCore.toValue)(ancestor.classes.first)];
|
|
184
181
|
return typeof keyMapping === 'undefined' ? undefined : Object.hasOwn(keyMapping, '[key: *]') ? keyMapping['[key: *]'] : keyMapping[keyName];
|
|
185
182
|
};
|
|
@@ -189,25 +186,30 @@ const findElementFactory = (ancestor, keyName) => {
|
|
|
189
186
|
*/
|
|
190
187
|
const plugin = () => () => ({
|
|
191
188
|
visitor: {
|
|
192
|
-
StringElement(
|
|
193
|
-
|
|
194
|
-
|
|
189
|
+
StringElement(path) {
|
|
190
|
+
const element = path.node;
|
|
191
|
+
if (!isEmptyElement(element)) return;
|
|
192
|
+
|
|
193
|
+
// getAncestorNodes() returns [parent, grandparent, ..., root], so reverse to get [root, ..., parent]
|
|
194
|
+
const lineage = path.getAncestorNodes().reverse().filter(_apidomDatamodel.isElement);
|
|
195
195
|
const parentElement = lineage.at(-1);
|
|
196
196
|
let elementFactory;
|
|
197
197
|
let context;
|
|
198
|
-
if ((0,
|
|
198
|
+
if ((0, _apidomDatamodel.isArrayElement)(parentElement)) {
|
|
199
199
|
context = element;
|
|
200
200
|
elementFactory = findElementFactory(parentElement, '<*>');
|
|
201
|
-
} else if ((0,
|
|
201
|
+
} else if ((0, _apidomDatamodel.isMemberElement)(parentElement)) {
|
|
202
202
|
context = lineage.at(-2);
|
|
203
203
|
elementFactory = findElementFactory(context, (0, _apidomCore.toValue)(parentElement.key));
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
// no element factory found
|
|
207
|
-
if (typeof elementFactory !== 'function') return
|
|
208
|
-
|
|
207
|
+
if (typeof elementFactory !== 'function') return;
|
|
208
|
+
const replacement = elementFactory.call({
|
|
209
209
|
context
|
|
210
|
-
}, undefined, (0,
|
|
210
|
+
}, undefined, (0, _apidomDatamodel.cloneDeep)(element.meta), (0, _apidomDatamodel.cloneDeep)(element.attributes));
|
|
211
|
+
_apidomDatamodel.SourceMapElement.transfer(element, replacement);
|
|
212
|
+
path.replaceWith(replacement);
|
|
211
213
|
}
|
|
212
214
|
}
|
|
213
215
|
});
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { ArrayElement, ObjectElement,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
1
|
+
import { ArrayElement, ObjectElement, isArrayElement, isElement, isMemberElement, isStringElement, includesClasses, cloneDeep, SourceMapElement } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
3
|
+
import { getNodeType } from '@speclynx/apidom-traverse';
|
|
5
4
|
import { MediaElement } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
6
5
|
import JSONSchemaElement from "../../elements/JSONSchema.mjs";
|
|
7
6
|
import LinkDescriptionElement from "../../elements/LinkDescription.mjs";
|
|
8
|
-
import { getNodeType } from "../../traversal/visitor.mjs";
|
|
9
7
|
/**
|
|
10
8
|
* This plugin is specific to YAML 1.2 format, which allows defining key-value pairs
|
|
11
9
|
* with empty key, empty value, or both. If the value is not provided in YAML format,
|
|
@@ -39,7 +37,7 @@ import { getNodeType } from "../../traversal/visitor.mjs";
|
|
|
39
37
|
* (StringElement)
|
|
40
38
|
* (JSONSchemaElement))
|
|
41
39
|
*/
|
|
42
|
-
const isEmptyElement = element => isStringElement(element) && includesClasses(['yaml-e-node', 'yaml-e-scalar']
|
|
40
|
+
const isEmptyElement = element => isStringElement(element) && includesClasses(element, ['yaml-e-node', 'yaml-e-scalar']);
|
|
43
41
|
const schema = {
|
|
44
42
|
JSONSchemaDraft6Element: {
|
|
45
43
|
additionalItems(...args) {
|
|
@@ -182,9 +180,12 @@ const findElementFactory = (ancestor, keyName) => {
|
|
|
182
180
|
*/
|
|
183
181
|
const plugin = () => () => ({
|
|
184
182
|
visitor: {
|
|
185
|
-
StringElement(
|
|
186
|
-
|
|
187
|
-
|
|
183
|
+
StringElement(path) {
|
|
184
|
+
const element = path.node;
|
|
185
|
+
if (!isEmptyElement(element)) return;
|
|
186
|
+
|
|
187
|
+
// getAncestorNodes() returns [parent, grandparent, ..., root], so reverse to get [root, ..., parent]
|
|
188
|
+
const lineage = path.getAncestorNodes().reverse().filter(isElement);
|
|
188
189
|
const parentElement = lineage.at(-1);
|
|
189
190
|
let elementFactory;
|
|
190
191
|
let context;
|
|
@@ -197,10 +198,12 @@ const plugin = () => () => ({
|
|
|
197
198
|
}
|
|
198
199
|
|
|
199
200
|
// no element factory found
|
|
200
|
-
if (typeof elementFactory !== 'function') return
|
|
201
|
-
|
|
201
|
+
if (typeof elementFactory !== 'function') return;
|
|
202
|
+
const replacement = elementFactory.call({
|
|
202
203
|
context
|
|
203
204
|
}, undefined, cloneDeep(element.meta), cloneDeep(element.attributes));
|
|
205
|
+
SourceMapElement.transfer(element, replacement);
|
|
206
|
+
path.replaceWith(replacement);
|
|
204
207
|
}
|
|
205
208
|
}
|
|
206
209
|
});
|
|
@@ -11,7 +11,19 @@ var _ExamplesVisitor = _interopRequireDefault(require("./visitors/json-schema/Ex
|
|
|
11
11
|
var _index2 = _interopRequireDefault(require("./visitors/json-schema/link-description/index.cjs"));
|
|
12
12
|
const specification = (0, _ramda.pipe)(
|
|
13
13
|
// JSON Schema object modifications
|
|
14
|
-
(0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', '
|
|
14
|
+
(0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'element'], 'jSONSchemaDraft6'), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', '$visitor'], _index.default), (0, _ramda.dissocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'id']), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', '$id'], {
|
|
15
|
+
$ref: '#/visitors/value'
|
|
16
|
+
}), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'contains'], {
|
|
17
|
+
$visitor: _apidomNsJsonSchemaDraft.specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor,
|
|
18
|
+
alias: 'containsField'
|
|
19
|
+
}), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'items'], {
|
|
20
|
+
$visitor: _ItemsVisitor.default,
|
|
21
|
+
alias: 'itemsField'
|
|
22
|
+
}), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'propertyNames'], _apidomNsJsonSchemaDraft.specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'const'], {
|
|
23
|
+
$ref: '#/visitors/value'
|
|
24
|
+
}), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'examples'], _ExamplesVisitor.default),
|
|
15
25
|
// Link Description object modifications
|
|
16
|
-
(0, _ramda.assocPath)(['visitors', 'document', 'objects', 'LinkDescription', '$visitor'], _index2.default), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'hrefSchema'], _apidomNsJsonSchemaDraft.specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), (0, _ramda.dissocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'schema']), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionSchema'], _apidomNsJsonSchemaDraft.specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), (0, _ramda.dissocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'method']), (0, _ramda.dissocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'encType']), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionEncType'],
|
|
26
|
+
(0, _ramda.assocPath)(['visitors', 'document', 'objects', 'LinkDescription', '$visitor'], _index2.default), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'hrefSchema'], _apidomNsJsonSchemaDraft.specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), (0, _ramda.dissocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'schema']), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionSchema'], _apidomNsJsonSchemaDraft.specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), (0, _ramda.dissocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'method']), (0, _ramda.dissocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'encType']), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionEncType'], {
|
|
27
|
+
$ref: '#/visitors/value'
|
|
28
|
+
}))(_apidomNsJsonSchemaDraft.specificationObj);
|
|
17
29
|
var _default = exports.default = specification;
|
|
@@ -6,7 +6,19 @@ import JSONSchemaExamplesVisitor from "./visitors/json-schema/ExamplesVisitor.mj
|
|
|
6
6
|
import LinkDescriptionVisitor from "./visitors/json-schema/link-description/index.mjs";
|
|
7
7
|
const specification = pipe(
|
|
8
8
|
// JSON Schema object modifications
|
|
9
|
-
assocPath(['visitors', 'document', 'objects', 'JSONSchema', '
|
|
9
|
+
assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'element'], 'jSONSchemaDraft6'), assocPath(['visitors', 'document', 'objects', 'JSONSchema', '$visitor'], JSONSchemaVisitor), dissocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'id']), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', '$id'], {
|
|
10
|
+
$ref: '#/visitors/value'
|
|
11
|
+
}), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'contains'], {
|
|
12
|
+
$visitor: specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor,
|
|
13
|
+
alias: 'containsField'
|
|
14
|
+
}), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'items'], {
|
|
15
|
+
$visitor: JSONSchemaItemsVisitor,
|
|
16
|
+
alias: 'itemsField'
|
|
17
|
+
}), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'propertyNames'], specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'const'], {
|
|
18
|
+
$ref: '#/visitors/value'
|
|
19
|
+
}), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'examples'], JSONSchemaExamplesVisitor),
|
|
10
20
|
// Link Description object modifications
|
|
11
|
-
assocPath(['visitors', 'document', 'objects', 'LinkDescription', '$visitor'], LinkDescriptionVisitor), assocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'hrefSchema'], specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), dissocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'schema']), assocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionSchema'], specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), dissocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'method']), dissocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'encType']), assocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionEncType'],
|
|
21
|
+
assocPath(['visitors', 'document', 'objects', 'LinkDescription', '$visitor'], LinkDescriptionVisitor), assocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'hrefSchema'], specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), dissocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'schema']), assocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionSchema'], specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), dissocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'method']), dissocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'encType']), assocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionEncType'], {
|
|
22
|
+
$ref: '#/visitors/value'
|
|
23
|
+
}))(specificationObj);
|
|
12
24
|
export default specification;
|
|
@@ -4,15 +4,20 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
5
5
|
exports.__esModule = true;
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
8
8
|
var jsonSchemaDraft6Predicates = _interopRequireWildcard(require("../predicates.cjs"));
|
|
9
9
|
var _namespace = _interopRequireDefault(require("../namespace.cjs"));
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
|
|
10
14
|
const createToolbox = () => {
|
|
11
|
-
const namespace =
|
|
15
|
+
const namespace = new _apidomDatamodel.Namespace();
|
|
12
16
|
const predicates = {
|
|
13
17
|
...jsonSchemaDraft6Predicates,
|
|
14
|
-
isStringElement:
|
|
18
|
+
isStringElement: _apidomDatamodel.isStringElement
|
|
15
19
|
};
|
|
20
|
+
namespace.use(_namespace.default);
|
|
16
21
|
return {
|
|
17
22
|
predicates,
|
|
18
23
|
namespace
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isStringElement, Namespace } from '@speclynx/apidom-datamodel';
|
|
2
2
|
import * as jsonSchemaDraft6Predicates from "../predicates.mjs";
|
|
3
3
|
import jsonSchemaDraft6Namespace from "../namespace.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
4
7
|
const createToolbox = () => {
|
|
5
|
-
const namespace =
|
|
8
|
+
const namespace = new Namespace();
|
|
6
9
|
const predicates = {
|
|
7
10
|
...jsonSchemaDraft6Predicates,
|
|
8
11
|
isStringElement
|
|
9
12
|
};
|
|
13
|
+
namespace.use(jsonSchemaDraft6Namespace);
|
|
10
14
|
return {
|
|
11
15
|
predicates,
|
|
12
16
|
namespace
|
|
@@ -7,10 +7,9 @@ var _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-4"
|
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
9
|
class ExamplesVisitor extends _apidomNsJsonSchemaDraft.FallbackVisitor {
|
|
10
|
-
ArrayElement(
|
|
11
|
-
|
|
10
|
+
ArrayElement(path) {
|
|
11
|
+
this.enter(path);
|
|
12
12
|
this.element.classes.push('json-schema-examples');
|
|
13
|
-
return result;
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
var _default = exports.default = ExamplesVisitor;
|
|
@@ -3,10 +3,9 @@ import { FallbackVisitor } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
|
3
3
|
* @public
|
|
4
4
|
*/
|
|
5
5
|
class ExamplesVisitor extends FallbackVisitor {
|
|
6
|
-
ArrayElement(
|
|
7
|
-
|
|
6
|
+
ArrayElement(path) {
|
|
7
|
+
this.enter(path);
|
|
8
8
|
this.element.classes.push('json-schema-examples');
|
|
9
|
-
return result;
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
11
|
export default ExamplesVisitor;
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
|
-
var _apidomCore = require("@speclynx/apidom-core");
|
|
6
5
|
var _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-4");
|
|
7
6
|
/**
|
|
8
7
|
* @public
|
|
9
8
|
*/
|
|
10
9
|
class ItemsVisitor extends _apidomNsJsonSchemaDraft.ItemsVisitor {
|
|
11
|
-
BooleanElement(
|
|
12
|
-
this.element = this.toRefractedElement(['document', 'objects', 'JSONSchema'],
|
|
13
|
-
|
|
10
|
+
BooleanElement(path) {
|
|
11
|
+
this.element = this.toRefractedElement(['document', 'objects', 'JSONSchema'], path.node);
|
|
12
|
+
path.stop();
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
var _default = exports.default = ItemsVisitor;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { BREAK } from '@speclynx/apidom-core';
|
|
2
1
|
import { ItemsVisitor as JSONSchemaDraft4ItemsVisitor } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
3
2
|
/**
|
|
4
3
|
* @public
|
|
5
4
|
*/
|
|
6
5
|
class ItemsVisitor extends JSONSchemaDraft4ItemsVisitor {
|
|
7
|
-
BooleanElement(
|
|
8
|
-
this.element = this.toRefractedElement(['document', 'objects', 'JSONSchema'],
|
|
9
|
-
|
|
6
|
+
BooleanElement(path) {
|
|
7
|
+
this.element = this.toRefractedElement(['document', 'objects', 'JSONSchema'], path.node);
|
|
8
|
+
path.stop();
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
11
|
export default ItemsVisitor;
|
|
@@ -9,6 +9,8 @@ var _JSONSchema = _interopRequireDefault(require("../../../elements/JSONSchema.c
|
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
11
|
class JSONSchemaVisitor extends _apidomNsJsonSchemaDraft.JSONSchemaVisitor {
|
|
12
|
+
// @ts-expect-error - element can be BooleanElement (boolean schemas introduced in draft-6)
|
|
13
|
+
|
|
12
14
|
constructor(options) {
|
|
13
15
|
super(options);
|
|
14
16
|
this.element = new _JSONSchema.default();
|
|
@@ -16,10 +18,9 @@ class JSONSchemaVisitor extends _apidomNsJsonSchemaDraft.JSONSchemaVisitor {
|
|
|
16
18
|
get defaultDialectIdentifier() {
|
|
17
19
|
return 'http://json-schema.org/draft-06/schema#';
|
|
18
20
|
}
|
|
19
|
-
BooleanElement(
|
|
20
|
-
|
|
21
|
+
BooleanElement(path) {
|
|
22
|
+
this.enter(path);
|
|
21
23
|
this.element.classes.push('boolean-json-schema');
|
|
22
|
-
return result;
|
|
23
24
|
}
|
|
24
25
|
handleSchemaIdentifier(objectElement, identifierKeyword = '$id') {
|
|
25
26
|
return super.handleSchemaIdentifier(objectElement, identifierKeyword);
|
|
@@ -4,6 +4,8 @@ import JSONSchemaElement from "../../../elements/JSONSchema.mjs";
|
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
6
|
class JSONSchemaVisitor extends JSONSchemaDraft4Visitor {
|
|
7
|
+
// @ts-expect-error - element can be BooleanElement (boolean schemas introduced in draft-6)
|
|
8
|
+
|
|
7
9
|
constructor(options) {
|
|
8
10
|
super(options);
|
|
9
11
|
this.element = new JSONSchemaElement();
|
|
@@ -11,10 +13,9 @@ class JSONSchemaVisitor extends JSONSchemaDraft4Visitor {
|
|
|
11
13
|
get defaultDialectIdentifier() {
|
|
12
14
|
return 'http://json-schema.org/draft-06/schema#';
|
|
13
15
|
}
|
|
14
|
-
BooleanElement(
|
|
15
|
-
|
|
16
|
+
BooleanElement(path) {
|
|
17
|
+
this.enter(path);
|
|
16
18
|
this.element.classes.push('boolean-json-schema');
|
|
17
|
-
return result;
|
|
18
19
|
}
|
|
19
20
|
handleSchemaIdentifier(objectElement, identifierKeyword = '$id') {
|
|
20
21
|
return super.handleSchemaIdentifier(objectElement, identifierKeyword);
|
|
@@ -9,6 +9,8 @@ var _LinkDescription = _interopRequireDefault(require("../../../../elements/Link
|
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
11
|
class LinkDescriptionVisitor extends _apidomNsJsonSchemaDraft.LinkDescriptionVisitor {
|
|
12
|
+
// @ts-expect-error - widening type to include BooleanElement (boolean schemas introduced in draft-6)
|
|
13
|
+
|
|
12
14
|
constructor(options) {
|
|
13
15
|
super(options);
|
|
14
16
|
this.element = new _LinkDescription.default();
|
|
@@ -4,6 +4,8 @@ import LinkDescriptionElement from "../../../../elements/LinkDescription.mjs";
|
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
6
|
class LinkDescriptionVisitor extends JSONSchemaDraft4LinkDescriptionVisitor {
|
|
7
|
+
// @ts-expect-error - widening type to include BooleanElement (boolean schemas introduced in draft-6)
|
|
8
|
+
|
|
7
9
|
constructor(options) {
|
|
8
10
|
super(options);
|
|
9
11
|
this.element = new LinkDescriptionElement();
|