@swagger-api/apidom-ns-json-schema-draft-7 0.68.1
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 +154 -0
- package/LICENSES/Apache-2.0.txt +202 -0
- package/LICENSES/MIT.txt +9 -0
- package/NOTICE +57 -0
- package/README.md +188 -0
- package/cjs/elements/JSONSchema.cjs +97 -0
- package/cjs/elements/LinkDescription.cjs +107 -0
- package/cjs/index.cjs +50 -0
- package/cjs/media-types.cjs +24 -0
- package/cjs/namespace.cjs +21 -0
- package/cjs/predicates.cjs +26 -0
- package/cjs/refractor/index.cjs +50 -0
- package/cjs/refractor/plugins/replace-empty-element.cjs +237 -0
- package/cjs/refractor/registration.cjs +13 -0
- package/cjs/refractor/specification.cjs +27 -0
- package/cjs/refractor/toolbox.cjs +23 -0
- package/cjs/refractor/visitors/json-schema/$commentVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/ContentEncodingVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/ContentMediaTypeVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/WriteOnlyVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/index.cjs +30 -0
- package/cjs/refractor/visitors/json-schema/link-description/$commentVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/link-description/AnchorPointerVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/link-description/AnchorVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/link-description/DescriptionVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/link-description/SubmissionMediaTypeVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/link-description/TargetHintsVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/link-description/TargetMediaTypeVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/link-description/TemplatePointersVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/link-description/TemplateRequiredVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/link-description/index.cjs +19 -0
- package/cjs/traversal/visitor.cjs +20 -0
- package/dist/apidom-ns-json-schema-draft-7.browser.js +1 -0
- package/es/elements/JSONSchema.js +93 -0
- package/es/elements/LinkDescription.js +103 -0
- package/es/index.js +14 -0
- package/es/media-types.js +18 -0
- package/es/namespace.js +15 -0
- package/es/predicates.js +18 -0
- package/es/refractor/index.js +45 -0
- package/es/refractor/plugins/replace-empty-element.js +229 -0
- package/es/refractor/registration.js +6 -0
- package/es/refractor/specification.js +21 -0
- package/es/refractor/toolbox.js +17 -0
- package/es/refractor/visitors/json-schema/$commentVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/ContentEncodingVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/ContentMediaTypeVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/WriteOnlyVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/index.js +24 -0
- package/es/refractor/visitors/json-schema/link-description/$commentVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/link-description/AnchorPointerVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/link-description/AnchorVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/link-description/DescriptionVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/link-description/SubmissionMediaTypeVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/link-description/TargetHintsVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/link-description/TargetMediaTypeVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/link-description/TemplatePointersVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/link-description/TemplateRequiredVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/link-description/index.js +13 -0
- package/es/traversal/visitor.js +17 -0
- package/package.json +63 -0
- package/types/dist.d.ts +311 -0
package/es/namespace.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { JSONReferenceElement } from '@swagger-api/apidom-ns-json-schema-draft-6';
|
|
2
|
+
import JSONSchemaElement from "./elements/JSONSchema.js";
|
|
3
|
+
import LinkDescriptionElement from "./elements/LinkDescription.js";
|
|
4
|
+
const jsonSchemaDraft7 = {
|
|
5
|
+
namespace: options => {
|
|
6
|
+
const {
|
|
7
|
+
base
|
|
8
|
+
} = options;
|
|
9
|
+
base.register('jSONSchemaDraft7', JSONSchemaElement);
|
|
10
|
+
base.register('jSONReference', JSONReferenceElement);
|
|
11
|
+
base.register('linkDescription', LinkDescriptionElement);
|
|
12
|
+
return base;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export default jsonSchemaDraft7;
|
package/es/predicates.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createPredicate } from '@swagger-api/apidom-core';
|
|
2
|
+
import JSONSchemaElement from "./elements/JSONSchema.js";
|
|
3
|
+
import LinkDescriptionElement from "./elements/LinkDescription.js";
|
|
4
|
+
export { isJSONReferenceElement } from '@swagger-api/apidom-ns-json-schema-draft-6';
|
|
5
|
+
export const isJSONSchemaElement = createPredicate(({
|
|
6
|
+
hasBasicElementProps,
|
|
7
|
+
isElementType,
|
|
8
|
+
primitiveEq
|
|
9
|
+
}) => {
|
|
10
|
+
return element => element instanceof JSONSchemaElement || hasBasicElementProps(element) && isElementType('JSONSchemaDraft7', element) && primitiveEq('object', element);
|
|
11
|
+
});
|
|
12
|
+
export const isLinkDescriptionElement = createPredicate(({
|
|
13
|
+
hasBasicElementProps,
|
|
14
|
+
isElementType,
|
|
15
|
+
primitiveEq
|
|
16
|
+
}) => {
|
|
17
|
+
return element => element instanceof LinkDescriptionElement || hasBasicElementProps(element) && isElementType('linkDescription', element) && primitiveEq('object', element);
|
|
18
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { invokeArgs } from 'ramda-adjunct';
|
|
5
|
+
import { visit, dereference, refract as baseRefract, dispatchRefractorPlugins } from '@swagger-api/apidom-core';
|
|
6
|
+
import specification from "./specification.js";
|
|
7
|
+
import { keyMap, getNodeType } from "../traversal/visitor.js";
|
|
8
|
+
import createToolbox from "./toolbox.js";
|
|
9
|
+
const refract = (value, {
|
|
10
|
+
specPath = ['visitors', 'document', 'objects', 'JSONSchema', '$visitor'],
|
|
11
|
+
plugins = [],
|
|
12
|
+
specificationObj = specification
|
|
13
|
+
} = {}) => {
|
|
14
|
+
const element = baseRefract(value);
|
|
15
|
+
const resolvedSpec = dereference(specificationObj);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This is where generic ApiDOM becomes semantic (namespace applied).
|
|
19
|
+
* We don't allow consumers to hook into this translation.
|
|
20
|
+
* Though we allow consumers to define their onw plugins on already transformed ApiDOM.
|
|
21
|
+
*/
|
|
22
|
+
const rootVisitor = invokeArgs(specPath, [], resolvedSpec);
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
visit(element, rootVisitor, {
|
|
25
|
+
state: {
|
|
26
|
+
specObj: resolvedSpec
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Run plugins only when necessary.
|
|
32
|
+
* Running plugins visitors means extra single traversal === performance hit.
|
|
33
|
+
*/
|
|
34
|
+
return dispatchRefractorPlugins(rootVisitor.element, plugins, {
|
|
35
|
+
toolboxCreator: createToolbox,
|
|
36
|
+
visitorOptions: {
|
|
37
|
+
keyMap,
|
|
38
|
+
nodeTypeGetter: getNodeType
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
export const createRefractor = specPath => (value, options = {}) => refract(value, _objectSpread({
|
|
43
|
+
specPath
|
|
44
|
+
}, options));
|
|
45
|
+
export default refract;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { MemberElement, ArrayElement, ObjectElement, isStringElement, includesClasses, isArrayElement } from '@swagger-api/apidom-core';
|
|
2
|
+
/**
|
|
3
|
+
* JSON Schema Draft 7 specification elements.
|
|
4
|
+
*/
|
|
5
|
+
import JSONSchemaElement from "../../elements/JSONSchema.js";
|
|
6
|
+
import LinkDescriptionElement from "../../elements/LinkDescription.js";
|
|
7
|
+
import { getNodeType } from "../../traversal/visitor.js";
|
|
8
|
+
/**
|
|
9
|
+
* This plugin is specific to YAML 1.2 format, which allows defining key-value pairs
|
|
10
|
+
* with empty key, empty value, or both. If the value is not provided in YAML format,
|
|
11
|
+
* this plugin compensates for this missing value with the most appropriate semantic element type.
|
|
12
|
+
*
|
|
13
|
+
* https://yaml.org/spec/1.2.2/#72-empty-nodes
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* ```yaml
|
|
18
|
+
* $schema: http://json-schema.org/draft-07/schema#
|
|
19
|
+
* items:
|
|
20
|
+
* ```
|
|
21
|
+
* Refracting result without this plugin:
|
|
22
|
+
*
|
|
23
|
+
* (JSONSchemaElement
|
|
24
|
+
* (MemberElement
|
|
25
|
+
* (StringElement)
|
|
26
|
+
* (StringElement))
|
|
27
|
+
* (MemberElement
|
|
28
|
+
* (StringElement)
|
|
29
|
+
* (StringElement))
|
|
30
|
+
*
|
|
31
|
+
* Refracting result with this plugin:
|
|
32
|
+
*
|
|
33
|
+
* (JSONSchemaElement
|
|
34
|
+
* (MemberElement
|
|
35
|
+
* (StringElement)
|
|
36
|
+
* (StringElement))
|
|
37
|
+
* (MemberElement
|
|
38
|
+
* (StringElement)
|
|
39
|
+
* (JSONSchemaElement))
|
|
40
|
+
*/
|
|
41
|
+
const isEmptyElement = element => isStringElement(element) && includesClasses(['yaml-e-node', 'yaml-e-scalar'], element);
|
|
42
|
+
const schema = {
|
|
43
|
+
JSONSchemaDraft7Element: {
|
|
44
|
+
additionalItems(...args) {
|
|
45
|
+
return new JSONSchemaElement(...args);
|
|
46
|
+
},
|
|
47
|
+
items(...args) {
|
|
48
|
+
return new JSONSchemaElement(...args);
|
|
49
|
+
},
|
|
50
|
+
contains(...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
|
+
propertyNames(...args) {
|
|
77
|
+
return new JSONSchemaElement(...args);
|
|
78
|
+
},
|
|
79
|
+
enum(...args) {
|
|
80
|
+
const element = new ArrayElement(...args);
|
|
81
|
+
element.classes.push('json-schema-enum');
|
|
82
|
+
return element;
|
|
83
|
+
},
|
|
84
|
+
allOf(...args) {
|
|
85
|
+
const element = new ArrayElement(...args);
|
|
86
|
+
element.classes.push('json-schema-allOf');
|
|
87
|
+
return element;
|
|
88
|
+
},
|
|
89
|
+
anyOf(...args) {
|
|
90
|
+
const element = new ArrayElement(...args);
|
|
91
|
+
element.classes.push('json-schema-anyOf');
|
|
92
|
+
return element;
|
|
93
|
+
},
|
|
94
|
+
oneOf(...args) {
|
|
95
|
+
const element = new ArrayElement(...args);
|
|
96
|
+
element.classes.push('json-schema-oneOf');
|
|
97
|
+
return element;
|
|
98
|
+
},
|
|
99
|
+
if(...args) {
|
|
100
|
+
return new JSONSchemaElement(...args);
|
|
101
|
+
},
|
|
102
|
+
then(...args) {
|
|
103
|
+
return new JSONSchemaElement(...args);
|
|
104
|
+
},
|
|
105
|
+
else(...args) {
|
|
106
|
+
return new JSONSchemaElement(...args);
|
|
107
|
+
},
|
|
108
|
+
not(...args) {
|
|
109
|
+
return new JSONSchemaElement(...args);
|
|
110
|
+
},
|
|
111
|
+
definitions(...args) {
|
|
112
|
+
const element = new ObjectElement(...args);
|
|
113
|
+
element.classes.push('json-schema-definitions');
|
|
114
|
+
return element;
|
|
115
|
+
},
|
|
116
|
+
examples(...args) {
|
|
117
|
+
const element = new ArrayElement(...args);
|
|
118
|
+
element.classes.push('json-schema-examples');
|
|
119
|
+
return element;
|
|
120
|
+
},
|
|
121
|
+
links(...args) {
|
|
122
|
+
const element = new ArrayElement(...args);
|
|
123
|
+
element.classes.push('json-schema-links');
|
|
124
|
+
return element;
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
LinkDescriptionElement: {
|
|
128
|
+
hrefSchema(...args) {
|
|
129
|
+
return new JSONSchemaElement(...args);
|
|
130
|
+
},
|
|
131
|
+
targetSchema(...args) {
|
|
132
|
+
return new JSONSchemaElement(...args);
|
|
133
|
+
},
|
|
134
|
+
submissionSchema(...args) {
|
|
135
|
+
return new JSONSchemaElement(...args);
|
|
136
|
+
},
|
|
137
|
+
templatePointers(...args) {
|
|
138
|
+
return new ObjectElement(...args);
|
|
139
|
+
},
|
|
140
|
+
templateRequired(...args) {
|
|
141
|
+
return new ArrayElement(...args);
|
|
142
|
+
},
|
|
143
|
+
targetHints(...args) {
|
|
144
|
+
return new ObjectElement(...args);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
'json-schema-properties': {
|
|
148
|
+
'[key: *]': function key(...args) {
|
|
149
|
+
return new JSONSchemaElement(...args);
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
'json-schema-patternProperties': {
|
|
153
|
+
'[key: *]': function key(...args) {
|
|
154
|
+
return new JSONSchemaElement(...args);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
'json-schema-dependencies': {
|
|
158
|
+
'[key: *]': function key(...args) {
|
|
159
|
+
return new JSONSchemaElement(...args);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
'json-schema-allOf': {
|
|
163
|
+
'<*>': function asterisk(...args) {
|
|
164
|
+
return new JSONSchemaElement(...args);
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
'json-schema-anyOf': {
|
|
168
|
+
'<*>': function asterisk(...args) {
|
|
169
|
+
return new JSONSchemaElement(...args);
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
'json-schema-oneOf': {
|
|
173
|
+
'<*>': function asterisk(...args) {
|
|
174
|
+
return new JSONSchemaElement(...args);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
'json-schema-definitions': {
|
|
178
|
+
'[key: *]': function key(...args) {
|
|
179
|
+
return new JSONSchemaElement(...args);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
'json-schema-links': {
|
|
183
|
+
'<*>': function asterisk(...args) {
|
|
184
|
+
return new LinkDescriptionElement(...args);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
const findElementFactory = (ancestor, keyName) => {
|
|
189
|
+
var _ancestor$classes$fir, _ancestor$classes$fir2;
|
|
190
|
+
const elementType = getNodeType(ancestor); // @ts-ignore
|
|
191
|
+
const keyMapping = schema[elementType] || schema[(_ancestor$classes$fir = ancestor.classes.first) === null || _ancestor$classes$fir === void 0 ? void 0 : (_ancestor$classes$fir2 = _ancestor$classes$fir.toValue) === null || _ancestor$classes$fir2 === void 0 ? void 0 : _ancestor$classes$fir2.call(_ancestor$classes$fir)];
|
|
192
|
+
return typeof keyMapping === 'undefined' ? undefined : Object.prototype.hasOwnProperty.call(keyMapping, '[key: *]') ? keyMapping['[key: *]'] : keyMapping[keyName];
|
|
193
|
+
};
|
|
194
|
+
const plugin = () => () => {
|
|
195
|
+
return {
|
|
196
|
+
visitor: {
|
|
197
|
+
MemberElement(element, ...rest) {
|
|
198
|
+
// no empty Element, continue with next one
|
|
199
|
+
if (!isEmptyElement(element.value)) return undefined;
|
|
200
|
+
const [,,, ancestors] = rest;
|
|
201
|
+
const ancestor = ancestors[ancestors.length - 1]; // @ts-ignore
|
|
202
|
+
const elementFactory = findElementFactory(ancestor, element.key.toValue());
|
|
203
|
+
|
|
204
|
+
// no element factory found
|
|
205
|
+
if (typeof elementFactory === 'undefined') return undefined;
|
|
206
|
+
const originalValue = element.value;
|
|
207
|
+
return new MemberElement(element.key, elementFactory.call({
|
|
208
|
+
context: ancestor
|
|
209
|
+
}, undefined, originalValue.meta.clone(), originalValue.attributes.clone()), element.meta.clone(), element.attributes.clone());
|
|
210
|
+
},
|
|
211
|
+
StringElement(element, ...rest) {
|
|
212
|
+
if (!isEmptyElement(element)) return undefined;
|
|
213
|
+
const [,,, ancestors] = rest;
|
|
214
|
+
const ancestor = ancestors[ancestors.length - 1];
|
|
215
|
+
|
|
216
|
+
// we're only interested in empty elements in ArrayElements
|
|
217
|
+
if (!isArrayElement(ancestor)) return undefined;
|
|
218
|
+
const elementFactory = findElementFactory(ancestor, '<*>');
|
|
219
|
+
|
|
220
|
+
// no element factory found
|
|
221
|
+
if (typeof elementFactory === 'undefined') return undefined;
|
|
222
|
+
return elementFactory.call({
|
|
223
|
+
context: element
|
|
224
|
+
}, undefined, element.meta.clone(), element.attributes.clone());
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
export default plugin;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import JSONSchemaElement from "../elements/JSONSchema.js";
|
|
2
|
+
import LinkDescriptionElement from "../elements/LinkDescription.js";
|
|
3
|
+
import { createRefractor } from "./index.js"; // register refractors specific to element types
|
|
4
|
+
JSONSchemaElement.refract = createRefractor(['visitors', 'document', 'objects', 'JSONSchema', '$visitor']);
|
|
5
|
+
LinkDescriptionElement.refract = createRefractor(['visitors', 'document', 'objects', 'LinkDescription', '$visitor']);
|
|
6
|
+
export { JSONSchemaElement, LinkDescriptionElement };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { pipe, assocPath, dissocPath } from 'ramda';
|
|
2
|
+
import { specificationObj } from '@swagger-api/apidom-ns-json-schema-draft-6';
|
|
3
|
+
import JSONSchemaVisitor from "./visitors/json-schema/index.js";
|
|
4
|
+
import JSONSchema$commentVisitor from "./visitors/json-schema/$commentVisitor.js";
|
|
5
|
+
import JsonSchemaContentEncodingVisitor from "./visitors/json-schema/ContentEncodingVisitor.js";
|
|
6
|
+
import JsonSchemaContentMediaTypeVisitor from "./visitors/json-schema/ContentMediaTypeVisitor.js";
|
|
7
|
+
import JsonSchemaWriteOnlyVisitor from "./visitors/json-schema/WriteOnlyVisitor.js";
|
|
8
|
+
import LinkDescriptionVisitor from "./visitors/json-schema/link-description/index.js";
|
|
9
|
+
import LinkDescriptionAnchorVisitor from "./visitors/json-schema/link-description/AnchorVisitor.js";
|
|
10
|
+
import LinkDescriptionAnchorPointerVisitor from "./visitors/json-schema/link-description/AnchorPointerVisitor.js";
|
|
11
|
+
import LinkDescriptionTargetMediaTypeVisitor from "./visitors/json-schema/link-description/TargetMediaTypeVisitor.js";
|
|
12
|
+
import LinkDescriptionTargetHintsVisitor from "./visitors/json-schema/link-description/TargetHintsVisitor.js";
|
|
13
|
+
import LinkDescriptionDescriptionVisitor from "./visitors/json-schema/link-description/DescriptionVisitor.js";
|
|
14
|
+
import LinkDescription$commentVisitor from "./visitors/json-schema/link-description/$commentVisitor.js";
|
|
15
|
+
import LinkDescriptionSubmissionMediaTypeVisitor from "./visitors/json-schema/link-description/SubmissionMediaTypeVisitor.js";
|
|
16
|
+
const specification = pipe(
|
|
17
|
+
// JSON Schema object modifications
|
|
18
|
+
assocPath(['visitors', 'document', 'objects', 'JSONSchema', '$visitor'], JSONSchemaVisitor), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', '$comment'], JSONSchema$commentVisitor), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'if'], specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'then'], specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'else'], specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), dissocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'media']), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'contentEncoding'], JsonSchemaContentEncodingVisitor), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'contentMediaType'], JsonSchemaContentMediaTypeVisitor), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'writeOnly'], JsonSchemaWriteOnlyVisitor),
|
|
19
|
+
// Link Description object modifications
|
|
20
|
+
assocPath(['visitors', 'document', 'objects', 'LinkDescription', '$visitor'], LinkDescriptionVisitor), assocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'anchor'], LinkDescriptionAnchorVisitor), assocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'anchorPointer'], LinkDescriptionAnchorPointerVisitor), dissocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'mediaType']), assocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'targetMediaType'], LinkDescriptionTargetMediaTypeVisitor), assocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'targetHints'], LinkDescriptionTargetHintsVisitor), assocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'description'], LinkDescriptionDescriptionVisitor), assocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', '$comment'], LinkDescription$commentVisitor), dissocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionEncType']), assocPath(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionMediaType'], LinkDescriptionSubmissionMediaTypeVisitor))(specificationObj);
|
|
21
|
+
export default specification;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { createNamespace, isStringElement } from '@swagger-api/apidom-core';
|
|
5
|
+
import * as jsonSchemaDraft7Predicates from "../predicates.js";
|
|
6
|
+
import jsonSchemaDraft7Namespace from "../namespace.js";
|
|
7
|
+
const createToolbox = () => {
|
|
8
|
+
const namespace = createNamespace(jsonSchemaDraft7Namespace);
|
|
9
|
+
const predicates = _objectSpread(_objectSpread({}, jsonSchemaDraft7Predicates), {}, {
|
|
10
|
+
isStringElement
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
predicates,
|
|
14
|
+
namespace
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default createToolbox;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import stampit from 'stampit';
|
|
2
|
+
import { always } from 'ramda';
|
|
3
|
+
import { BREAK } from '@swagger-api/apidom-core';
|
|
4
|
+
import { FixedFieldsVisitor, FallbackVisitor } from '@swagger-api/apidom-ns-json-schema-draft-6';
|
|
5
|
+
import JSONSchemaElement from "../../../elements/JSONSchema.js";
|
|
6
|
+
const JSONSchemaVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
|
|
7
|
+
props: {
|
|
8
|
+
specPath: always(['document', 'objects', 'JSONSchema'])
|
|
9
|
+
},
|
|
10
|
+
methods: {
|
|
11
|
+
ObjectElement(objectElement) {
|
|
12
|
+
this.element = new JSONSchemaElement();
|
|
13
|
+
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
return FixedFieldsVisitor.compose.methods.ObjectElement.call(this, objectElement);
|
|
16
|
+
},
|
|
17
|
+
BooleanElement(booleanElement) {
|
|
18
|
+
this.element = booleanElement.clone();
|
|
19
|
+
this.element.classes.push('boolean-json-schema');
|
|
20
|
+
return BREAK;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
export default JSONSchemaVisitor;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import stampit from 'stampit';
|
|
2
|
+
import { always } from 'ramda';
|
|
3
|
+
import { FixedFieldsVisitor, FallbackVisitor } from '@swagger-api/apidom-ns-json-schema-draft-6';
|
|
4
|
+
import LinkDescriptionElement from "../../../../elements/LinkDescription.js";
|
|
5
|
+
const LinkDescriptionVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
|
|
6
|
+
props: {
|
|
7
|
+
specPath: always(['document', 'objects', 'LinkDescription'])
|
|
8
|
+
},
|
|
9
|
+
init() {
|
|
10
|
+
this.element = new LinkDescriptionElement();
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export default LinkDescriptionVisitor;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { keyMap as keyMapBase, isElement } from '@swagger-api/apidom-core';
|
|
5
|
+
|
|
6
|
+
// getNodeType :: Node -> String
|
|
7
|
+
export const getNodeType = element => {
|
|
8
|
+
if (!isElement(element)) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
return `${element.element.charAt(0).toUpperCase() + element.element.slice(1)}Element`;
|
|
12
|
+
};
|
|
13
|
+
export const keyMap = _objectSpread({
|
|
14
|
+
JSONSchemaDraft7Element: ['content'],
|
|
15
|
+
JSONReferenceElement: ['content'],
|
|
16
|
+
LinkDescriptionElement: ['content']
|
|
17
|
+
}, keyMapBase);
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@swagger-api/apidom-ns-json-schema-draft-7",
|
|
3
|
+
"version": "0.68.1",
|
|
4
|
+
"description": "JSON Schema Draft 7 namespace for ApiDOM.",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public",
|
|
7
|
+
"registry": "https://registry.npmjs.org"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"sideEffects": [
|
|
11
|
+
"./es/refractor/registration.js",
|
|
12
|
+
"./cjs/refractor/registration.cjs"
|
|
13
|
+
],
|
|
14
|
+
"unpkg": "./dist/apidom-ns-json-schema-draft-7.browser.min.js",
|
|
15
|
+
"main": "./cjs/index.cjs",
|
|
16
|
+
"exports": {
|
|
17
|
+
"types": "./types/dist.d.ts",
|
|
18
|
+
"import": "./es/index.js",
|
|
19
|
+
"require": "./cjs/index.cjs"
|
|
20
|
+
},
|
|
21
|
+
"types": "./types/dist.d.ts",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser",
|
|
24
|
+
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es --extensions '.ts' --root-mode 'upward'",
|
|
25
|
+
"build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir cjs --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'",
|
|
26
|
+
"build:umd:browser": "cross-env BABEL_ENV=browser BROWSERSLIST_ENV=production webpack --config config/webpack/browser.config.js --progress",
|
|
27
|
+
"lint": "eslint ./",
|
|
28
|
+
"lint:fix": "eslint ./ --fix",
|
|
29
|
+
"clean": "rimraf ./es ./cjs ./dist ./types",
|
|
30
|
+
"test": "cross-env NODE_ENV=test BABEL_ENV=cjs mocha",
|
|
31
|
+
"test:update-snapshots": "cross-env UPDATE_SNAPSHOT=1 BABEL_ENV=cjs mocha",
|
|
32
|
+
"typescript:check-types": "tsc --noEmit",
|
|
33
|
+
"typescript:declaration": "tsc -p declaration.tsconfig.json && rollup -c config/rollup/types.dist.js",
|
|
34
|
+
"prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
|
|
35
|
+
"postpack": "rimraf NOTICE LICENSES"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/swagger-api/apidom.git"
|
|
40
|
+
},
|
|
41
|
+
"author": "Vladimir Gorej",
|
|
42
|
+
"license": "Apache-2.0",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@babel/runtime-corejs3": "^7.20.7",
|
|
45
|
+
"@swagger-api/apidom-core": "^0.68.1",
|
|
46
|
+
"@swagger-api/apidom-ns-json-schema-draft-6": "^0.68.1",
|
|
47
|
+
"@types/ramda": "=0.28.23",
|
|
48
|
+
"ramda": "=0.28.0",
|
|
49
|
+
"ramda-adjunct": "=3.4.0",
|
|
50
|
+
"stampit": "=4.3.2"
|
|
51
|
+
},
|
|
52
|
+
"files": [
|
|
53
|
+
"cjs/",
|
|
54
|
+
"dist/",
|
|
55
|
+
"es/",
|
|
56
|
+
"types/dist.d.ts",
|
|
57
|
+
"LICENSES",
|
|
58
|
+
"NOTICE",
|
|
59
|
+
"README.md",
|
|
60
|
+
"CHANGELOG.md"
|
|
61
|
+
],
|
|
62
|
+
"gitHead": "d2bc706671f1b9a593b8f0c5bca8c501ad0e4cff"
|
|
63
|
+
}
|