@swagger-api/apidom-ns-json-schema-draft-6 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.
Files changed (46) hide show
  1. package/CHANGELOG.md +156 -0
  2. package/LICENSES/Apache-2.0.txt +202 -0
  3. package/LICENSES/MIT.txt +9 -0
  4. package/NOTICE +57 -0
  5. package/README.md +189 -0
  6. package/cjs/elements/JSONSchema.cjs +115 -0
  7. package/cjs/elements/LinkDescription.cjs +57 -0
  8. package/cjs/index.cjs +52 -0
  9. package/cjs/media-types.cjs +24 -0
  10. package/cjs/namespace.cjs +22 -0
  11. package/cjs/predicates.cjs +27 -0
  12. package/cjs/refractor/index.cjs +49 -0
  13. package/cjs/refractor/plugins/replace-empty-element.cjs +223 -0
  14. package/cjs/refractor/registration.cjs +13 -0
  15. package/cjs/refractor/specification.cjs +21 -0
  16. package/cjs/refractor/toolbox.cjs +23 -0
  17. package/cjs/refractor/visitors/json-schema/$idVisitor.cjs +8 -0
  18. package/cjs/refractor/visitors/json-schema/ConstVisitor.cjs +8 -0
  19. package/cjs/refractor/visitors/json-schema/ExamplesVisitor.cjs +19 -0
  20. package/cjs/refractor/visitors/json-schema/ItemsVisitor.cjs +34 -0
  21. package/cjs/refractor/visitors/json-schema/index.cjs +30 -0
  22. package/cjs/refractor/visitors/json-schema/link-description/SubmissionEncTypeVisitor.cjs +8 -0
  23. package/cjs/refractor/visitors/json-schema/link-description/index.cjs +19 -0
  24. package/cjs/traversal/visitor.cjs +21 -0
  25. package/dist/apidom-ns-json-schema-draft-6.browser.js +1 -0
  26. package/es/elements/JSONSchema.js +111 -0
  27. package/es/elements/LinkDescription.js +52 -0
  28. package/es/index.js +14 -0
  29. package/es/media-types.js +18 -0
  30. package/es/namespace.js +16 -0
  31. package/es/predicates.js +18 -0
  32. package/es/refractor/index.js +44 -0
  33. package/es/refractor/plugins/replace-empty-element.js +215 -0
  34. package/es/refractor/registration.js +6 -0
  35. package/es/refractor/specification.js +15 -0
  36. package/es/refractor/toolbox.js +17 -0
  37. package/es/refractor/visitors/json-schema/$idVisitor.js +3 -0
  38. package/es/refractor/visitors/json-schema/ConstVisitor.js +3 -0
  39. package/es/refractor/visitors/json-schema/ExamplesVisitor.js +13 -0
  40. package/es/refractor/visitors/json-schema/ItemsVisitor.js +28 -0
  41. package/es/refractor/visitors/json-schema/index.js +24 -0
  42. package/es/refractor/visitors/json-schema/link-description/SubmissionEncTypeVisitor.js +3 -0
  43. package/es/refractor/visitors/json-schema/link-description/index.js +13 -0
  44. package/es/traversal/visitor.js +18 -0
  45. package/package.json +63 -0
  46. package/types/dist.d.ts +290 -0
