@speclynx/apidom-ns-json-schema-draft-4 1.12.1 → 2.0.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 +25 -0
- package/NOTICE +16 -7
- package/README.md +24 -24
- package/dist/apidom-ns-json-schema-draft-4.browser.js +1 -1
- package/package.json +8 -8
- package/src/elements/JSONReference.cjs +2 -2
- package/src/elements/JSONReference.mjs +1 -2
- package/src/elements/JSONSchema.cjs +9 -9
- package/src/elements/JSONSchema.mjs +8 -8
- package/src/elements/LinkDescription.cjs +2 -2
- package/src/elements/LinkDescription.mjs +1 -1
- package/src/elements/Media.cjs +2 -2
- package/src/elements/Media.mjs +1 -2
- package/src/index.cjs +24 -21
- package/src/index.mjs +3 -4
- package/src/predicates.cjs +8 -29
- package/src/predicates.mjs +4 -29
- package/src/refractor/index.cjs +57 -16
- package/src/refractor/index.mjs +51 -15
- package/src/refractor/inspect.cjs +55 -0
- package/src/refractor/inspect.mjs +47 -0
- package/src/refractor/plugins/replace-empty-element.cjs +27 -21
- package/src/refractor/plugins/replace-empty-element.mjs +14 -8
- package/src/refractor/predicates.cjs +2 -2
- package/src/refractor/predicates.mjs +1 -1
- package/src/refractor/specification.cjs +14 -3
- package/src/refractor/specification.mjs +14 -3
- package/src/refractor/toolbox.cjs +10 -3
- package/src/refractor/toolbox.mjs +8 -2
- package/src/refractor/visitors/FallbackVisitor.cjs +4 -4
- package/src/refractor/visitors/FallbackVisitor.mjs +4 -4
- package/src/refractor/visitors/SpecificationVisitor.cjs +4 -3
- package/src/refractor/visitors/SpecificationVisitor.mjs +3 -2
- package/src/refractor/visitors/Visitor.cjs +10 -8
- package/src/refractor/visitors/Visitor.mjs +11 -9
- package/src/refractor/visitors/generics/AlternatingVisitor.cjs +3 -3
- package/src/refractor/visitors/generics/AlternatingVisitor.mjs +3 -3
- package/src/refractor/visitors/generics/FixedFieldsVisitor.cjs +10 -7
- package/src/refractor/visitors/generics/FixedFieldsVisitor.mjs +9 -6
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.cjs +9 -6
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.mjs +8 -5
- package/src/refractor/visitors/json-schema/AllOfVisitor.cjs +7 -10
- package/src/refractor/visitors/json-schema/AllOfVisitor.mjs +6 -8
- package/src/refractor/visitors/json-schema/AnyOfVisitor.cjs +7 -10
- package/src/refractor/visitors/json-schema/AnyOfVisitor.mjs +6 -8
- package/src/refractor/visitors/json-schema/DefinitionsVisitor.cjs +4 -8
- package/src/refractor/visitors/json-schema/DefinitionsVisitor.mjs +3 -6
- package/src/refractor/visitors/json-schema/DependenciesVisitor.cjs +4 -8
- package/src/refractor/visitors/json-schema/DependenciesVisitor.mjs +3 -6
- package/src/refractor/visitors/json-schema/EnumVisitor.cjs +2 -3
- package/src/refractor/visitors/json-schema/EnumVisitor.mjs +2 -3
- package/src/refractor/visitors/json-schema/ItemsVisitor.cjs +10 -12
- package/src/refractor/visitors/json-schema/ItemsVisitor.mjs +9 -10
- package/src/refractor/visitors/json-schema/LinksVisitor.cjs +7 -10
- package/src/refractor/visitors/json-schema/LinksVisitor.mjs +6 -8
- package/src/refractor/visitors/json-schema/OneOfVisitor.cjs +7 -10
- package/src/refractor/visitors/json-schema/OneOfVisitor.mjs +6 -8
- package/src/refractor/visitors/json-schema/PatternPropertiesVisitor.cjs +4 -8
- package/src/refractor/visitors/json-schema/PatternPropertiesVisitor.mjs +3 -6
- package/src/refractor/visitors/json-schema/PropertiesVisitor.cjs +4 -8
- package/src/refractor/visitors/json-schema/PropertiesVisitor.mjs +3 -6
- package/src/refractor/visitors/json-schema/RequiredVisitor.cjs +2 -3
- package/src/refractor/visitors/json-schema/RequiredVisitor.mjs +2 -3
- package/src/refractor/visitors/json-schema/TypeVisitor.cjs +4 -6
- package/src/refractor/visitors/json-schema/TypeVisitor.mjs +4 -6
- package/src/refractor/visitors/json-schema/bases.cjs +45 -0
- package/src/refractor/visitors/json-schema/bases.mjs +39 -0
- package/src/refractor/visitors/json-schema/index.cjs +12 -12
- package/src/refractor/visitors/json-schema/index.mjs +11 -11
- package/src/refractor/visitors/json-schema/json-reference/$RefVisitor.cjs +2 -3
- package/src/refractor/visitors/json-schema/json-reference/$RefVisitor.mjs +2 -3
- package/src/refractor/visitors/json-schema/json-reference/index.cjs +6 -8
- package/src/refractor/visitors/json-schema/json-reference/index.mjs +5 -7
- package/src/refractor/visitors/json-schema/link-description/index.cjs +2 -4
- package/src/refractor/visitors/json-schema/link-description/index.mjs +2 -4
- package/src/refractor/visitors/json-schema/media/index.cjs +2 -4
- package/src/refractor/visitors/json-schema/media/index.mjs +2 -4
- package/types/apidom-ns-json-schema-draft-4.d.ts +169 -151
- package/src/refractor/registration.cjs +0 -19
- package/src/refractor/registration.mjs +0 -10
- package/src/traversal/visitor.cjs +0 -26
- package/src/traversal/visitor.mjs +0 -22
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,31 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.0.1](https://github.com/speclynx/apidom/compare/v2.0.0...v2.0.1) (2026-01-14)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @speclynx/apidom-ns-json-schema-draft-4
|
|
9
|
+
|
|
10
|
+
# [2.0.0](https://github.com/speclynx/apidom/compare/v1.12.2...v2.0.0) (2026-01-14)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- limit source maps memory consuption ([#20](https://github.com/speclynx/apidom/issues/20)) ([4a0574f](https://github.com/speclynx/apidom/commit/4a0574fd6d466be7c33c8a5871baacd384918d22))
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- apply innovations learned during last 3 years ([#11](https://github.com/speclynx/apidom/issues/11)) ([cfdbbfc](https://github.com/speclynx/apidom/commit/cfdbbfc2721b0dadc77eeba31dd4e8768c078d22))
|
|
19
|
+
- **traverse:** move traverse operations to apidom-traverse package ([#18](https://github.com/speclynx/apidom/issues/18)) ([36c9d49](https://github.com/speclynx/apidom/commit/36c9d490ceac2ea961e2b23fbbc72df7fb54bbf3))
|
|
20
|
+
|
|
21
|
+
### BREAKING CHANGES
|
|
22
|
+
|
|
23
|
+
- source maps have been completely rewritten
|
|
24
|
+
- **traverse:** move traverse operations from core to traverse package
|
|
25
|
+
- breaking changes introduced to every package public API
|
|
26
|
+
|
|
27
|
+
## [1.12.2](https://github.com/speclynx/apidom/compare/v1.12.1...v1.12.2) (2025-12-23)
|
|
28
|
+
|
|
29
|
+
**Note:** Version bump only for package @speclynx/apidom-ns-json-schema-draft-4
|
|
30
|
+
|
|
6
31
|
## [1.12.1](https://github.com/speclynx/apidom/compare/v1.12.0...v1.12.1) (2025-12-23)
|
|
7
32
|
|
|
8
33
|
**Note:** Version bump only for package @speclynx/apidom-ns-json-schema-draft-4
|
package/NOTICE
CHANGED
|
@@ -5,11 +5,6 @@ This distribution includes modifications by SpecLynx.
|
|
|
5
5
|
All such modifications are licensed under the Apache License, Version 2.0.
|
|
6
6
|
A copy of the Apache 2.0 license can be found in `LICENSES/Apache-2.0.txt`.
|
|
7
7
|
|
|
8
|
-
ApiDOM
|
|
9
|
-
Copyright 2020 SmartBear Software Inc.
|
|
10
|
-
ApiDOM is licensed under Apache 2.0 license.
|
|
11
|
-
Copy of the Apache 2.0 license can be found in `LICENSES/Apache-2.0.txt` file.
|
|
12
|
-
|
|
13
8
|
json-schema-ref-parser
|
|
14
9
|
Copyright (c) 2015 James Messinger
|
|
15
10
|
File packages/apidom-reference/src/util/url.ts (the file) was originally created under MIT license in https://github.com/APIDevTools/json-schema-ref-parser repository.
|
|
@@ -18,8 +13,8 @@ Copy of the MIT license can be found in `LICENSES/MIT.txt` file.
|
|
|
18
13
|
|
|
19
14
|
graphql-js
|
|
20
15
|
Copyright (c) GraphQL Contributors
|
|
21
|
-
File packages/apidom-
|
|
22
|
-
|
|
16
|
+
File packages/apidom-traverse/src/traversal.ts (the file) was originally inspired by https://github.com/graphql/graphql-js repository.
|
|
17
|
+
All modifications are licensed under Apache 2.0 License.
|
|
23
18
|
Copy of the MIT license can be found in `LICENSES/MIT.txt` file.
|
|
24
19
|
|
|
25
20
|
babel-plugin-add-import-extension
|
|
@@ -54,6 +49,20 @@ Copyright (c) 2012 James Halliday, Josh Duff, and other contributors
|
|
|
54
49
|
Copy of the MIT license can be found in `LICENSES/MIT.txt` file.
|
|
55
50
|
All modifications are licensed under Apache 2.0 License.
|
|
56
51
|
|
|
52
|
+
ApiDOM
|
|
53
|
+
Copyright 2020 SmartBear Software Inc.
|
|
54
|
+
ApiDOM is licensed under Apache 2.0 license.
|
|
55
|
+
Copy of the Apache 2.0 license can be found in `LICENSES/Apache-2.0.txt` file.
|
|
56
|
+
|
|
57
|
+
minim
|
|
58
|
+
Copyright (c) 2014 Stephen Mizell
|
|
59
|
+
The apidom-datamodel package contains code originally created under the MIT
|
|
60
|
+
License as part of the Minim project (https://github.com/refractproject/minim).
|
|
61
|
+
This code has been copied into this project and modified.
|
|
62
|
+
The original portions remain licensed under the MIT License. Our modifications
|
|
63
|
+
to that code are licensed under the Apache License 2.0.
|
|
64
|
+
Copy of the MIT license can be found in `LICENSES/MIT.txt` file.
|
|
65
|
+
|
|
57
66
|
---
|
|
58
67
|
|
|
59
68
|
If the SPDX-FileCopyrightText and SPDX-License-Identifier tags are not present in the file,
|
package/README.md
CHANGED
|
@@ -15,13 +15,14 @@ You can install this package via [npm CLI](https://docs.npmjs.com/cli) by runnin
|
|
|
15
15
|
## JSON Schema Draft 4 namespace
|
|
16
16
|
|
|
17
17
|
JSON Schema Draft 4 namespace consists of [number of elements](https://github.com/speclynx/apidom/tree/main/packages/apidom-ns-json-schema-draft-4/src/elements) implemented on top
|
|
18
|
-
of [primitive ones](https://github.com/
|
|
18
|
+
of [primitive ones](https://github.com/speclynx/apidom/tree/main/packages/apidom-datamodel/src/primitives).
|
|
19
19
|
|
|
20
20
|
```js
|
|
21
|
-
import {
|
|
21
|
+
import { Namespace } from '@speclynx/apidom-datamodel';
|
|
22
22
|
import jsonShemaDraft4Namespace from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
23
23
|
|
|
24
|
-
const namespace =
|
|
24
|
+
const namespace = new Namespace();
|
|
25
|
+
namespace.use(jsonShemaDraft4Namespace);
|
|
25
26
|
|
|
26
27
|
const objectElement = new namespace.elements.Object();
|
|
27
28
|
const jsonSchemaElement = new namespace.elements.JSONSchemaDraft4();
|
|
@@ -56,23 +57,22 @@ isJSONSchemaElement(jsonSchemaElement); // => true
|
|
|
56
57
|
|
|
57
58
|
## Traversal
|
|
58
59
|
|
|
59
|
-
Traversing ApiDOM in this namespace is possible by using `
|
|
60
|
-
|
|
61
|
-
To learn more about these `visit` configuration options please refer to [@speclynx/apidom-ast documentation](https://github.com/speclynx/apidom/blob/main/packages/apidom-ast/README.md#visit).
|
|
60
|
+
Traversing ApiDOM in this namespace is possible by using `traverse` function from `@speclynx/apidom-traverse` package.
|
|
61
|
+
To learn more about the `traverse` function, please refer to [@speclynx/apidom-traverse documentation](https://github.com/speclynx/apidom/blob/main/packages/apidom-traverse/README.md).
|
|
62
62
|
|
|
63
63
|
```js
|
|
64
|
-
import {
|
|
65
|
-
import { JSONSchemaElement
|
|
64
|
+
import { traverse } from '@speclynx/apidom-traverse';
|
|
65
|
+
import { JSONSchemaElement } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
66
66
|
|
|
67
67
|
const element = new JSONSchemaElement();
|
|
68
68
|
|
|
69
69
|
const visitor = {
|
|
70
|
-
JSONSchemaDraft4Element(
|
|
71
|
-
console.dir(
|
|
70
|
+
JSONSchemaDraft4Element(path) {
|
|
71
|
+
console.dir(path.node);
|
|
72
72
|
},
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
traverse(element, visitor);
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
## Refractors
|
|
@@ -83,37 +83,37 @@ or generic ApiDOM structures into structures built from elements of this namespa
|
|
|
83
83
|
**Refracting JavaScript structures**:
|
|
84
84
|
|
|
85
85
|
```js
|
|
86
|
-
import {
|
|
86
|
+
import { refractMedia } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
87
87
|
|
|
88
88
|
const object = {
|
|
89
89
|
binaryEncoding: 'base64',
|
|
90
90
|
type: 'image/png',
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
refractMedia(object); // => MediaElement({ binaryEncoding, type })
|
|
94
94
|
```
|
|
95
95
|
|
|
96
96
|
**Refracting generic ApiDOM structures**:
|
|
97
97
|
|
|
98
98
|
```js
|
|
99
|
-
import { ObjectElement } from '@speclynx/apidom-
|
|
100
|
-
import {
|
|
99
|
+
import { ObjectElement } from '@speclynx/apidom-datamodel';
|
|
100
|
+
import { refractMedia } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
101
101
|
|
|
102
102
|
const objectElement = new ObjectElement({
|
|
103
103
|
binaryEncoding: 'base64',
|
|
104
104
|
type: 'image/png',
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
refractMedia(objectElement); // => MediaElement({ binaryEncoding = 'base64', type = 'image/png' })
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
### Refractor plugins
|
|
111
111
|
|
|
112
|
-
Refractors can accept plugins as a second argument of refract
|
|
112
|
+
Refractors can accept plugins as a second argument of refract function.
|
|
113
113
|
|
|
114
114
|
```js
|
|
115
|
-
import { ObjectElement } from '@speclynx/apidom-
|
|
116
|
-
import {
|
|
115
|
+
import { ObjectElement } from '@speclynx/apidom-datamodel';
|
|
116
|
+
import { refractMedia } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
117
117
|
|
|
118
118
|
const objectElement = new ObjectElement({
|
|
119
119
|
binaryEncoding: 'base64',
|
|
@@ -126,8 +126,8 @@ const plugin = ({ predicates, namespace }) => ({
|
|
|
126
126
|
console.dir('runs before traversal');
|
|
127
127
|
},
|
|
128
128
|
visitor: {
|
|
129
|
-
MediaElement(
|
|
130
|
-
|
|
129
|
+
MediaElement(path) {
|
|
130
|
+
path.node.type = 'image/gif';
|
|
131
131
|
},
|
|
132
132
|
},
|
|
133
133
|
post() {
|
|
@@ -135,7 +135,7 @@ const plugin = ({ predicates, namespace }) => ({
|
|
|
135
135
|
},
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
refractMedia(objectElement, { plugins: [plugin] }); // => MediaElement({ binaryEncoding = 'base64', type = 'image/gif' })
|
|
139
139
|
```
|
|
140
140
|
|
|
141
141
|
You can define as many plugins as needed to enhance the resulting namespaced ApiDOM structure.
|
|
@@ -149,14 +149,14 @@ this missing value with the most appropriate semantic element type.
|
|
|
149
149
|
|
|
150
150
|
```js
|
|
151
151
|
import { parse } from '@speclynx/apidom-parser-adapter-yaml-1-2';
|
|
152
|
-
import { refractorPluginReplaceEmptyElement,
|
|
152
|
+
import { refractorPluginReplaceEmptyElement, refractJSONSchema } from '@speclynx/apidom-ns-json-schema-draft-4';
|
|
153
153
|
|
|
154
154
|
const yamlDefinition = `
|
|
155
155
|
$schema: 'http://json-schema.org/draft-04/schema#'
|
|
156
156
|
additionalProperties:
|
|
157
157
|
`;
|
|
158
158
|
const apiDOM = await parse(yamlDefinition);
|
|
159
|
-
const jsonSchemaElement =
|
|
159
|
+
const jsonSchemaElement = refractJSONSchema(apiDOM.result, {
|
|
160
160
|
plugins: [refractorPluginReplaceEmptyElement()],
|
|
161
161
|
});
|
|
162
162
|
|