@speclynx/apidom-ns-json-schema-draft-4 3.2.0 → 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 +16 -0
- package/dist/apidom-ns-json-schema-draft-4.browser.js +24 -20
- package/package.json +5 -5
- package/src/elements/JSONReference.cjs +0 -29
- package/src/elements/JSONReference.mjs +0 -25
- package/src/elements/JSONSchema.cjs +0 -296
- package/src/elements/JSONSchema.mjs +0 -292
- package/src/elements/LinkDescription.cjs +0 -65
- package/src/elements/LinkDescription.mjs +0 -61
- package/src/elements/Media.cjs +0 -29
- package/src/elements/Media.mjs +0 -25
- package/src/index.cjs +0 -69
- package/src/index.mjs +0 -23
- package/src/media-types.cjs +0 -34
- package/src/media-types.mjs +0 -30
- package/src/namespace.cjs +0 -25
- package/src/namespace.mjs +0 -20
- package/src/predicates.cjs +0 -32
- package/src/predicates.mjs +0 -23
- package/src/refractor/index.cjs +0 -96
- package/src/refractor/index.mjs +0 -85
- package/src/refractor/inspect.cjs +0 -55
- package/src/refractor/inspect.mjs +0 -47
- package/src/refractor/plugins/replace-empty-element.cjs +0 -208
- package/src/refractor/plugins/replace-empty-element.mjs +0 -202
- package/src/refractor/predicates.cjs +0 -16
- package/src/refractor/predicates.mjs +0 -12
- package/src/refractor/specification.cjs +0 -193
- package/src/refractor/specification.mjs +0 -188
- package/src/refractor/toolbox.cjs +0 -28
- package/src/refractor/toolbox.mjs +0 -21
- package/src/refractor/visitors/FallbackVisitor.cjs +0 -25
- package/src/refractor/visitors/FallbackVisitor.mjs +0 -19
- 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 -57
- package/src/refractor/visitors/generics/FixedFieldsVisitor.mjs +0 -50
- package/src/refractor/visitors/generics/MapVisitor.cjs +0 -21
- package/src/refractor/visitors/generics/MapVisitor.mjs +0 -15
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.cjs +0 -58
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.mjs +0 -52
- package/src/refractor/visitors/json-schema/AllOfVisitor.cjs +0 -32
- package/src/refractor/visitors/json-schema/AllOfVisitor.mjs +0 -27
- package/src/refractor/visitors/json-schema/AnyOfVisitor.cjs +0 -32
- package/src/refractor/visitors/json-schema/AnyOfVisitor.mjs +0 -27
- package/src/refractor/visitors/json-schema/DefinitionsVisitor.cjs +0 -23
- package/src/refractor/visitors/json-schema/DefinitionsVisitor.mjs +0 -18
- package/src/refractor/visitors/json-schema/DependenciesVisitor.cjs +0 -23
- package/src/refractor/visitors/json-schema/DependenciesVisitor.mjs +0 -18
- package/src/refractor/visitors/json-schema/EnumVisitor.cjs +0 -16
- package/src/refractor/visitors/json-schema/EnumVisitor.mjs +0 -11
- package/src/refractor/visitors/json-schema/ItemsVisitor.cjs +0 -35
- package/src/refractor/visitors/json-schema/ItemsVisitor.mjs +0 -30
- package/src/refractor/visitors/json-schema/JSONSchemaOrJSONReferenceVisitor.cjs +0 -24
- package/src/refractor/visitors/json-schema/JSONSchemaOrJSONReferenceVisitor.mjs +0 -19
- package/src/refractor/visitors/json-schema/LinksVisitor.cjs +0 -30
- package/src/refractor/visitors/json-schema/LinksVisitor.mjs +0 -25
- package/src/refractor/visitors/json-schema/OneOfVisitor.cjs +0 -32
- package/src/refractor/visitors/json-schema/OneOfVisitor.mjs +0 -27
- package/src/refractor/visitors/json-schema/ParentSchemaAwareVisitor.cjs +0 -20
- package/src/refractor/visitors/json-schema/ParentSchemaAwareVisitor.mjs +0 -16
- package/src/refractor/visitors/json-schema/PatternPropertiesVisitor.cjs +0 -23
- package/src/refractor/visitors/json-schema/PatternPropertiesVisitor.mjs +0 -18
- package/src/refractor/visitors/json-schema/PropertiesVisitor.cjs +0 -23
- package/src/refractor/visitors/json-schema/PropertiesVisitor.mjs +0 -18
- package/src/refractor/visitors/json-schema/RequiredVisitor.cjs +0 -16
- package/src/refractor/visitors/json-schema/RequiredVisitor.mjs +0 -11
- package/src/refractor/visitors/json-schema/TypeVisitor.cjs +0 -20
- package/src/refractor/visitors/json-schema/TypeVisitor.mjs +0 -15
- package/src/refractor/visitors/json-schema/bases.cjs +0 -45
- package/src/refractor/visitors/json-schema/bases.mjs +0 -39
- package/src/refractor/visitors/json-schema/index.cjs +0 -65
- package/src/refractor/visitors/json-schema/index.mjs +0 -59
- package/src/refractor/visitors/json-schema/json-reference/$RefVisitor.cjs +0 -16
- package/src/refractor/visitors/json-schema/json-reference/$RefVisitor.mjs +0 -11
- package/src/refractor/visitors/json-schema/json-reference/index.cjs +0 -33
- package/src/refractor/visitors/json-schema/json-reference/index.mjs +0 -27
- package/src/refractor/visitors/json-schema/link-description/index.cjs +0 -23
- package/src/refractor/visitors/json-schema/link-description/index.mjs +0 -17
- package/src/refractor/visitors/json-schema/media/index.cjs +0 -23
- package/src/refractor/visitors/json-schema/media/index.mjs +0 -17
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { ArrayElement, ObjectElement, isArrayElement, isElement, isMemberElement, isStringElement, includesClasses, cloneDeep, SourceMapElement, StyleElement } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import { toValue } from '@speclynx/apidom-core';
|
|
3
|
-
import { getNodeType } from '@speclynx/apidom-traverse';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* JSON Schema Draft 4 specification elements.
|
|
7
|
-
*/
|
|
8
|
-
import JSONSchemaElement from "../../elements/JSONSchema.mjs";
|
|
9
|
-
import LinkDescriptionElement from "../../elements/LinkDescription.mjs";
|
|
10
|
-
import MediaElement from "../../elements/Media.mjs";
|
|
11
|
-
/**
|
|
12
|
-
* This plugin is specific to YAML 1.2 format, which allows defining key-value pairs
|
|
13
|
-
* with empty key, empty value, or both. If the value is not provided in YAML format,
|
|
14
|
-
* this plugin compensates for this missing value with the most appropriate semantic element type.
|
|
15
|
-
*
|
|
16
|
-
* https://yaml.org/spec/1.2.2/#72-empty-nodes
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
*
|
|
20
|
-
* ```yaml
|
|
21
|
-
* $schema: http://json-schema.org/draft-04/schema#
|
|
22
|
-
* items:
|
|
23
|
-
* ```
|
|
24
|
-
* Refracting result without this plugin:
|
|
25
|
-
*
|
|
26
|
-
* (JSONSchemaElement
|
|
27
|
-
* (MemberElement
|
|
28
|
-
* (StringElement)
|
|
29
|
-
* (StringElement))
|
|
30
|
-
* (MemberElement
|
|
31
|
-
* (StringElement)
|
|
32
|
-
* (StringElement))
|
|
33
|
-
*
|
|
34
|
-
* Refracting result with this plugin:
|
|
35
|
-
*
|
|
36
|
-
* (JSONSchemaElement
|
|
37
|
-
* (MemberElement
|
|
38
|
-
* (StringElement)
|
|
39
|
-
* (StringElement))
|
|
40
|
-
* (MemberElement
|
|
41
|
-
* (StringElement)
|
|
42
|
-
* (JSONSchemaElement))
|
|
43
|
-
*/
|
|
44
|
-
const isEmptyElement = element => isStringElement(element) && includesClasses(element, ['yaml-e-node', 'yaml-e-scalar']);
|
|
45
|
-
const schema = {
|
|
46
|
-
JSONSchemaDraft4Element: {
|
|
47
|
-
additionalItems(...args) {
|
|
48
|
-
return new JSONSchemaElement(...args);
|
|
49
|
-
},
|
|
50
|
-
items(...args) {
|
|
51
|
-
return new JSONSchemaElement(...args);
|
|
52
|
-
},
|
|
53
|
-
required(...args) {
|
|
54
|
-
const element = new ArrayElement(...args);
|
|
55
|
-
element.classes.push('json-schema-required');
|
|
56
|
-
return element;
|
|
57
|
-
},
|
|
58
|
-
properties(...args) {
|
|
59
|
-
const element = new ObjectElement(...args);
|
|
60
|
-
element.classes.push('json-schema-properties');
|
|
61
|
-
return element;
|
|
62
|
-
},
|
|
63
|
-
additionalProperties(...args) {
|
|
64
|
-
return new JSONSchemaElement(...args);
|
|
65
|
-
},
|
|
66
|
-
patternProperties(...args) {
|
|
67
|
-
const element = new ObjectElement(...args);
|
|
68
|
-
element.classes.push('json-schema-patternProperties');
|
|
69
|
-
return element;
|
|
70
|
-
},
|
|
71
|
-
dependencies(...args) {
|
|
72
|
-
const element = new ObjectElement(...args);
|
|
73
|
-
element.classes.push('json-schema-dependencies');
|
|
74
|
-
return element;
|
|
75
|
-
},
|
|
76
|
-
enum(...args) {
|
|
77
|
-
const element = new ArrayElement(...args);
|
|
78
|
-
element.classes.push('json-schema-enum');
|
|
79
|
-
return element;
|
|
80
|
-
},
|
|
81
|
-
allOf(...args) {
|
|
82
|
-
const element = new ArrayElement(...args);
|
|
83
|
-
element.classes.push('json-schema-allOf');
|
|
84
|
-
return element;
|
|
85
|
-
},
|
|
86
|
-
anyOf(...args) {
|
|
87
|
-
const element = new ArrayElement(...args);
|
|
88
|
-
element.classes.push('json-schema-anyOf');
|
|
89
|
-
return element;
|
|
90
|
-
},
|
|
91
|
-
oneOf(...args) {
|
|
92
|
-
const element = new ArrayElement(...args);
|
|
93
|
-
element.classes.push('json-schema-oneOf');
|
|
94
|
-
return element;
|
|
95
|
-
},
|
|
96
|
-
not(...args) {
|
|
97
|
-
return new JSONSchemaElement(...args);
|
|
98
|
-
},
|
|
99
|
-
definitions(...args) {
|
|
100
|
-
const element = new ObjectElement(...args);
|
|
101
|
-
element.classes.push('json-schema-definitions');
|
|
102
|
-
return element;
|
|
103
|
-
},
|
|
104
|
-
links(...args) {
|
|
105
|
-
const element = new ArrayElement(...args);
|
|
106
|
-
element.classes.push('json-schema-links');
|
|
107
|
-
return element;
|
|
108
|
-
},
|
|
109
|
-
media(...args) {
|
|
110
|
-
return new MediaElement(...args);
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
LinkDescriptionElement: {
|
|
114
|
-
targetSchema(...args) {
|
|
115
|
-
return new JSONSchemaElement(...args);
|
|
116
|
-
},
|
|
117
|
-
schema(...args) {
|
|
118
|
-
return new JSONSchemaElement(...args);
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
'json-schema-properties': {
|
|
122
|
-
'[key: *]': function key(...args) {
|
|
123
|
-
return new JSONSchemaElement(...args);
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
'json-schema-patternProperties': {
|
|
127
|
-
'[key: *]': function key(...args) {
|
|
128
|
-
return new JSONSchemaElement(...args);
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
'json-schema-dependencies': {
|
|
132
|
-
'[key: *]': function key(...args) {
|
|
133
|
-
return new JSONSchemaElement(...args);
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
'json-schema-allOf': {
|
|
137
|
-
'<*>': function asterisk(...args) {
|
|
138
|
-
return new JSONSchemaElement(...args);
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
'json-schema-anyOf': {
|
|
142
|
-
'<*>': function asterisk(...args) {
|
|
143
|
-
return new JSONSchemaElement(...args);
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
'json-schema-oneOf': {
|
|
147
|
-
'<*>': function asterisk(...args) {
|
|
148
|
-
return new JSONSchemaElement(...args);
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
'json-schema-definitions': {
|
|
152
|
-
'[key: *]': function key(...args) {
|
|
153
|
-
return new JSONSchemaElement(...args);
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
'json-schema-links': {
|
|
157
|
-
'<*>': function asterisk(...args) {
|
|
158
|
-
return new LinkDescriptionElement(...args);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
const findElementFactory = (ancestor, keyName) => {
|
|
163
|
-
const elementType = getNodeType(ancestor);
|
|
164
|
-
const classType = ancestor.isMetaEmpty ? undefined : ancestor.classes.at(0); // @ts-ignore
|
|
165
|
-
const keyMapping = schema[elementType] || schema[classType];
|
|
166
|
-
return typeof keyMapping === 'undefined' ? undefined : Object.hasOwn(keyMapping, '[key: *]') ? keyMapping['[key: *]'] : keyMapping[keyName];
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* @public
|
|
171
|
-
*/
|
|
172
|
-
const plugin = () => () => ({
|
|
173
|
-
visitor: {
|
|
174
|
-
StringElement(path) {
|
|
175
|
-
const element = path.node;
|
|
176
|
-
if (!isEmptyElement(element)) return;
|
|
177
|
-
|
|
178
|
-
// getAncestorNodes() returns [parent, grandparent, ..., root], so reverse to get [root, ..., parent]
|
|
179
|
-
const lineage = path.getAncestorNodes().reverse().filter(isElement);
|
|
180
|
-
const parentElement = lineage.at(-1);
|
|
181
|
-
let elementFactory;
|
|
182
|
-
let context;
|
|
183
|
-
if (isArrayElement(parentElement)) {
|
|
184
|
-
context = element;
|
|
185
|
-
elementFactory = findElementFactory(parentElement, '<*>');
|
|
186
|
-
} else if (isMemberElement(parentElement)) {
|
|
187
|
-
context = lineage.at(-2);
|
|
188
|
-
elementFactory = findElementFactory(context, toValue(parentElement.key));
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// no element factory found
|
|
192
|
-
if (typeof elementFactory !== 'function') return;
|
|
193
|
-
const replacement = elementFactory.call({
|
|
194
|
-
context
|
|
195
|
-
}, undefined, element.isMetaEmpty ? undefined : element.meta.cloneDeep(), element.isAttributesEmpty ? undefined : cloneDeep(element.attributes));
|
|
196
|
-
SourceMapElement.transfer(element, replacement);
|
|
197
|
-
StyleElement.transfer(element, replacement);
|
|
198
|
-
path.replaceWith(replacement);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
export default plugin;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.isJSONReferenceLikeElement = void 0;
|
|
5
|
-
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
const isJSONReferenceLikeElement = element => {
|
|
14
|
-
return (0, _apidomDatamodel.isObjectElement)(element) && element.hasKey('$ref');
|
|
15
|
-
};
|
|
16
|
-
exports.isJSONReferenceLikeElement = isJSONReferenceLikeElement;
|
|
@@ -1,193 +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 _FallbackVisitor = _interopRequireDefault(require("./visitors/FallbackVisitor.cjs"));
|
|
7
|
-
var _index = _interopRequireDefault(require("./visitors/json-schema/index.cjs"));
|
|
8
|
-
var _ItemsVisitor = _interopRequireDefault(require("./visitors/json-schema/ItemsVisitor.cjs"));
|
|
9
|
-
var _RequiredVisitor = _interopRequireDefault(require("./visitors/json-schema/RequiredVisitor.cjs"));
|
|
10
|
-
var _PropertiesVisitor = _interopRequireDefault(require("./visitors/json-schema/PropertiesVisitor.cjs"));
|
|
11
|
-
var _PatternPropertiesVisitor = _interopRequireDefault(require("./visitors/json-schema/PatternPropertiesVisitor.cjs"));
|
|
12
|
-
var _DependenciesVisitor = _interopRequireDefault(require("./visitors/json-schema/DependenciesVisitor.cjs"));
|
|
13
|
-
var _EnumVisitor = _interopRequireDefault(require("./visitors/json-schema/EnumVisitor.cjs"));
|
|
14
|
-
var _TypeVisitor = _interopRequireDefault(require("./visitors/json-schema/TypeVisitor.cjs"));
|
|
15
|
-
var _AllOfVisitor = _interopRequireDefault(require("./visitors/json-schema/AllOfVisitor.cjs"));
|
|
16
|
-
var _AnyOfVisitor = _interopRequireDefault(require("./visitors/json-schema/AnyOfVisitor.cjs"));
|
|
17
|
-
var _OneOfVisitor = _interopRequireDefault(require("./visitors/json-schema/OneOfVisitor.cjs"));
|
|
18
|
-
var _DefinitionsVisitor = _interopRequireDefault(require("./visitors/json-schema/DefinitionsVisitor.cjs"));
|
|
19
|
-
var _LinksVisitor = _interopRequireDefault(require("./visitors/json-schema/LinksVisitor.cjs"));
|
|
20
|
-
var _index2 = _interopRequireDefault(require("./visitors/json-schema/json-reference/index.cjs"));
|
|
21
|
-
var _$RefVisitor = _interopRequireDefault(require("./visitors/json-schema/json-reference/$RefVisitor.cjs"));
|
|
22
|
-
var _JSONSchemaOrJSONReferenceVisitor = _interopRequireDefault(require("./visitors/json-schema/JSONSchemaOrJSONReferenceVisitor.cjs"));
|
|
23
|
-
var _index3 = _interopRequireDefault(require("./visitors/json-schema/media/index.cjs"));
|
|
24
|
-
var _index4 = _interopRequireDefault(require("./visitors/json-schema/link-description/index.cjs"));
|
|
25
|
-
/**
|
|
26
|
-
* Specification object allows us to have complete control over visitors
|
|
27
|
-
* when traversing the ApiDOM.
|
|
28
|
-
* Specification also allows us to create amended refractors from
|
|
29
|
-
* existing ones by manipulating it.
|
|
30
|
-
*
|
|
31
|
-
* Note: Specification object allows to use absolute internal JSON pointers.
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
const specification = {
|
|
35
|
-
visitors: {
|
|
36
|
-
value: _FallbackVisitor.default,
|
|
37
|
-
JSONSchemaOrJSONReferenceVisitor: _JSONSchemaOrJSONReferenceVisitor.default,
|
|
38
|
-
document: {
|
|
39
|
-
objects: {
|
|
40
|
-
JSONSchema: {
|
|
41
|
-
element: 'jSONSchemaDraft4',
|
|
42
|
-
$visitor: _index.default,
|
|
43
|
-
fixedFields: {
|
|
44
|
-
// core vocabulary
|
|
45
|
-
id: {
|
|
46
|
-
$ref: '#/visitors/value',
|
|
47
|
-
alias: 'idField'
|
|
48
|
-
},
|
|
49
|
-
$schema: {
|
|
50
|
-
$ref: '#/visitors/value'
|
|
51
|
-
},
|
|
52
|
-
// validation vocabulary
|
|
53
|
-
// validation keywords for numeric instances (number and integer)
|
|
54
|
-
multipleOf: {
|
|
55
|
-
$ref: '#/visitors/value'
|
|
56
|
-
},
|
|
57
|
-
maximum: {
|
|
58
|
-
$ref: '#/visitors/value'
|
|
59
|
-
},
|
|
60
|
-
exclusiveMaximum: {
|
|
61
|
-
$ref: '#/visitors/value'
|
|
62
|
-
},
|
|
63
|
-
minimum: {
|
|
64
|
-
$ref: '#/visitors/value'
|
|
65
|
-
},
|
|
66
|
-
exclusiveMinimum: {
|
|
67
|
-
$ref: '#/visitors/value'
|
|
68
|
-
},
|
|
69
|
-
// validation keywords for strings
|
|
70
|
-
maxLength: {
|
|
71
|
-
$ref: '#/visitors/value'
|
|
72
|
-
},
|
|
73
|
-
minLength: {
|
|
74
|
-
$ref: '#/visitors/value'
|
|
75
|
-
},
|
|
76
|
-
pattern: {
|
|
77
|
-
$ref: '#/visitors/value'
|
|
78
|
-
},
|
|
79
|
-
// validation keywords for arrays
|
|
80
|
-
additionalItems: _JSONSchemaOrJSONReferenceVisitor.default,
|
|
81
|
-
items: {
|
|
82
|
-
$visitor: _ItemsVisitor.default,
|
|
83
|
-
alias: 'itemsField'
|
|
84
|
-
},
|
|
85
|
-
maxItems: {
|
|
86
|
-
$ref: '#/visitors/value'
|
|
87
|
-
},
|
|
88
|
-
minItems: {
|
|
89
|
-
$ref: '#/visitors/value'
|
|
90
|
-
},
|
|
91
|
-
uniqueItems: {
|
|
92
|
-
$ref: '#/visitors/value'
|
|
93
|
-
},
|
|
94
|
-
// validation keywords for objects
|
|
95
|
-
maxProperties: {
|
|
96
|
-
$ref: '#/visitors/value'
|
|
97
|
-
},
|
|
98
|
-
minProperties: {
|
|
99
|
-
$ref: '#/visitors/value'
|
|
100
|
-
},
|
|
101
|
-
required: _RequiredVisitor.default,
|
|
102
|
-
properties: _PropertiesVisitor.default,
|
|
103
|
-
additionalProperties: _JSONSchemaOrJSONReferenceVisitor.default,
|
|
104
|
-
patternProperties: _PatternPropertiesVisitor.default,
|
|
105
|
-
dependencies: _DependenciesVisitor.default,
|
|
106
|
-
// validation keywords for any instance type
|
|
107
|
-
enum: _EnumVisitor.default,
|
|
108
|
-
type: _TypeVisitor.default,
|
|
109
|
-
allOf: _AllOfVisitor.default,
|
|
110
|
-
anyOf: _AnyOfVisitor.default,
|
|
111
|
-
oneOf: _OneOfVisitor.default,
|
|
112
|
-
not: _JSONSchemaOrJSONReferenceVisitor.default,
|
|
113
|
-
definitions: _DefinitionsVisitor.default,
|
|
114
|
-
// metadata keywords
|
|
115
|
-
title: {
|
|
116
|
-
$ref: '#/visitors/value'
|
|
117
|
-
},
|
|
118
|
-
description: {
|
|
119
|
-
$ref: '#/visitors/value'
|
|
120
|
-
},
|
|
121
|
-
default: {
|
|
122
|
-
$ref: '#/visitors/value'
|
|
123
|
-
},
|
|
124
|
-
// semantic validation with "format"
|
|
125
|
-
format: {
|
|
126
|
-
$ref: '#/visitors/value'
|
|
127
|
-
},
|
|
128
|
-
// JSON Hyper-Schema
|
|
129
|
-
base: {
|
|
130
|
-
$ref: '#/visitors/value'
|
|
131
|
-
},
|
|
132
|
-
links: {
|
|
133
|
-
$visitor: _LinksVisitor.default,
|
|
134
|
-
alias: 'linksField'
|
|
135
|
-
},
|
|
136
|
-
media: {
|
|
137
|
-
$ref: '#/visitors/document/objects/Media'
|
|
138
|
-
},
|
|
139
|
-
readOnly: {
|
|
140
|
-
$ref: '#/visitors/value'
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
JSONReference: {
|
|
145
|
-
element: 'jSONReference',
|
|
146
|
-
$visitor: _index2.default,
|
|
147
|
-
fixedFields: {
|
|
148
|
-
$ref: _$RefVisitor.default
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
Media: {
|
|
152
|
-
element: 'media',
|
|
153
|
-
$visitor: _index3.default,
|
|
154
|
-
fixedFields: {
|
|
155
|
-
binaryEncoding: {
|
|
156
|
-
$ref: '#/visitors/value'
|
|
157
|
-
},
|
|
158
|
-
type: {
|
|
159
|
-
$ref: '#/visitors/value'
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
LinkDescription: {
|
|
164
|
-
element: 'linkDescription',
|
|
165
|
-
$visitor: _index4.default,
|
|
166
|
-
fixedFields: {
|
|
167
|
-
href: {
|
|
168
|
-
$ref: '#/visitors/value'
|
|
169
|
-
},
|
|
170
|
-
rel: {
|
|
171
|
-
$ref: '#/visitors/value'
|
|
172
|
-
},
|
|
173
|
-
title: {
|
|
174
|
-
$ref: '#/visitors/value'
|
|
175
|
-
},
|
|
176
|
-
targetSchema: _JSONSchemaOrJSONReferenceVisitor.default,
|
|
177
|
-
mediaType: {
|
|
178
|
-
$ref: '#/visitors/value'
|
|
179
|
-
},
|
|
180
|
-
method: {
|
|
181
|
-
$ref: '#/visitors/value'
|
|
182
|
-
},
|
|
183
|
-
encType: {
|
|
184
|
-
$ref: '#/visitors/value'
|
|
185
|
-
},
|
|
186
|
-
schema: _JSONSchemaOrJSONReferenceVisitor.default
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
var _default = exports.default = specification;
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import FallbackVisitor from "./visitors/FallbackVisitor.mjs";
|
|
2
|
-
import JSONSchemaVisitor from "./visitors/json-schema/index.mjs";
|
|
3
|
-
import JSONSchemaItemsVisitor from "./visitors/json-schema/ItemsVisitor.mjs";
|
|
4
|
-
import JSONSchemaRequiredVisitor from "./visitors/json-schema/RequiredVisitor.mjs";
|
|
5
|
-
import JSONSchemaPropertiesVisitor from "./visitors/json-schema/PropertiesVisitor.mjs";
|
|
6
|
-
import JSONSchemaPatternPropertiesVisitor from "./visitors/json-schema/PatternPropertiesVisitor.mjs";
|
|
7
|
-
import JSONSchemaDependenciesVisitor from "./visitors/json-schema/DependenciesVisitor.mjs";
|
|
8
|
-
import JSONSchemaEnumVisitor from "./visitors/json-schema/EnumVisitor.mjs";
|
|
9
|
-
import JSONSchemaTypeVisitor from "./visitors/json-schema/TypeVisitor.mjs";
|
|
10
|
-
import JSONSchemaAllOfVisitor from "./visitors/json-schema/AllOfVisitor.mjs";
|
|
11
|
-
import JSONSchemaAnyOfVisitor from "./visitors/json-schema/AnyOfVisitor.mjs";
|
|
12
|
-
import JSONSchemaOneOfVisitor from "./visitors/json-schema/OneOfVisitor.mjs";
|
|
13
|
-
import JSONSchemaDefinitionsVisitor from "./visitors/json-schema/DefinitionsVisitor.mjs";
|
|
14
|
-
import JSONSchemaLinksVisitor from "./visitors/json-schema/LinksVisitor.mjs";
|
|
15
|
-
import JSONReferenceVisitor from "./visitors/json-schema/json-reference/index.mjs";
|
|
16
|
-
import JSONReference$RefVisitor from "./visitors/json-schema/json-reference/$RefVisitor.mjs";
|
|
17
|
-
import JSONSchemaOrJSONReferenceVisitor from "./visitors/json-schema/JSONSchemaOrJSONReferenceVisitor.mjs";
|
|
18
|
-
import MediaVisitor from "./visitors/json-schema/media/index.mjs";
|
|
19
|
-
import LinkDescriptionVisitor from "./visitors/json-schema/link-description/index.mjs";
|
|
20
|
-
/**
|
|
21
|
-
* Specification object allows us to have complete control over visitors
|
|
22
|
-
* when traversing the ApiDOM.
|
|
23
|
-
* Specification also allows us to create amended refractors from
|
|
24
|
-
* existing ones by manipulating it.
|
|
25
|
-
*
|
|
26
|
-
* Note: Specification object allows to use absolute internal JSON pointers.
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
const specification = {
|
|
30
|
-
visitors: {
|
|
31
|
-
value: FallbackVisitor,
|
|
32
|
-
JSONSchemaOrJSONReferenceVisitor,
|
|
33
|
-
document: {
|
|
34
|
-
objects: {
|
|
35
|
-
JSONSchema: {
|
|
36
|
-
element: 'jSONSchemaDraft4',
|
|
37
|
-
$visitor: JSONSchemaVisitor,
|
|
38
|
-
fixedFields: {
|
|
39
|
-
// core vocabulary
|
|
40
|
-
id: {
|
|
41
|
-
$ref: '#/visitors/value',
|
|
42
|
-
alias: 'idField'
|
|
43
|
-
},
|
|
44
|
-
$schema: {
|
|
45
|
-
$ref: '#/visitors/value'
|
|
46
|
-
},
|
|
47
|
-
// validation vocabulary
|
|
48
|
-
// validation keywords for numeric instances (number and integer)
|
|
49
|
-
multipleOf: {
|
|
50
|
-
$ref: '#/visitors/value'
|
|
51
|
-
},
|
|
52
|
-
maximum: {
|
|
53
|
-
$ref: '#/visitors/value'
|
|
54
|
-
},
|
|
55
|
-
exclusiveMaximum: {
|
|
56
|
-
$ref: '#/visitors/value'
|
|
57
|
-
},
|
|
58
|
-
minimum: {
|
|
59
|
-
$ref: '#/visitors/value'
|
|
60
|
-
},
|
|
61
|
-
exclusiveMinimum: {
|
|
62
|
-
$ref: '#/visitors/value'
|
|
63
|
-
},
|
|
64
|
-
// validation keywords for strings
|
|
65
|
-
maxLength: {
|
|
66
|
-
$ref: '#/visitors/value'
|
|
67
|
-
},
|
|
68
|
-
minLength: {
|
|
69
|
-
$ref: '#/visitors/value'
|
|
70
|
-
},
|
|
71
|
-
pattern: {
|
|
72
|
-
$ref: '#/visitors/value'
|
|
73
|
-
},
|
|
74
|
-
// validation keywords for arrays
|
|
75
|
-
additionalItems: JSONSchemaOrJSONReferenceVisitor,
|
|
76
|
-
items: {
|
|
77
|
-
$visitor: JSONSchemaItemsVisitor,
|
|
78
|
-
alias: 'itemsField'
|
|
79
|
-
},
|
|
80
|
-
maxItems: {
|
|
81
|
-
$ref: '#/visitors/value'
|
|
82
|
-
},
|
|
83
|
-
minItems: {
|
|
84
|
-
$ref: '#/visitors/value'
|
|
85
|
-
},
|
|
86
|
-
uniqueItems: {
|
|
87
|
-
$ref: '#/visitors/value'
|
|
88
|
-
},
|
|
89
|
-
// validation keywords for objects
|
|
90
|
-
maxProperties: {
|
|
91
|
-
$ref: '#/visitors/value'
|
|
92
|
-
},
|
|
93
|
-
minProperties: {
|
|
94
|
-
$ref: '#/visitors/value'
|
|
95
|
-
},
|
|
96
|
-
required: JSONSchemaRequiredVisitor,
|
|
97
|
-
properties: JSONSchemaPropertiesVisitor,
|
|
98
|
-
additionalProperties: JSONSchemaOrJSONReferenceVisitor,
|
|
99
|
-
patternProperties: JSONSchemaPatternPropertiesVisitor,
|
|
100
|
-
dependencies: JSONSchemaDependenciesVisitor,
|
|
101
|
-
// validation keywords for any instance type
|
|
102
|
-
enum: JSONSchemaEnumVisitor,
|
|
103
|
-
type: JSONSchemaTypeVisitor,
|
|
104
|
-
allOf: JSONSchemaAllOfVisitor,
|
|
105
|
-
anyOf: JSONSchemaAnyOfVisitor,
|
|
106
|
-
oneOf: JSONSchemaOneOfVisitor,
|
|
107
|
-
not: JSONSchemaOrJSONReferenceVisitor,
|
|
108
|
-
definitions: JSONSchemaDefinitionsVisitor,
|
|
109
|
-
// metadata keywords
|
|
110
|
-
title: {
|
|
111
|
-
$ref: '#/visitors/value'
|
|
112
|
-
},
|
|
113
|
-
description: {
|
|
114
|
-
$ref: '#/visitors/value'
|
|
115
|
-
},
|
|
116
|
-
default: {
|
|
117
|
-
$ref: '#/visitors/value'
|
|
118
|
-
},
|
|
119
|
-
// semantic validation with "format"
|
|
120
|
-
format: {
|
|
121
|
-
$ref: '#/visitors/value'
|
|
122
|
-
},
|
|
123
|
-
// JSON Hyper-Schema
|
|
124
|
-
base: {
|
|
125
|
-
$ref: '#/visitors/value'
|
|
126
|
-
},
|
|
127
|
-
links: {
|
|
128
|
-
$visitor: JSONSchemaLinksVisitor,
|
|
129
|
-
alias: 'linksField'
|
|
130
|
-
},
|
|
131
|
-
media: {
|
|
132
|
-
$ref: '#/visitors/document/objects/Media'
|
|
133
|
-
},
|
|
134
|
-
readOnly: {
|
|
135
|
-
$ref: '#/visitors/value'
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
JSONReference: {
|
|
140
|
-
element: 'jSONReference',
|
|
141
|
-
$visitor: JSONReferenceVisitor,
|
|
142
|
-
fixedFields: {
|
|
143
|
-
$ref: JSONReference$RefVisitor
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
Media: {
|
|
147
|
-
element: 'media',
|
|
148
|
-
$visitor: MediaVisitor,
|
|
149
|
-
fixedFields: {
|
|
150
|
-
binaryEncoding: {
|
|
151
|
-
$ref: '#/visitors/value'
|
|
152
|
-
},
|
|
153
|
-
type: {
|
|
154
|
-
$ref: '#/visitors/value'
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
LinkDescription: {
|
|
159
|
-
element: 'linkDescription',
|
|
160
|
-
$visitor: LinkDescriptionVisitor,
|
|
161
|
-
fixedFields: {
|
|
162
|
-
href: {
|
|
163
|
-
$ref: '#/visitors/value'
|
|
164
|
-
},
|
|
165
|
-
rel: {
|
|
166
|
-
$ref: '#/visitors/value'
|
|
167
|
-
},
|
|
168
|
-
title: {
|
|
169
|
-
$ref: '#/visitors/value'
|
|
170
|
-
},
|
|
171
|
-
targetSchema: JSONSchemaOrJSONReferenceVisitor,
|
|
172
|
-
mediaType: {
|
|
173
|
-
$ref: '#/visitors/value'
|
|
174
|
-
},
|
|
175
|
-
method: {
|
|
176
|
-
$ref: '#/visitors/value'
|
|
177
|
-
},
|
|
178
|
-
encType: {
|
|
179
|
-
$ref: '#/visitors/value'
|
|
180
|
-
},
|
|
181
|
-
schema: JSONSchemaOrJSONReferenceVisitor
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
export default specification;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
5
|
-
exports.__esModule = true;
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
8
|
-
var jsonSchemaDraft4Predicates = _interopRequireWildcard(require("../predicates.cjs"));
|
|
9
|
-
var refractorPredicates = _interopRequireWildcard(require("./predicates.cjs"));
|
|
10
|
-
var _namespace = _interopRequireDefault(require("../namespace.cjs"));
|
|
11
|
-
/**
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const createToolbox = () => {
|
|
16
|
-
const namespace = new _apidomDatamodel.Namespace();
|
|
17
|
-
const predicates = {
|
|
18
|
-
...refractorPredicates,
|
|
19
|
-
...jsonSchemaDraft4Predicates,
|
|
20
|
-
isStringElement: _apidomDatamodel.isStringElement
|
|
21
|
-
};
|
|
22
|
-
namespace.use(_namespace.default);
|
|
23
|
-
return {
|
|
24
|
-
predicates,
|
|
25
|
-
namespace
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
var _default = exports.default = createToolbox;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { isStringElement, Namespace } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import * as jsonSchemaDraft4Predicates from "../predicates.mjs";
|
|
3
|
-
import * as refractorPredicates from "./predicates.mjs";
|
|
4
|
-
import jsonSchemaDraft4Namespace from "../namespace.mjs";
|
|
5
|
-
/**
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
const createToolbox = () => {
|
|
9
|
-
const namespace = new Namespace();
|
|
10
|
-
const predicates = {
|
|
11
|
-
...refractorPredicates,
|
|
12
|
-
...jsonSchemaDraft4Predicates,
|
|
13
|
-
isStringElement
|
|
14
|
-
};
|
|
15
|
-
namespace.use(jsonSchemaDraft4Namespace);
|
|
16
|
-
return {
|
|
17
|
-
predicates,
|
|
18
|
-
namespace
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export default createToolbox;
|
|
@@ -1,25 +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 _Visitor = _interopRequireDefault(require("./Visitor.cjs"));
|
|
8
|
-
/**
|
|
9
|
-
* This visitor is responsible for falling back to current traversed element
|
|
10
|
-
* Given JSONSchemaVisitor expects ObjectElement to be traversed. If
|
|
11
|
-
* different Element is provided FallBackVisitor is responsible to assigning
|
|
12
|
-
* this Element as current element.
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
class FallbackVisitor extends _Visitor.default {
|
|
20
|
-
enter(path) {
|
|
21
|
-
this.element = this.consume ? path.node : (0, _apidomDatamodel.cloneDeep)(path.node);
|
|
22
|
-
path.stop();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
var _default = exports.default = FallbackVisitor;
|