@@ -0,0 +1,52 @@
1
+ import { LinkDescriptionElement } from '@swagger-api/apidom-ns-json-schema-draft-4';
2
+ /* eslint-disable class-methods-use-this */
3
+
4
+ /**
5
+ * URI: https://datatracker.ietf.org/doc/html/draft-wright-json-schema-hyperschema-01#section-6
6
+ */
7
+
8
+ class LinkDescription extends LinkDescriptionElement {
9
+ get hrefSchema() {
10
+ return this.get('hrefSchema');
11
+ }
12
+ set hrefSchema(hrefSchema) {
13
+ this.set('hrefSchema', hrefSchema);
14
+ }
15
+ get targetSchema() {
16
+ return this.get('targetSchema');
17
+ }
18
+ set targetSchema(targetSchema) {
19
+ this.set('targetSchema', targetSchema);
20
+ }
21
+ get schema() {
22
+ throw new Error('schema keyword from Hyper-Schema vocabulary has been renamed to submissionSchema.');
23
+ }
24
+ set schema(schema) {
25
+ throw new Error('schema keyword from Hyper-Schema vocabulary has been renamed to submissionSchema.');
26
+ }
27
+ get submissionSchema() {
28
+ return this.get('submissionSchema');
29
+ }
30
+ set submissionSchema(submissionSchema) {
31
+ this.set('submissionSchema', submissionSchema);
32
+ }
33
+ get method() {
34
+ throw new Error('method keyword from Hyper-Schema vocabulary has been removed.');
35
+ }
36
+ set method(method) {
37
+ throw new Error('method keyword from Hyper-Schema vocabulary has been removed.');
38
+ }
39
+ get encType() {
40
+ throw new Error('encType keyword from Hyper-Schema vocabulary has been renamed to submissionEncType.');
41
+ }
42
+ set encType(encType) {
43
+ throw new Error('encType keyword from Hyper-Schema vocabulary has been renamed to submissionEncType.');
44
+ }
45
+ get submissionEncType() {
46
+ return this.get('submissionEncType');
47
+ }
48
+ set submissionEncType(submissionEncType) {
49
+ this.set('submissionEncType', submissionEncType);
50
+ }
51
+ }
52
+ export default LinkDescription;
package/es/index.js ADDED
@@ -0,0 +1,14 @@
1
+ export { isRefElement, isLinkElement, isMemberElement, isObjectElement, isArrayElement, isBooleanElement, isNullElement, isElement, isNumberElement, isStringElement } from '@swagger-api/apidom-core';
2
+ export { default as mediaTypes, JSONSchemaDraft6MediaTypes } from "./media-types.js"; // eslint-disable-next-line no-restricted-exports
3
+ export { default } from "./namespace.js";
4
+ export { default as refractorPluginReplaceEmptyElement } from "./refractor/plugins/replace-empty-element.js";
5
+ export { default as refract, createRefractor } from "./refractor/index.js";
6
+ export { default as specificationObj } from "./refractor/specification.js";
7
+ export { isJSONReferenceElement, isJSONSchemaElement, isLinkDescriptionElement, isMediaElement } from "./predicates.js";
8
+ export { isJSONReferenceLikeElement, SpecificationVisitor, FallbackVisitor, FixedFieldsVisitor, PatternedFieldsVisitor, MapVisitor, AlternatingVisitor, ParentSchemaAwareVisitor } from '@swagger-api/apidom-ns-json-schema-draft-4';
9
+ export { keyMap, getNodeType } from "./traversal/visitor.js";
10
+ /**
11
+ * JSON Schema Draft 6 specification elements.
12
+ */
13
+ export { JSONSchemaElement, LinkDescriptionElement } from "./refractor/registration.js";
14
+ export { JSONReferenceElement, MediaElement } from '@swagger-api/apidom-ns-json-schema-draft-4';
@@ -0,0 +1,18 @@
1
+ import { last } from 'ramda';
2
+ import { MediaTypes } from '@swagger-api/apidom-core';
3
+ export class JSONSchemaDraft6MediaTypes extends MediaTypes {
4
+ filterByFormat(format = 'generic') {
5
+ const effectiveFormat = format === 'generic' ? 'schema;version' : format;
6
+ return this.filter(mediaType => mediaType.includes(effectiveFormat));
7
+ }
8
+ findBy(version = 'draft-06', format = 'generic') {
9
+ const search = format === 'generic' ? `schema;version=${version}` : `schema+${format};version=${version}`;
10
+ const found = this.find(mediaType => mediaType.includes(search));
11
+ return found || this.unknownMediaType;
12
+ }
13
+ latest(format = 'generic') {
14
+ return last(this.filterByFormat(format));
15
+ }
16
+ }
17
+ const mediaTypes = new JSONSchemaDraft6MediaTypes('application/schema;version=draft-06', 'application/schema+json;version=draft-06', 'application/schema+yaml;version=draft-06');
18
+ export default mediaTypes;
@@ -0,0 +1,16 @@
1
+ import { JSONReferenceElement, MediaElement } from '@swagger-api/apidom-ns-json-schema-draft-4';
2
+ import JSONSchemaElement from "./elements/JSONSchema.js";
3
+ import LinkDescriptionElement from "./elements/LinkDescription.js";
4
+ const jsonSchemaDraft6 = {
5
+ namespace: options => {
6
+ const {
7
+ base
8
+ } = options;
9
+ base.register('jSONSchemaDraft6', JSONSchemaElement);
10
+ base.register('jSONReference', JSONReferenceElement);
11
+ base.register('media', MediaElement);
12
+ base.register('linkDescription', LinkDescriptionElement);
13
+ return base;
14
+ }
15
+ };
16
+ export default jsonSchemaDraft6;
@@ -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, isMediaElement } from '@swagger-api/apidom-ns-json-schema-draft-4';
5
+ export const isJSONSchemaElement = createPredicate(({
6
+ hasBasicElementProps,
7
+ isElementType,
8
+ primitiveEq
9
+ }) => {
10
+ return element => element instanceof JSONSchemaElement || hasBasicElementProps(element) && isElementType('JSONSchemaDraft6', 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,44 @@
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
+ * Running plugins visitors means extra single traversal === performance hit.
32
+ */
33
+ return dispatchRefractorPlugins(rootVisitor.element, plugins, {
34
+ toolboxCreator: createToolbox,
35
+ visitorOptions: {
36
+ keyMap,
37
+ nodeTypeGetter: getNodeType
38
+ }
39
+ });
40
+ };
41
+ export const createRefractor = specPath => (value, options = {}) => refract(value, _objectSpread({
42
+ specPath
43
+ }, options));
44
+ export default refract;
@@ -0,0 +1,215 @@
1
+ import { MemberElement, ArrayElement, ObjectElement, isStringElement, includesClasses, isArrayElement } from '@swagger-api/apidom-core';
2
+ /**
3
+ * JSON Schema Draft 6 specification elements.
4
+ */
5
+ import { MediaElement } from '@swagger-api/apidom-ns-json-schema-draft-4';
6
+ import JSONSchemaElement from "../../elements/JSONSchema.js";
7
+ import LinkDescriptionElement from "../../elements/LinkDescription.js";
8
+ import { getNodeType } from "../../traversal/visitor.js";
9
+ /**
10
+ * This plugin is specific to YAML 1.2 format, which allows defining key-value pairs
11
+ * with empty key, empty value, or both. If the value is not provided in YAML format,
12
+ * this plugin compensates for this missing value with the most appropriate semantic element type.
13
+ *
14
+ * https://yaml.org/spec/1.2.2/#72-empty-nodes
15
+ *
16
+ * @example
17
+ *
18
+ * ```yaml
19
+ * $schema: http://json-schema.org/draft-06/schema#
20
+ * items:
21
+ * ```
22
+ * Refracting result without this plugin:
23
+ *
24
+ * (JSONSchemaElement
25
+ * (MemberElement
26
+ * (StringElement)
27
+ * (StringElement))
28
+ * (MemberElement
29
+ * (StringElement)
30
+ * (StringElement))
31
+ *
32
+ * Refracting result with this plugin:
33
+ *
34
+ * (JSONSchemaElement
35
+ * (MemberElement
36
+ * (StringElement)
37
+ * (StringElement))
38
+ * (MemberElement
39
+ * (StringElement)
40
+ * (JSONSchemaElement))
41
+ */
42
+ const isEmptyElement = element => isStringElement(element) && includesClasses(['yaml-e-node', 'yaml-e-scalar'], element);
43
+ const schema = {
44
+ JSONSchemaDraft6Element: {
45
+ additionalItems(...args) {
46
+ return new JSONSchemaElement(...args);
47
+ },
48
+ items(...args) {
49
+ return new JSONSchemaElement(...args);
50
+ },
51
+ contains(...args) {
52
+ return new JSONSchemaElement(...args);
53
+ },
54
+ required(...args) {
55
+ const element = new ArrayElement(...args);
56
+ element.classes.push('json-schema-required');
57
+ return element;
58
+ },
59
+ properties(...args) {
60
+ const element = new ObjectElement(...args);
61
+ element.classes.push('json-schema-properties');
62
+ return element;
63
+ },
64
+ additionalProperties(...args) {
65
+ return new JSONSchemaElement(...args);
66
+ },
67
+ patternProperties(...args) {
68
+ const element = new ObjectElement(...args);
69
+ element.classes.push('json-schema-patternProperties');
70
+ return element;
71
+ },
72
+ dependencies(...args) {
73
+ const element = new ObjectElement(...args);
74
+ element.classes.push('json-schema-dependencies');
75
+ return element;
76
+ },
77
+ propertyNames(...args) {
78
+ return new JSONSchemaElement(...args);
79
+ },
80
+ enum(...args) {
81
+ const element = new ArrayElement(...args);
82
+ element.classes.push('json-schema-enum');
83
+ return element;
84
+ },
85
+ allOf(...args) {
86
+ const element = new ArrayElement(...args);
87
+ element.classes.push('json-schema-allOf');
88
+ return element;
89
+ },
90
+ anyOf(...args) {
91
+ const element = new ArrayElement(...args);
92
+ element.classes.push('json-schema-anyOf');
93
+ return element;
94
+ },
95
+ oneOf(...args) {
96
+ const element = new ArrayElement(...args);
97
+ element.classes.push('json-schema-oneOf');
98
+ return element;
99
+ },
100
+ not(...args) {
101
+ return new JSONSchemaElement(...args);
102
+ },
103
+ definitions(...args) {
104
+ const element = new ObjectElement(...args);
105
+ element.classes.push('json-schema-definitions');
106
+ return element;
107
+ },
108
+ examples(...args) {
109
+ const element = new ArrayElement(...args);
110
+ element.classes.push('json-schema-examples');
111
+ return element;
112
+ },
113
+ links(...args) {
114
+ const element = new ArrayElement(...args);
115
+ element.classes.push('json-schema-links');
116
+ return element;
117
+ },
118
+ media(...args) {
119
+ return new MediaElement(...args);
120
+ }
121
+ },
122
+ LinkDescriptionElement: {
123
+ hrefSchema(...args) {
124
+ return new JSONSchemaElement(...args);
125
+ },
126
+ targetSchema(...args) {
127
+ return new JSONSchemaElement(...args);
128
+ },
129
+ submissionSchema(...args) {
130
+ return new JSONSchemaElement(...args);
131
+ }
132
+ },
133
+ 'json-schema-properties': {
134
+ '[key: *]': function key(...args) {
135
+ return new JSONSchemaElement(...args);
136
+ }
137
+ },
138
+ 'json-schema-patternProperties': {
139
+ '[key: *]': function key(...args) {
140
+ return new JSONSchemaElement(...args);
141
+ }
142
+ },
143
+ 'json-schema-dependencies': {
144
+ '[key: *]': function key(...args) {
145
+ return new JSONSchemaElement(...args);
146
+ }
147
+ },
148
+ 'json-schema-allOf': {
149
+ '<*>': function asterisk(...args) {
150
+ return new JSONSchemaElement(...args);
151
+ }
152
+ },
153
+ 'json-schema-anyOf': {
154
+ '<*>': function asterisk(...args) {
155
+ return new JSONSchemaElement(...args);
156
+ }
157
+ },
158
+ 'json-schema-oneOf': {
159
+ '<*>': function asterisk(...args) {
160
+ return new JSONSchemaElement(...args);
161
+ }
162
+ },
163
+ 'json-schema-definitions': {
164
+ '[key: *]': function key(...args) {
165
+ return new JSONSchemaElement(...args);
166
+ }
167
+ },
168
+ 'json-schema-links': {
169
+ '<*>': function asterisk(...args) {
170
+ return new LinkDescriptionElement(...args);
171
+ }
172
+ }
173
+ };
174
+ const findElementFactory = (ancestor, keyName) => {
175
+ var _ancestor$classes$fir, _ancestor$classes$fir2;
176
+ const elementType = getNodeType(ancestor); // @ts-ignore
177
+ 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)];
178
+ return typeof keyMapping === 'undefined' ? undefined : Object.prototype.hasOwnProperty.call(keyMapping, '[key: *]') ? keyMapping['[key: *]'] : keyMapping[keyName];
179
+ };
180
+ const plugin = () => () => {
181
+ return {
182
+ visitor: {
183
+ MemberElement(element, ...rest) {
184
+ // no empty Element, continue with next one
185
+ if (!isEmptyElement(element.value)) return undefined;
186
+ const [,,, ancestors] = rest;
187
+ const ancestor = ancestors[ancestors.length - 1]; // @ts-ignore
188
+ const elementFactory = findElementFactory(ancestor, element.key.toValue());
189
+
190
+ // no element factory found
191
+ if (typeof elementFactory === 'undefined') return undefined;
192
+ const originalValue = element.value;
193
+ return new MemberElement(element.key, elementFactory.call({
194
+ context: ancestor
195
+ }, undefined, originalValue.meta.clone(), originalValue.attributes.clone()), element.meta.clone(), element.attributes.clone());
196
+ },
197
+ StringElement(element, ...rest) {
198
+ if (!isEmptyElement(element)) return undefined;
199
+ const [,,, ancestors] = rest;
200
+ const ancestor = ancestors[ancestors.length - 1];
201
+
202
+ // we're only interested in empty elements in ArrayElements
203
+ if (!isArrayElement(ancestor)) return undefined;
204
+ const elementFactory = findElementFactory(ancestor, '<*>');
205
+
206
+ // no element factory found
207
+ if (typeof elementFactory === 'undefined') return undefined;
208
+ return elementFactory.call({
209
+ context: element
210
+ }, undefined, element.meta.clone(), element.attributes.clone());
211
+ }
212
+ }
213
+ };
214
+ };
215
+ 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,15 @@
1
+ import { pipe, assocPath, dissocPath } from 'ramda';
2
+ import { specificationObj } from '@swagger-api/apidom-ns-json-schema-draft-4';
3
+ import JSONSchemaVisitor from "./visitors/json-schema/index.js";
4
+ import JSONSchema$idVisitor from "./visitors/json-schema/$idVisitor.js";
5
+ import JSONSchemaItemsVisitor from "./visitors/json-schema/ItemsVisitor.js";
6
+ import JSONSchemaConstVisitor from "./visitors/json-schema/ConstVisitor.js";
7
+ import JSONSchemaExamplesVisitor from "./visitors/json-schema/ExamplesVisitor.js";
8
+ import LinkDescriptionVisitor from "./visitors/json-schema/link-description/index.js";
9
+ import LinkDescriptionSubmissionEncTypeVisitor from "./visitors/json-schema/link-description/SubmissionEncTypeVisitor.js";
10
+ const specification = pipe(
11
+ // JSON Schema object modifications
12
+ assocPath(['visitors', 'document', 'objects', 'JSONSchema', '$visitor'], JSONSchemaVisitor), dissocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'id']), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', '$id'], JSONSchema$idVisitor), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'contains'], specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'items'], JSONSchemaItemsVisitor), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'propertyNames'], specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'const'], JSONSchemaConstVisitor), assocPath(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'examples'], JSONSchemaExamplesVisitor),
13
+ // Link Description object modifications
14
+ 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'], LinkDescriptionSubmissionEncTypeVisitor))(specificationObj);
15
+ 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 jsonSchemaDraft6Predicates from "../predicates.js";
6
+ import jsonSchemaDraft6Namespace from "../namespace.js";
7
+ const createToolbox = () => {
8
+ const namespace = createNamespace(jsonSchemaDraft6Namespace);
9
+ const predicates = _objectSpread(_objectSpread({}, jsonSchemaDraft6Predicates), {}, {
10
+ isStringElement
11
+ });
12
+ return {
13
+ predicates,
14
+ namespace
15
+ };
16
+ };
17
+ export default createToolbox;
@@ -0,0 +1,3 @@
1
+ import { FallbackVisitor } from '@swagger-api/apidom-ns-json-schema-draft-4';
2
+ const $idVisitor = FallbackVisitor;
3
+ export default $idVisitor;
@@ -0,0 +1,3 @@
1
+ import { FallbackVisitor } from '@swagger-api/apidom-ns-json-schema-draft-4';
2
+ const ConstVisitor = FallbackVisitor;
3
+ export default ConstVisitor;
@@ -0,0 +1,13 @@
1
+ import stampit from 'stampit';
2
+ import { BREAK } from '@swagger-api/apidom-core';
3
+ import { FallbackVisitor } from '@swagger-api/apidom-ns-json-schema-draft-4';
4
+ const ExamplesVisitor = stampit(FallbackVisitor, {
5
+ methods: {
6
+ ArrayElement(arrayElement) {
7
+ this.element = arrayElement.clone();
8
+ this.element.classes.push('json-schema-examples');
9
+ return BREAK;
10
+ }
11
+ }
12
+ });
13
+ export default ExamplesVisitor;
@@ -0,0 +1,28 @@
1
+ import stampit from 'stampit';
2
+ import { ArrayElement, BREAK } from '@swagger-api/apidom-core';
3
+ import { SpecificationVisitor, FallbackVisitor, ParentSchemaAwareVisitor, isJSONReferenceLikeElement } from '@swagger-api/apidom-ns-json-schema-draft-4';
4
+ const ItemsVisitor = stampit(SpecificationVisitor, ParentSchemaAwareVisitor, FallbackVisitor, {
5
+ methods: {
6
+ ObjectElement(objectElement) {
7
+ const specPath = isJSONReferenceLikeElement(objectElement) ? ['document', 'objects', 'JSONReference'] : ['document', 'objects', 'JSONSchema'];
8
+ this.element = this.toRefractedElement(specPath, objectElement);
9
+ return BREAK;
10
+ },
11
+ ArrayElement(arrayElement) {
12
+ this.element = new ArrayElement();
13
+ this.element.classes.push('json-schema-items');
14
+ arrayElement.forEach(item => {
15
+ const specPath = isJSONReferenceLikeElement(item) ? ['document', 'objects', 'JSONReference'] : ['document', 'objects', 'JSONSchema'];
16
+ const element = this.toRefractedElement(specPath, item);
17
+ this.element.push(element);
18
+ });
19
+ this.copyMetaAndAttributes(arrayElement, this.element);
20
+ return BREAK;
21
+ },
22
+ BooleanElement(booleanElement) {
23
+ this.element = this.toRefractedElement(['document', 'objects', 'JSONSchema'], booleanElement);
24
+ return BREAK;
25
+ }
26
+ }
27
+ });
28
+ export default ItemsVisitor;
@@ -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-4';
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,3 @@
1
+ import { FallbackVisitor } from '@swagger-api/apidom-ns-json-schema-draft-4';
2
+ const SubmissionEncTypeVisitor = FallbackVisitor;
3
+ export default SubmissionEncTypeVisitor;
@@ -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-4';
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,18 @@
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
+ JSONSchemaDraft6Element: ['content'],
15
+ JSONReferenceElement: ['content'],
16
+ MediaElement: ['content'],
17
+ LinkDescriptionElement: ['content']
18
+ }, keyMapBase);
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@swagger-api/apidom-ns-json-schema-draft-6",
3
+ "version": "0.68.1",
4
+ "description": "JSON Schema Draft 6 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-6.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-4": "^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
+ }