@speclynx/apidom-ns-json-schema-draft-6 4.0.2 → 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 +6 -0
- package/package.json +8 -9
- package/src/elements/JSONSchema.cjs +124 -0
- package/src/elements/JSONSchema.mjs +121 -0
- package/src/elements/JSONSchema.ts +158 -0
- package/src/elements/LinkDescription.cjs +60 -0
- package/src/elements/LinkDescription.mjs +56 -0
- package/src/elements/LinkDescription.ts +100 -0
- package/src/index.cjs +46 -0
- package/src/index.mjs +14 -0
- package/src/index.ts +85 -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 +24 -0
- package/src/namespace.mjs +19 -0
- package/src/namespace.ts +23 -0
- package/src/predicates.cjs +30 -0
- package/src/predicates.mjs +21 -0
- package/src/predicates.ts +25 -0
- package/src/refractor/index.cjs +76 -0
- package/src/refractor/index.mjs +67 -0
- package/src/refractor/index.ts +90 -0
- package/src/refractor/inspect.cjs +47 -0
- package/src/refractor/inspect.mjs +39 -0
- package/src/refractor/inspect.ts +51 -0
- package/src/refractor/plugins/replace-empty-element.cjs +218 -0
- package/src/refractor/plugins/replace-empty-element.mjs +212 -0
- package/src/refractor/plugins/replace-empty-element.ts +243 -0
- package/src/refractor/specification.cjs +29 -0
- package/src/refractor/specification.mjs +24 -0
- package/src/refractor/specification.ts +58 -0
- package/src/refractor/toolbox.cjs +26 -0
- package/src/refractor/toolbox.mjs +19 -0
- package/src/refractor/toolbox.ts +23 -0
- package/src/refractor/visitors/json-schema/ExamplesVisitor.cjs +15 -0
- package/src/refractor/visitors/json-schema/ExamplesVisitor.mjs +11 -0
- package/src/refractor/visitors/json-schema/ExamplesVisitor.ts +19 -0
- package/src/refractor/visitors/json-schema/ItemsVisitor.cjs +15 -0
- package/src/refractor/visitors/json-schema/ItemsVisitor.mjs +11 -0
- package/src/refractor/visitors/json-schema/ItemsVisitor.ts +21 -0
- package/src/refractor/visitors/json-schema/index.cjs +29 -0
- package/src/refractor/visitors/json-schema/index.mjs +24 -0
- package/src/refractor/visitors/json-schema/index.ts +38 -0
- package/src/refractor/visitors/json-schema/link-description/index.cjs +19 -0
- package/src/refractor/visitors/json-schema/link-description/index.mjs +14 -0
- package/src/refractor/visitors/json-schema/link-description/index.ts +23 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArrayElement,
|
|
3
|
+
ObjectElement,
|
|
4
|
+
StringElement,
|
|
5
|
+
isArrayElement,
|
|
6
|
+
isElement,
|
|
7
|
+
isMemberElement,
|
|
8
|
+
isStringElement,
|
|
9
|
+
includesClasses,
|
|
10
|
+
cloneDeep,
|
|
11
|
+
SourceMapElement,
|
|
12
|
+
StyleElement,
|
|
13
|
+
} from '@speclynx/apidom-datamodel';
|
|
14
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
15
|
+
import { Path, getNodeType } from '@speclynx/apidom-traverse';
|
|
16
|
+
import { MediaElement } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
17
|
+
|
|
18
|
+
import JSONSchemaElement from '../../elements/JSONSchema.ts';
|
|
19
|
+
import LinkDescriptionElement from '../../elements/LinkDescription.ts';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* This plugin is specific to YAML 1.2 format, which allows defining key-value pairs
|
|
23
|
+
* with empty key, empty value, or both. If the value is not provided in YAML format,
|
|
24
|
+
* this plugin compensates for this missing value with the most appropriate semantic element type.
|
|
25
|
+
*
|
|
26
|
+
* https://yaml.org/spec/1.2.2/#72-empty-nodes
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
*
|
|
30
|
+
* ```yaml
|
|
31
|
+
* $schema: http://json-schema.org/draft-06/schema#
|
|
32
|
+
* items:
|
|
33
|
+
* ```
|
|
34
|
+
* Refracting result without this plugin:
|
|
35
|
+
*
|
|
36
|
+
* (JSONSchemaElement
|
|
37
|
+
* (MemberElement
|
|
38
|
+
* (StringElement)
|
|
39
|
+
* (StringElement))
|
|
40
|
+
* (MemberElement
|
|
41
|
+
* (StringElement)
|
|
42
|
+
* (StringElement))
|
|
43
|
+
*
|
|
44
|
+
* Refracting result with this plugin:
|
|
45
|
+
*
|
|
46
|
+
* (JSONSchemaElement
|
|
47
|
+
* (MemberElement
|
|
48
|
+
* (StringElement)
|
|
49
|
+
* (StringElement))
|
|
50
|
+
* (MemberElement
|
|
51
|
+
* (StringElement)
|
|
52
|
+
* (JSONSchemaElement))
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
const isEmptyElement = (element: any) =>
|
|
56
|
+
isStringElement(element) && includesClasses(element, ['yaml-e-node', 'yaml-e-scalar']);
|
|
57
|
+
|
|
58
|
+
const schema = {
|
|
59
|
+
JSONSchemaDraft6Element: {
|
|
60
|
+
additionalItems(...args: any[]) {
|
|
61
|
+
return new JSONSchemaElement(...args);
|
|
62
|
+
},
|
|
63
|
+
items(...args: any[]) {
|
|
64
|
+
return new JSONSchemaElement(...args);
|
|
65
|
+
},
|
|
66
|
+
contains(...args: any[]) {
|
|
67
|
+
return new JSONSchemaElement(...args);
|
|
68
|
+
},
|
|
69
|
+
required(...args: any[]) {
|
|
70
|
+
const element = new ArrayElement(...args);
|
|
71
|
+
element.classes.push('json-schema-required');
|
|
72
|
+
return element;
|
|
73
|
+
},
|
|
74
|
+
properties(...args: any[]) {
|
|
75
|
+
const element = new ObjectElement(...args);
|
|
76
|
+
element.classes.push('json-schema-properties');
|
|
77
|
+
return element;
|
|
78
|
+
},
|
|
79
|
+
additionalProperties(...args: any[]) {
|
|
80
|
+
return new JSONSchemaElement(...args);
|
|
81
|
+
},
|
|
82
|
+
patternProperties(...args: any[]) {
|
|
83
|
+
const element = new ObjectElement(...args);
|
|
84
|
+
element.classes.push('json-schema-patternProperties');
|
|
85
|
+
return element;
|
|
86
|
+
},
|
|
87
|
+
dependencies(...args: any[]) {
|
|
88
|
+
const element = new ObjectElement(...args);
|
|
89
|
+
element.classes.push('json-schema-dependencies');
|
|
90
|
+
return element;
|
|
91
|
+
},
|
|
92
|
+
propertyNames(...args: any[]) {
|
|
93
|
+
return new JSONSchemaElement(...args);
|
|
94
|
+
},
|
|
95
|
+
enum(...args: any[]) {
|
|
96
|
+
const element = new ArrayElement(...args);
|
|
97
|
+
element.classes.push('json-schema-enum');
|
|
98
|
+
return element;
|
|
99
|
+
},
|
|
100
|
+
allOf(...args: any[]) {
|
|
101
|
+
const element = new ArrayElement(...args);
|
|
102
|
+
element.classes.push('json-schema-allOf');
|
|
103
|
+
return element;
|
|
104
|
+
},
|
|
105
|
+
anyOf(...args: any[]) {
|
|
106
|
+
const element = new ArrayElement(...args);
|
|
107
|
+
element.classes.push('json-schema-anyOf');
|
|
108
|
+
return element;
|
|
109
|
+
},
|
|
110
|
+
oneOf(...args: any[]) {
|
|
111
|
+
const element = new ArrayElement(...args);
|
|
112
|
+
element.classes.push('json-schema-oneOf');
|
|
113
|
+
return element;
|
|
114
|
+
},
|
|
115
|
+
not(...args: any[]) {
|
|
116
|
+
return new JSONSchemaElement(...args);
|
|
117
|
+
},
|
|
118
|
+
definitions(...args: any[]) {
|
|
119
|
+
const element = new ObjectElement(...args);
|
|
120
|
+
element.classes.push('json-schema-definitions');
|
|
121
|
+
return element;
|
|
122
|
+
},
|
|
123
|
+
examples(...args: any[]) {
|
|
124
|
+
const element = new ArrayElement(...args);
|
|
125
|
+
element.classes.push('json-schema-examples');
|
|
126
|
+
return element;
|
|
127
|
+
},
|
|
128
|
+
links(...args: any[]) {
|
|
129
|
+
const element = new ArrayElement(...args);
|
|
130
|
+
element.classes.push('json-schema-links');
|
|
131
|
+
return element;
|
|
132
|
+
},
|
|
133
|
+
media(...args: any[]) {
|
|
134
|
+
return new MediaElement(...args);
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
LinkDescriptionElement: {
|
|
138
|
+
hrefSchema(...args: any[]) {
|
|
139
|
+
return new JSONSchemaElement(...args);
|
|
140
|
+
},
|
|
141
|
+
targetSchema(...args: any[]) {
|
|
142
|
+
return new JSONSchemaElement(...args);
|
|
143
|
+
},
|
|
144
|
+
submissionSchema(...args: any[]) {
|
|
145
|
+
return new JSONSchemaElement(...args);
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
'json-schema-properties': {
|
|
149
|
+
'[key: *]': function key(...args: any[]) {
|
|
150
|
+
return new JSONSchemaElement(...args);
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
'json-schema-patternProperties': {
|
|
154
|
+
'[key: *]': function key(...args: any[]) {
|
|
155
|
+
return new JSONSchemaElement(...args);
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
'json-schema-dependencies': {
|
|
159
|
+
'[key: *]': function key(...args: any[]) {
|
|
160
|
+
return new JSONSchemaElement(...args);
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
'json-schema-allOf': {
|
|
164
|
+
'<*>': function asterisk(...args: any[]) {
|
|
165
|
+
return new JSONSchemaElement(...args);
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
'json-schema-anyOf': {
|
|
169
|
+
'<*>': function asterisk(...args: any[]) {
|
|
170
|
+
return new JSONSchemaElement(...args);
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
'json-schema-oneOf': {
|
|
174
|
+
'<*>': function asterisk(...args: any[]) {
|
|
175
|
+
return new JSONSchemaElement(...args);
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
'json-schema-definitions': {
|
|
179
|
+
'[key: *]': function key(...args: any[]) {
|
|
180
|
+
return new JSONSchemaElement(...args);
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
'json-schema-links': {
|
|
184
|
+
'<*>': function asterisk(...args: any[]) {
|
|
185
|
+
return new LinkDescriptionElement(...args);
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const findElementFactory = (ancestor: any, keyName: string) => {
|
|
191
|
+
const elementType = getNodeType(ancestor);
|
|
192
|
+
const classType = ancestor.isMetaEmpty ? undefined : ancestor.classes.at(0); // @ts-ignore
|
|
193
|
+
const keyMapping = schema[elementType] || schema[classType];
|
|
194
|
+
|
|
195
|
+
return typeof keyMapping === 'undefined'
|
|
196
|
+
? undefined
|
|
197
|
+
: Object.hasOwn(keyMapping, '[key: *]')
|
|
198
|
+
? keyMapping['[key: *]']
|
|
199
|
+
: keyMapping[keyName];
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* @public
|
|
204
|
+
*/
|
|
205
|
+
const plugin = () => () => ({
|
|
206
|
+
visitor: {
|
|
207
|
+
StringElement(path: Path<StringElement>) {
|
|
208
|
+
const element = path.node;
|
|
209
|
+
|
|
210
|
+
if (!isEmptyElement(element)) return;
|
|
211
|
+
|
|
212
|
+
// getAncestorNodes() returns [parent, grandparent, ..., root], so reverse to get [root, ..., parent]
|
|
213
|
+
const lineage = path.getAncestorNodes().reverse().filter(isElement);
|
|
214
|
+
const parentElement = lineage.at(-1);
|
|
215
|
+
let elementFactory;
|
|
216
|
+
let context;
|
|
217
|
+
|
|
218
|
+
if (isArrayElement(parentElement)) {
|
|
219
|
+
context = element;
|
|
220
|
+
elementFactory = findElementFactory(parentElement, '<*>');
|
|
221
|
+
} else if (isMemberElement(parentElement)) {
|
|
222
|
+
context = lineage.at(-2);
|
|
223
|
+
elementFactory = findElementFactory(context, toValue(parentElement.key) as string);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// no element factory found
|
|
227
|
+
if (typeof elementFactory !== 'function') return;
|
|
228
|
+
|
|
229
|
+
const replacement = elementFactory.call(
|
|
230
|
+
{ context },
|
|
231
|
+
undefined,
|
|
232
|
+
element.isMetaEmpty ? undefined : element.meta.cloneDeep(),
|
|
233
|
+
element.isAttributesEmpty ? undefined : cloneDeep(element.attributes),
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
SourceMapElement.transfer(element, replacement);
|
|
237
|
+
StyleElement.transfer(element, replacement);
|
|
238
|
+
path.replaceWith(replacement);
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
export default plugin;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-4");
|
|
8
|
+
var _index = _interopRequireDefault(require("./visitors/json-schema/index.cjs"));
|
|
9
|
+
var _ItemsVisitor = _interopRequireDefault(require("./visitors/json-schema/ItemsVisitor.cjs"));
|
|
10
|
+
var _ExamplesVisitor = _interopRequireDefault(require("./visitors/json-schema/ExamplesVisitor.cjs"));
|
|
11
|
+
var _index2 = _interopRequireDefault(require("./visitors/json-schema/link-description/index.cjs"));
|
|
12
|
+
const specification = (0, _ramda.pipe)(
|
|
13
|
+
// JSON Schema object modifications
|
|
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),
|
|
25
|
+
// Link Description object modifications
|
|
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);
|
|
29
|
+
var _default = exports.default = specification;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { pipe, assocPath, dissocPath } from 'ramda';
|
|
2
|
+
import { specificationObj } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
3
|
+
import JSONSchemaVisitor from "./visitors/json-schema/index.mjs";
|
|
4
|
+
import JSONSchemaItemsVisitor from "./visitors/json-schema/ItemsVisitor.mjs";
|
|
5
|
+
import JSONSchemaExamplesVisitor from "./visitors/json-schema/ExamplesVisitor.mjs";
|
|
6
|
+
import LinkDescriptionVisitor from "./visitors/json-schema/link-description/index.mjs";
|
|
7
|
+
const specification = pipe(
|
|
8
|
+
// JSON Schema object modifications
|
|
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),
|
|
20
|
+
// Link Description object modifications
|
|
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);
|
|
24
|
+
export default specification;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { pipe, assocPath, dissocPath } from 'ramda';
|
|
2
|
+
import { specificationObj } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
3
|
+
|
|
4
|
+
import JSONSchemaVisitor from './visitors/json-schema/index.ts';
|
|
5
|
+
import JSONSchemaItemsVisitor from './visitors/json-schema/ItemsVisitor.ts';
|
|
6
|
+
import JSONSchemaExamplesVisitor from './visitors/json-schema/ExamplesVisitor.ts';
|
|
7
|
+
import LinkDescriptionVisitor from './visitors/json-schema/link-description/index.ts';
|
|
8
|
+
|
|
9
|
+
const specification = pipe(
|
|
10
|
+
// JSON Schema object modifications
|
|
11
|
+
assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'element'], 'jSONSchemaDraft6'),
|
|
12
|
+
assocPath(['visitors', 'document', 'objects', 'JSONSchema', '$visitor'], JSONSchemaVisitor),
|
|
13
|
+
dissocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'id']),
|
|
14
|
+
assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', '$id'], {
|
|
15
|
+
$ref: '#/visitors/value',
|
|
16
|
+
}),
|
|
17
|
+
assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'contains'], {
|
|
18
|
+
$visitor: specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor,
|
|
19
|
+
alias: 'containsField',
|
|
20
|
+
}),
|
|
21
|
+
assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'items'], {
|
|
22
|
+
$visitor: JSONSchemaItemsVisitor,
|
|
23
|
+
alias: 'itemsField',
|
|
24
|
+
}),
|
|
25
|
+
assocPath(
|
|
26
|
+
['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'propertyNames'],
|
|
27
|
+
specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor,
|
|
28
|
+
),
|
|
29
|
+
assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'const'], {
|
|
30
|
+
$ref: '#/visitors/value',
|
|
31
|
+
}),
|
|
32
|
+
assocPath(
|
|
33
|
+
['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'examples'],
|
|
34
|
+
JSONSchemaExamplesVisitor,
|
|
35
|
+
),
|
|
36
|
+
// Link Description object modifications
|
|
37
|
+
assocPath(
|
|
38
|
+
['visitors', 'document', 'objects', 'LinkDescription', '$visitor'],
|
|
39
|
+
LinkDescriptionVisitor,
|
|
40
|
+
),
|
|
41
|
+
assocPath(
|
|
42
|
+
['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'hrefSchema'],
|
|
43
|
+
specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor,
|
|
44
|
+
),
|
|
45
|
+
dissocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'schema']),
|
|
46
|
+
assocPath(
|
|
47
|
+
['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionSchema'],
|
|
48
|
+
specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor,
|
|
49
|
+
),
|
|
50
|
+
dissocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'method']),
|
|
51
|
+
dissocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'encType']),
|
|
52
|
+
assocPath(
|
|
53
|
+
['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionEncType'],
|
|
54
|
+
{ $ref: '#/visitors/value' },
|
|
55
|
+
),
|
|
56
|
+
)(specificationObj);
|
|
57
|
+
|
|
58
|
+
export default specification as typeof specificationObj;
|
|
@@ -0,0 +1,26 @@
|
|
|
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 jsonSchemaDraft6Predicates = _interopRequireWildcard(require("../predicates.cjs"));
|
|
9
|
+
var _namespace = _interopRequireDefault(require("../namespace.cjs"));
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const createToolbox = () => {
|
|
15
|
+
const namespace = new _apidomDatamodel.Namespace();
|
|
16
|
+
const predicates = {
|
|
17
|
+
...jsonSchemaDraft6Predicates,
|
|
18
|
+
isStringElement: _apidomDatamodel.isStringElement
|
|
19
|
+
};
|
|
20
|
+
namespace.use(_namespace.default);
|
|
21
|
+
return {
|
|
22
|
+
predicates,
|
|
23
|
+
namespace
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
var _default = exports.default = createToolbox;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isStringElement, Namespace } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import * as jsonSchemaDraft6Predicates from "../predicates.mjs";
|
|
3
|
+
import jsonSchemaDraft6Namespace from "../namespace.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
const createToolbox = () => {
|
|
8
|
+
const namespace = new Namespace();
|
|
9
|
+
const predicates = {
|
|
10
|
+
...jsonSchemaDraft6Predicates,
|
|
11
|
+
isStringElement
|
|
12
|
+
};
|
|
13
|
+
namespace.use(jsonSchemaDraft6Namespace);
|
|
14
|
+
return {
|
|
15
|
+
predicates,
|
|
16
|
+
namespace
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default createToolbox;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isStringElement, Namespace } from '@speclynx/apidom-datamodel';
|
|
2
|
+
|
|
3
|
+
import * as jsonSchemaDraft6Predicates from '../predicates.ts';
|
|
4
|
+
import jsonSchemaDraft6Namespace from '../namespace.ts';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface Toolbox {
|
|
10
|
+
predicates: Record<string, (...args: any[]) => boolean>;
|
|
11
|
+
namespace: Namespace;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const createToolbox = (): Toolbox => {
|
|
15
|
+
const namespace = new Namespace();
|
|
16
|
+
const predicates = { ...jsonSchemaDraft6Predicates, isStringElement };
|
|
17
|
+
|
|
18
|
+
namespace.use(jsonSchemaDraft6Namespace);
|
|
19
|
+
|
|
20
|
+
return { predicates, namespace };
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default createToolbox;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-4");
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
class ExamplesVisitor extends _apidomNsJsonSchemaDraft.FallbackVisitor {
|
|
10
|
+
ArrayElement(path) {
|
|
11
|
+
this.enter(path);
|
|
12
|
+
this.element.classes.push('json-schema-examples');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
var _default = exports.default = ExamplesVisitor;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FallbackVisitor } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
class ExamplesVisitor extends FallbackVisitor {
|
|
6
|
+
ArrayElement(path) {
|
|
7
|
+
this.enter(path);
|
|
8
|
+
this.element.classes.push('json-schema-examples');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export default ExamplesVisitor;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ArrayElement } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { Path } from '@speclynx/apidom-traverse';
|
|
3
|
+
import { FallbackVisitor, FallbackVisitorOptions } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
4
|
+
|
|
5
|
+
export type { FallbackVisitorOptions as ExamplesVisitorOptions };
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
class ExamplesVisitor extends FallbackVisitor {
|
|
11
|
+
declare public readonly element: ArrayElement;
|
|
12
|
+
|
|
13
|
+
ArrayElement(path: Path<ArrayElement>) {
|
|
14
|
+
this.enter(path);
|
|
15
|
+
this.element.classes.push('json-schema-examples');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default ExamplesVisitor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-4");
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
class ItemsVisitor extends _apidomNsJsonSchemaDraft.ItemsVisitor {
|
|
10
|
+
BooleanElement(path) {
|
|
11
|
+
this.element = this.toRefractedElement(['document', 'objects', 'JSONSchema'], path.node);
|
|
12
|
+
path.stop();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
var _default = exports.default = ItemsVisitor;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ItemsVisitor as JSONSchemaDraft4ItemsVisitor } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
class ItemsVisitor extends JSONSchemaDraft4ItemsVisitor {
|
|
6
|
+
BooleanElement(path) {
|
|
7
|
+
this.element = this.toRefractedElement(['document', 'objects', 'JSONSchema'], path.node);
|
|
8
|
+
path.stop();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export default ItemsVisitor;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BooleanElement } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { Path } from '@speclynx/apidom-traverse';
|
|
3
|
+
import {
|
|
4
|
+
ItemsVisitor as JSONSchemaDraft4ItemsVisitor,
|
|
5
|
+
ItemsVisitorOptions,
|
|
6
|
+
} from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
7
|
+
|
|
8
|
+
export type { ItemsVisitorOptions };
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
class ItemsVisitor extends JSONSchemaDraft4ItemsVisitor {
|
|
14
|
+
BooleanElement(path: Path<BooleanElement>) {
|
|
15
|
+
this.element = this.toRefractedElement(['document', 'objects', 'JSONSchema'], path.node);
|
|
16
|
+
|
|
17
|
+
path.stop();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default ItemsVisitor;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-4");
|
|
7
|
+
var _JSONSchema = _interopRequireDefault(require("../../../elements/JSONSchema.cjs"));
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class JSONSchemaVisitor extends _apidomNsJsonSchemaDraft.JSONSchemaVisitor {
|
|
12
|
+
// @ts-expect-error - element can be BooleanElement (boolean schemas introduced in draft-6)
|
|
13
|
+
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super(options);
|
|
16
|
+
this.element = new _JSONSchema.default();
|
|
17
|
+
}
|
|
18
|
+
get defaultDialectIdentifier() {
|
|
19
|
+
return 'http://json-schema.org/draft-06/schema#';
|
|
20
|
+
}
|
|
21
|
+
BooleanElement(path) {
|
|
22
|
+
this.enter(path);
|
|
23
|
+
this.element.classes.push('boolean-json-schema');
|
|
24
|
+
}
|
|
25
|
+
handleSchemaIdentifier(objectElement, identifierKeyword = '$id') {
|
|
26
|
+
return super.handleSchemaIdentifier(objectElement, identifierKeyword);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
var _default = exports.default = JSONSchemaVisitor;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { JSONSchemaVisitor as JSONSchemaDraft4Visitor } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
2
|
+
import JSONSchemaElement from "../../../elements/JSONSchema.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
class JSONSchemaVisitor extends JSONSchemaDraft4Visitor {
|
|
7
|
+
// @ts-expect-error - element can be BooleanElement (boolean schemas introduced in draft-6)
|
|
8
|
+
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super(options);
|
|
11
|
+
this.element = new JSONSchemaElement();
|
|
12
|
+
}
|
|
13
|
+
get defaultDialectIdentifier() {
|
|
14
|
+
return 'http://json-schema.org/draft-06/schema#';
|
|
15
|
+
}
|
|
16
|
+
BooleanElement(path) {
|
|
17
|
+
this.enter(path);
|
|
18
|
+
this.element.classes.push('boolean-json-schema');
|
|
19
|
+
}
|
|
20
|
+
handleSchemaIdentifier(objectElement, identifierKeyword = '$id') {
|
|
21
|
+
return super.handleSchemaIdentifier(objectElement, identifierKeyword);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export default JSONSchemaVisitor;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ObjectElement, BooleanElement } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { Path } from '@speclynx/apidom-traverse';
|
|
3
|
+
import {
|
|
4
|
+
JSONSchemaVisitor as JSONSchemaDraft4Visitor,
|
|
5
|
+
JSONSchemaVisitorOptions,
|
|
6
|
+
} from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
7
|
+
|
|
8
|
+
import JSONSchemaElement from '../../../elements/JSONSchema.ts';
|
|
9
|
+
|
|
10
|
+
export type { JSONSchemaVisitorOptions };
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
class JSONSchemaVisitor extends JSONSchemaDraft4Visitor {
|
|
16
|
+
// @ts-expect-error - element can be BooleanElement (boolean schemas introduced in draft-6)
|
|
17
|
+
declare public element: JSONSchemaElement | BooleanElement;
|
|
18
|
+
|
|
19
|
+
constructor(options: JSONSchemaVisitorOptions) {
|
|
20
|
+
super(options);
|
|
21
|
+
this.element = new JSONSchemaElement();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get defaultDialectIdentifier(): string {
|
|
25
|
+
return 'http://json-schema.org/draft-06/schema#';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
BooleanElement(path: Path<BooleanElement>) {
|
|
29
|
+
this.enter(path);
|
|
30
|
+
this.element.classes.push('boolean-json-schema');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
handleSchemaIdentifier(objectElement: ObjectElement, identifierKeyword: string = '$id'): void {
|
|
34
|
+
return super.handleSchemaIdentifier(objectElement, identifierKeyword);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default JSONSchemaVisitor;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-4");
|
|
7
|
+
var _LinkDescription = _interopRequireDefault(require("../../../../elements/LinkDescription.cjs"));
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class LinkDescriptionVisitor extends _apidomNsJsonSchemaDraft.LinkDescriptionVisitor {
|
|
12
|
+
// @ts-expect-error - widening type to include BooleanElement (boolean schemas introduced in draft-6)
|
|
13
|
+
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super(options);
|
|
16
|
+
this.element = new _LinkDescription.default();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
var _default = exports.default = LinkDescriptionVisitor;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LinkDescriptionVisitor as JSONSchemaDraft4LinkDescriptionVisitor } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
2
|
+
import LinkDescriptionElement from "../../../../elements/LinkDescription.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
class LinkDescriptionVisitor extends JSONSchemaDraft4LinkDescriptionVisitor {
|
|
7
|
+
// @ts-expect-error - widening type to include BooleanElement (boolean schemas introduced in draft-6)
|
|
8
|
+
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super(options);
|
|
11
|
+
this.element = new LinkDescriptionElement();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export default LinkDescriptionVisitor;
|