@speclynx/apidom-ns-json-schema-draft-7 3.2.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,134 +0,0 @@
1
- import { UnsupportedOperationError } from '@speclynx/apidom-error';
2
- import { LinkDescriptionElement } from '@speclynx/apidom-ns-json-schema-draft-6';
3
- /**
4
- * URI: https://datatracker.ietf.org/doc/html/draft-wright-json-schema-hyperschema-01#section-6
5
- * @public
6
- */
7
-
8
- class LinkDescription extends LinkDescriptionElement {
9
- /**
10
- * Link context.
11
- *
12
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-01#section-6.1
13
- */
14
-
15
- get anchor() {
16
- return this.get('anchor');
17
- }
18
- set anchor(anchor) {
19
- this.set('anchor', anchor);
20
- }
21
- get anchorPointer() {
22
- return this.get('anchorPointer');
23
- }
24
- set anchorPointer(anchorPointer) {
25
- this.set('anchorPointer', anchorPointer);
26
- }
27
-
28
- /**
29
- * Adjusting URI Template Resolution.
30
- *
31
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-01#section-6.4
32
- */
33
-
34
- get templatePointers() {
35
- return this.get('templatePointers');
36
- }
37
- set templatePointers(templatePointers) {
38
- this.set('templatePointers', templatePointers);
39
- }
40
- get templateRequired() {
41
- return this.get('templateRequired');
42
- }
43
- set templateRequired(templateRequired) {
44
- this.set('templateRequired', templateRequired);
45
- }
46
-
47
- /**
48
- * Link Target Attributes.
49
- *
50
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-01#section-6.5
51
- */
52
-
53
- get targetSchema() {
54
- return this.get('targetSchema');
55
- }
56
- set targetSchema(targetSchema) {
57
- this.set('targetSchema', targetSchema);
58
- }
59
- get mediaType() {
60
- throw new UnsupportedOperationError('mediaType keyword from Hyper-Schema vocabulary has been renamed to targetMediaType.');
61
- }
62
- set mediaType(mediaType) {
63
- throw new UnsupportedOperationError('mediaType keyword from Hyper-Schema vocabulary has been renamed to targetMediaType.');
64
- }
65
- get targetMediaType() {
66
- return this.get('targetMediaType');
67
- }
68
- set targetMediaType(targetMediaType) {
69
- this.set('targetMediaType', targetMediaType);
70
- }
71
- get targetHints() {
72
- return this.get('targetHints');
73
- }
74
- set targetHints(targetHints) {
75
- this.set('targetHints', targetHints);
76
- }
77
- get description() {
78
- return this.get('description');
79
- }
80
- set description(description) {
81
- this.set('description', description);
82
- }
83
- get $comment() {
84
- return this.get('$comment');
85
- }
86
- set $comment($comment) {
87
- this.set('$comment', $comment);
88
- }
89
-
90
- /**
91
- * Link Input.
92
- *
93
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-01#section-6.6
94
- */
95
-
96
- get hrefSchema() {
97
- return this.get('hrefSchema');
98
- }
99
- set hrefSchema(hrefSchema) {
100
- this.set('hrefSchema', hrefSchema);
101
- }
102
- get headerSchema() {
103
- return this.get('headerSchema');
104
- }
105
- set headerSchema(headerSchema) {
106
- this.set('headerSchema', headerSchema);
107
- }
108
-
109
- /**
110
- * Submitting Data for Processing.
111
- *
112
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-01#section-6.6.4
113
- */
114
-
115
- get submissionSchema() {
116
- return this.get('submissionSchema');
117
- }
118
- set submissionSchema(submissionSchema) {
119
- this.set('submissionSchema', submissionSchema);
120
- }
121
- get submissionEncType() {
122
- throw new UnsupportedOperationError('submissionEncType keyword from Hyper-Schema vocabulary has been renamed to submissionMediaType.');
123
- }
124
- set submissionEncType(submissionEncType) {
125
- throw new UnsupportedOperationError('submissionEncType keyword from Hyper-Schema vocabulary has been renamed to submissionMediaType.');
126
- }
127
- get submissionMediaType() {
128
- return this.get('submissionMediaType');
129
- }
130
- set submissionMediaType(submissionMediaType) {
131
- this.set('submissionMediaType', submissionMediaType);
132
- }
133
- }
134
- export default LinkDescription;
package/src/index.cjs DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
5
- exports.__esModule = true;
6
- exports.specificationObj = exports.refractorPluginReplaceEmptyElement = exports.refractLinkDescription = exports.refractJSONSchema = exports.refract = exports.mediaTypes = exports.isLinkDescriptionElement = exports.isJSONSchemaElement = exports.isJSONReferenceLikeElement = exports.isJSONReferenceElement = exports.isBooleanJSONSchemaElement = exports.default = exports.Visitor = exports.SpecificationVisitor = exports.PatternedFieldsVisitor = exports.ParentSchemaAwareVisitor = exports.MapVisitor = exports.LinkDescriptionVisitor = exports.LinkDescriptionElement = exports.JSONSchemaVisitor = exports.JSONSchemaElement = exports.JSONSchemaDraft7MediaTypes = exports.JSONReferenceElement = exports.FixedFieldsVisitor = exports.FallbackVisitor = exports.AlternatingVisitor = void 0;
7
- var _mediaTypes = _interopRequireWildcard(require("./media-types.cjs"));
8
- exports.mediaTypes = _mediaTypes.default;
9
- exports.JSONSchemaDraft7MediaTypes = _mediaTypes.JSONSchemaDraft7MediaTypes;
10
- var _namespace = _interopRequireDefault(require("./namespace.cjs"));
11
- exports.default = _namespace.default;
12
- var _replaceEmptyElement = _interopRequireDefault(require("./refractor/plugins/replace-empty-element.cjs"));
13
- exports.refractorPluginReplaceEmptyElement = _replaceEmptyElement.default;
14
- var _index = _interopRequireWildcard(require("./refractor/index.cjs"));
15
- exports.refract = _index.default;
16
- exports.refractJSONSchema = _index.refractJSONSchema;
17
- exports.refractLinkDescription = _index.refractLinkDescription;
18
- var _specification = _interopRequireDefault(require("./refractor/specification.cjs"));
19
- exports.specificationObj = _specification.default;
20
- var _predicates = require("./predicates.cjs");
21
- exports.isBooleanJSONSchemaElement = _predicates.isBooleanJSONSchemaElement;
22
- exports.isJSONReferenceElement = _predicates.isJSONReferenceElement;
23
- exports.isJSONSchemaElement = _predicates.isJSONSchemaElement;
24
- exports.isLinkDescriptionElement = _predicates.isLinkDescriptionElement;
25
- var _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-6");
26
- exports.isJSONReferenceLikeElement = _apidomNsJsonSchemaDraft.isJSONReferenceLikeElement;
27
- exports.SpecificationVisitor = _apidomNsJsonSchemaDraft.SpecificationVisitor;
28
- exports.FallbackVisitor = _apidomNsJsonSchemaDraft.FallbackVisitor;
29
- exports.FixedFieldsVisitor = _apidomNsJsonSchemaDraft.FixedFieldsVisitor;
30
- exports.PatternedFieldsVisitor = _apidomNsJsonSchemaDraft.PatternedFieldsVisitor;
31
- exports.MapVisitor = _apidomNsJsonSchemaDraft.MapVisitor;
32
- exports.AlternatingVisitor = _apidomNsJsonSchemaDraft.AlternatingVisitor;
33
- exports.ParentSchemaAwareVisitor = _apidomNsJsonSchemaDraft.ParentSchemaAwareVisitor;
34
- exports.Visitor = _apidomNsJsonSchemaDraft.Visitor;
35
- var _index2 = _interopRequireDefault(require("./refractor/visitors/json-schema/index.cjs"));
36
- exports.JSONSchemaVisitor = _index2.default;
37
- var _index3 = _interopRequireDefault(require("./refractor/visitors/json-schema/link-description/index.cjs"));
38
- exports.LinkDescriptionVisitor = _index3.default;
39
- var _inspect = require("./refractor/inspect.cjs");
40
- exports.JSONSchemaElement = _inspect.JSONSchemaElement;
41
- exports.JSONReferenceElement = _inspect.JSONReferenceElement;
42
- exports.LinkDescriptionElement = _inspect.LinkDescriptionElement;
package/src/index.mjs DELETED
@@ -1,13 +0,0 @@
1
- export { default as mediaTypes, JSONSchemaDraft7MediaTypes } from "./media-types.mjs";
2
- export { default } from "./namespace.mjs";
3
- export { default as refractorPluginReplaceEmptyElement } from "./refractor/plugins/replace-empty-element.mjs";
4
- export { default as refract, refractJSONSchema, refractLinkDescription } from "./refractor/index.mjs";
5
- export { default as specificationObj } from "./refractor/specification.mjs";
6
- export { isBooleanJSONSchemaElement, isJSONReferenceElement, isJSONSchemaElement, isLinkDescriptionElement } from "./predicates.mjs";
7
- export { isJSONReferenceLikeElement, SpecificationVisitor, FallbackVisitor, FixedFieldsVisitor, PatternedFieldsVisitor, MapVisitor, AlternatingVisitor, ParentSchemaAwareVisitor, Visitor } from '@speclynx/apidom-ns-json-schema-draft-6';
8
- export { default as JSONSchemaVisitor } from "./refractor/visitors/json-schema/index.mjs";
9
- export { default as LinkDescriptionVisitor } from "./refractor/visitors/json-schema/link-description/index.mjs";
10
- /**
11
- * JSON Schema Draft 7 specification elements.
12
- */
13
- export { JSONSchemaElement, JSONReferenceElement, LinkDescriptionElement } from "./refractor/inspect.mjs";
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = exports.JSONSchemaDraft7MediaTypes = void 0;
5
- var _ramda = require("ramda");
6
- var _apidomCore = require("@speclynx/apidom-core");
7
- /**
8
- * @public
9
- */
10
-
11
- /**
12
- * @public
13
- */
14
- class JSONSchemaDraft7MediaTypes extends _apidomCore.MediaTypes {
15
- filterByFormat(format = 'generic') {
16
- const effectiveFormat = format === 'generic' ? 'schema;version' : format;
17
- return this.filter(mediaType => mediaType.includes(effectiveFormat));
18
- }
19
- findBy(version = 'draft-07', format = 'generic') {
20
- const search = format === 'generic' ? `schema;version=${version}` : `schema+${format};version=${version}`;
21
- const found = this.find(mediaType => mediaType.includes(search));
22
- return found || this.unknownMediaType;
23
- }
24
- latest(format = 'generic') {
25
- return (0, _ramda.last)(this.filterByFormat(format));
26
- }
27
- }
28
-
29
- /**
30
- * @public
31
- */
32
- exports.JSONSchemaDraft7MediaTypes = JSONSchemaDraft7MediaTypes;
33
- const mediaTypes = new JSONSchemaDraft7MediaTypes('application/schema;version=draft-07', 'application/schema+json;version=draft-07', 'application/schema+yaml;version=draft-07');
34
- var _default = exports.default = mediaTypes;
@@ -1,30 +0,0 @@
1
- import { last } from 'ramda';
2
- import { MediaTypes } from '@speclynx/apidom-core';
3
-
4
- /**
5
- * @public
6
- */
7
-
8
- /**
9
- * @public
10
- */
11
- export class JSONSchemaDraft7MediaTypes extends MediaTypes {
12
- filterByFormat(format = 'generic') {
13
- const effectiveFormat = format === 'generic' ? 'schema;version' : format;
14
- return this.filter(mediaType => mediaType.includes(effectiveFormat));
15
- }
16
- findBy(version = 'draft-07', format = 'generic') {
17
- const search = format === 'generic' ? `schema;version=${version}` : `schema+${format};version=${version}`;
18
- const found = this.find(mediaType => mediaType.includes(search));
19
- return found || this.unknownMediaType;
20
- }
21
- latest(format = 'generic') {
22
- return last(this.filterByFormat(format));
23
- }
24
- }
25
-
26
- /**
27
- * @public
28
- */
29
- const mediaTypes = new JSONSchemaDraft7MediaTypes('application/schema;version=draft-07', 'application/schema+json;version=draft-07', 'application/schema+yaml;version=draft-07');
30
- export default mediaTypes;
package/src/namespace.cjs DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
- exports.__esModule = true;
5
- exports.default = void 0;
6
- var _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-6");
7
- var _JSONSchema = _interopRequireDefault(require("./elements/JSONSchema.cjs"));
8
- var _LinkDescription = _interopRequireDefault(require("./elements/LinkDescription.cjs"));
9
- /**
10
- * @public
11
- */
12
- const jsonSchemaDraft7 = {
13
- namespace: options => {
14
- const {
15
- base
16
- } = options;
17
- base.register('jSONSchemaDraft7', _JSONSchema.default);
18
- base.register('jSONReference', _apidomNsJsonSchemaDraft.JSONReferenceElement);
19
- base.register('linkDescription', _LinkDescription.default);
20
- return base;
21
- }
22
- };
23
- var _default = exports.default = jsonSchemaDraft7;
package/src/namespace.mjs DELETED
@@ -1,18 +0,0 @@
1
- import { JSONReferenceElement } from '@speclynx/apidom-ns-json-schema-draft-6';
2
- import JSONSchemaElement from "./elements/JSONSchema.mjs";
3
- import LinkDescriptionElement from "./elements/LinkDescription.mjs";
4
- /**
5
- * @public
6
- */
7
- const jsonSchemaDraft7 = {
8
- namespace: options => {
9
- const {
10
- base
11
- } = options;
12
- base.register('jSONSchemaDraft7', JSONSchemaElement);
13
- base.register('jSONReference', JSONReferenceElement);
14
- base.register('linkDescription', LinkDescriptionElement);
15
- return base;
16
- }
17
- };
18
- export default jsonSchemaDraft7;
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
- exports.__esModule = true;
5
- exports.isMediaElement = exports.isLinkDescriptionElement = exports.isJSONSchemaElement = exports.isJSONReferenceElement = exports.isBooleanJSONSchemaElement = void 0;
6
- var _JSONSchema = _interopRequireDefault(require("./elements/JSONSchema.cjs"));
7
- var _LinkDescription = _interopRequireDefault(require("./elements/LinkDescription.cjs"));
8
- var _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-6");
9
- exports.isJSONReferenceElement = _apidomNsJsonSchemaDraft.isJSONReferenceElement;
10
- exports.isMediaElement = _apidomNsJsonSchemaDraft.isMediaElement;
11
- exports.isBooleanJSONSchemaElement = _apidomNsJsonSchemaDraft.isBooleanJSONSchemaElement;
12
- /**
13
- * @public
14
- */
15
- const isJSONSchemaElement = element => element instanceof _JSONSchema.default;
16
-
17
- /**
18
- * @public
19
- */
20
- exports.isJSONSchemaElement = isJSONSchemaElement;
21
- const isLinkDescriptionElement = element => element instanceof _LinkDescription.default;
22
- exports.isLinkDescriptionElement = isLinkDescriptionElement;
@@ -1,13 +0,0 @@
1
- import JSONSchemaElement from "./elements/JSONSchema.mjs";
2
- import LinkDescriptionElement from "./elements/LinkDescription.mjs";
3
- export { isJSONReferenceElement, isMediaElement, isBooleanJSONSchemaElement } from '@speclynx/apidom-ns-json-schema-draft-6';
4
-
5
- /**
6
- * @public
7
- */
8
- export const isJSONSchemaElement = element => element instanceof JSONSchemaElement;
9
-
10
- /**
11
- * @public
12
- */
13
- export const isLinkDescriptionElement = element => element instanceof LinkDescriptionElement;
@@ -1,76 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
- exports.__esModule = true;
5
- exports.refractLinkDescription = exports.refractJSONSchema = exports.default = void 0;
6
- var _apidomCore = require("@speclynx/apidom-core");
7
- var _apidomTraverse = require("@speclynx/apidom-traverse");
8
- var _apidomDatamodel = require("@speclynx/apidom-datamodel");
9
- var _ramda = require("ramda");
10
- var _specification = _interopRequireDefault(require("./specification.cjs"));
11
- var _toolbox = _interopRequireDefault(require("./toolbox.cjs"));
12
- /**
13
- * @public
14
- */
15
-
16
- /**
17
- * @public
18
- */
19
-
20
- /**
21
- * @public
22
- */
23
- const refract = (value, {
24
- element = 'jSONSchemaDraft7',
25
- plugins = [],
26
- specificationObj = _specification.default,
27
- consume = false
28
- } = {}) => {
29
- const genericElement = (0, _apidomDatamodel.refract)(value);
30
- const resolvedSpec = (0, _apidomCore.resolveSpecification)(specificationObj);
31
- const elementMap = resolvedSpec.elementMap;
32
- const specPath = elementMap[element];
33
- if (!specPath) {
34
- throw new Error(`Unknown element type: "${element}"`);
35
- }
36
-
37
- /**
38
- * This is where generic ApiDOM becomes semantic (namespace applied).
39
- * We don't allow consumers to hook into this translation.
40
- * Though we allow consumers to define their own plugins on already transformed ApiDOM.
41
- */
42
- const RootVisitorClass = (0, _ramda.path)(specPath, resolvedSpec);
43
- const rootVisitor = new RootVisitorClass({
44
- specObj: resolvedSpec,
45
- consume
46
- });
47
- (0, _apidomTraverse.traverse)(genericElement, rootVisitor);
48
-
49
- /**
50
- * Running plugins visitors means extra single traversal === performance hit.
51
- */
52
- return (0, _apidomCore.dispatchRefractorPlugins)(rootVisitor.element, plugins, {
53
- toolboxCreator: _toolbox.default
54
- });
55
- };
56
-
57
- /**
58
- * Refracts a value into a JSONSchemaElement.
59
- * @public
60
- */
61
- const refractJSONSchema = (value, options = {}) => refract(value, {
62
- ...options,
63
- element: 'jSONSchemaDraft7'
64
- });
65
-
66
- /**
67
- * Refracts a value into a LinkDescriptionElement.
68
- * @public
69
- */
70
- exports.refractJSONSchema = refractJSONSchema;
71
- const refractLinkDescription = (value, options = {}) => refract(value, {
72
- ...options,
73
- element: 'linkDescription'
74
- });
75
- exports.refractLinkDescription = refractLinkDescription;
76
- var _default = exports.default = refract;
@@ -1,67 +0,0 @@
1
- import { resolveSpecification, dispatchRefractorPlugins } from '@speclynx/apidom-core';
2
- import { traverse } from '@speclynx/apidom-traverse';
3
- import { refract as baseRefract } from '@speclynx/apidom-datamodel';
4
- import { path } from 'ramda';
5
- import specification from "./specification.mjs";
6
- import createToolbox from "./toolbox.mjs";
7
- /**
8
- * @public
9
- */
10
- /**
11
- * @public
12
- */
13
- /**
14
- * @public
15
- */
16
- const refract = (value, {
17
- element = 'jSONSchemaDraft7',
18
- plugins = [],
19
- specificationObj = specification,
20
- consume = false
21
- } = {}) => {
22
- const genericElement = baseRefract(value);
23
- const resolvedSpec = resolveSpecification(specificationObj);
24
- const elementMap = resolvedSpec.elementMap;
25
- const specPath = elementMap[element];
26
- if (!specPath) {
27
- throw new Error(`Unknown element type: "${element}"`);
28
- }
29
-
30
- /**
31
- * This is where generic ApiDOM becomes semantic (namespace applied).
32
- * We don't allow consumers to hook into this translation.
33
- * Though we allow consumers to define their own plugins on already transformed ApiDOM.
34
- */
35
- const RootVisitorClass = path(specPath, resolvedSpec);
36
- const rootVisitor = new RootVisitorClass({
37
- specObj: resolvedSpec,
38
- consume
39
- });
40
- traverse(genericElement, rootVisitor);
41
-
42
- /**
43
- * Running plugins visitors means extra single traversal === performance hit.
44
- */
45
- return dispatchRefractorPlugins(rootVisitor.element, plugins, {
46
- toolboxCreator: createToolbox
47
- });
48
- };
49
-
50
- /**
51
- * Refracts a value into a JSONSchemaElement.
52
- * @public
53
- */
54
- export const refractJSONSchema = (value, options = {}) => refract(value, {
55
- ...options,
56
- element: 'jSONSchemaDraft7'
57
- });
58
-
59
- /**
60
- * Refracts a value into a LinkDescriptionElement.
61
- * @public
62
- */
63
- export const refractLinkDescription = (value, options = {}) => refract(value, {
64
- ...options,
65
- element: 'linkDescription'
66
- });
67
- export default refract;
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
- exports.__esModule = true;
5
- var _apidomCore = require("@speclynx/apidom-core");
6
- var _ramdaAdjunct = require("ramda-adjunct");
7
- var _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-6");
8
- exports.JSONReferenceElement = _apidomNsJsonSchemaDraft.JSONReferenceElement;
9
- var _JSONSchema = _interopRequireDefault(require("../elements/JSONSchema.cjs"));
10
- exports.JSONSchemaElement = _JSONSchema.default;
11
- var _LinkDescription = _interopRequireDefault(require("../elements/LinkDescription.cjs"));
12
- exports.LinkDescriptionElement = _LinkDescription.default;
13
- var _specification = _interopRequireDefault(require("./specification.cjs"));
14
- /**
15
- * @public
16
- */
17
-
18
- // Resolve specification to dereference $ref pointers
19
- const resolvedSpec = (0, _apidomCore.resolveSpecification)(_specification.default);
20
-
21
- // Extract fixed fields as list of { name, alias?, $visitor }
22
- const getFixedFields = fixedFieldsSpec => {
23
- return Object.entries(fixedFieldsSpec).map(([name, fieldSpec]) => {
24
- if ((0, _ramdaAdjunct.isPlainObject)(fieldSpec)) {
25
- return {
26
- name,
27
- ...fieldSpec
28
- };
29
- }
30
- return {
31
- name,
32
- $visitor: fieldSpec
33
- };
34
- });
35
- };
36
-
37
- // Define lazy getters for fixedFields on element classes
38
- // Note: JSONReferenceElement inherits fixedFields from draft-6/draft-4
39
- Object.defineProperty(_JSONSchema.default, 'fixedFields', {
40
- get: () => getFixedFields(resolvedSpec.visitors.document.objects.JSONSchema.fixedFields),
41
- enumerable: true
42
- });
43
- Object.defineProperty(_LinkDescription.default, 'fixedFields', {
44
- get: () => getFixedFields(resolvedSpec.visitors.document.objects.LinkDescription.fixedFields),
45
- enumerable: true
46
- });
@@ -1,39 +0,0 @@
1
- import { resolveSpecification } from '@speclynx/apidom-core';
2
- import { isPlainObject } from 'ramda-adjunct';
3
- import { JSONReferenceElement } from '@speclynx/apidom-ns-json-schema-draft-6';
4
- import JSONSchemaElement from "../elements/JSONSchema.mjs";
5
- import LinkDescriptionElement from "../elements/LinkDescription.mjs";
6
- import specification from "./specification.mjs";
7
- /**
8
- * @public
9
- */
10
- // Resolve specification to dereference $ref pointers
11
- const resolvedSpec = resolveSpecification(specification);
12
-
13
- // Extract fixed fields as list of { name, alias?, $visitor }
14
- const getFixedFields = fixedFieldsSpec => {
15
- return Object.entries(fixedFieldsSpec).map(([name, fieldSpec]) => {
16
- if (isPlainObject(fieldSpec)) {
17
- return {
18
- name,
19
- ...fieldSpec
20
- };
21
- }
22
- return {
23
- name,
24
- $visitor: fieldSpec
25
- };
26
- });
27
- };
28
-
29
- // Define lazy getters for fixedFields on element classes
30
- // Note: JSONReferenceElement inherits fixedFields from draft-6/draft-4
31
- Object.defineProperty(JSONSchemaElement, 'fixedFields', {
32
- get: () => getFixedFields(resolvedSpec.visitors.document.objects.JSONSchema.fixedFields),
33
- enumerable: true
34
- });
35
- Object.defineProperty(LinkDescriptionElement, 'fixedFields', {
36
- get: () => getFixedFields(resolvedSpec.visitors.document.objects.LinkDescription.fixedFields),
37
- enumerable: true
38
- });
39
- export { JSONSchemaElement, JSONReferenceElement, LinkDescriptionElement };