@speclynx/apidom-ns-json-schema-2020-12 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 +25 -27
- package/dist/apidom-ns-json-schema-2020-12.browser.js +1 -1
- package/package.json +10 -9
- package/src/elements/JSONSchema.mjs +0 -1
- package/src/index.cjs +8 -16
- package/src/index.mjs +3 -3
- package/src/predicates.cjs +4 -15
- package/src/predicates.mjs +2 -15
- package/src/refractor/index.cjs +38 -18
- package/src/refractor/index.mjs +33 -16
- package/src/refractor/inspect.cjs +43 -0
- package/src/refractor/inspect.mjs +37 -0
- package/src/refractor/plugins/replace-empty-element.cjs +35 -29
- package/src/refractor/plugins/replace-empty-element.mjs +14 -8
- package/src/refractor/specification.cjs +2 -2
- package/src/refractor/specification.mjs +2 -2
- package/src/refractor/toolbox.cjs +8 -3
- package/src/refractor/toolbox.mjs +6 -2
- package/src/refractor/visitors/json-schema/PrefixItemsVisitor.cjs +6 -6
- package/src/refractor/visitors/json-schema/PrefixItemsVisitor.mjs +6 -6
- package/types/apidom-ns-json-schema-2020-12.d.ts +81 -221
- package/src/refractor/registration.cjs +0 -13
- package/src/refractor/registration.mjs +0 -6
- package/src/traversal/visitor.cjs +0 -15
- package/src/traversal/visitor.mjs +0 -10
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-2020-12
|
|
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-2020-12
|
|
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-2020-12
|
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
|
@@ -13,20 +13,20 @@ You can install this package via [npm CLI](https://docs.npmjs.com/cli) by runnin
|
|
|
13
13
|
## JSON Schema 2020-12 namespace
|
|
14
14
|
|
|
15
15
|
JSON Schema 2020-12 namespace consists of [number of elements](https://github.com/speclynx/apidom/tree/main/packages/apidom-ns-json-schema-2020-12/src/elements) implemented on top
|
|
16
|
-
of [primitive ones](https://github.com/
|
|
16
|
+
of [primitive ones](https://github.com/speclynx/apidom/tree/main/packages/apidom-datamodel/src/primitives).
|
|
17
17
|
|
|
18
18
|
```js
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
19
|
+
import { Namespace } from '@speclynx/apidom-datamodel';
|
|
20
|
+
import jsonSchema202012Namespace from '@speclynx/apidom-ns-json-schema-2020-12';
|
|
21
21
|
|
|
22
|
-
const namespace =
|
|
22
|
+
const namespace = new Namespace().use(jsonSchema202012Namespace);
|
|
23
23
|
|
|
24
24
|
const objectElement = new namespace.elements.Object();
|
|
25
25
|
const jsonSchemaElement = new namespace.elements.JSONSchema202012();
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
When namespace instance is created in this way, it will extend the base namespace
|
|
29
|
-
with the namespace provided as an argument.
|
|
29
|
+
with the namespace plugin provided as an argument.
|
|
30
30
|
|
|
31
31
|
Elements from the namespace can also be used directly by importing them.
|
|
32
32
|
|
|
@@ -52,23 +52,22 @@ isJSONSchemaElement(jsonSchemaElement); // => true
|
|
|
52
52
|
|
|
53
53
|
## Traversal
|
|
54
54
|
|
|
55
|
-
Traversing ApiDOM in this namespace is possible by using `
|
|
56
|
-
|
|
57
|
-
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).
|
|
55
|
+
Traversing ApiDOM in this namespace is possible by using `traverse` function from `@speclynx/apidom-traverse` package.
|
|
56
|
+
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).
|
|
58
57
|
|
|
59
58
|
```js
|
|
60
|
-
import {
|
|
61
|
-
import { JSONSchemaElement
|
|
59
|
+
import { traverse } from '@speclynx/apidom-traverse';
|
|
60
|
+
import { JSONSchemaElement } from '@speclynx/apidom-ns-json-schema-2020-12';
|
|
62
61
|
|
|
63
62
|
const element = new JSONSchemaElement();
|
|
64
63
|
|
|
65
64
|
const visitor = {
|
|
66
|
-
JSONSchema202012Element(
|
|
67
|
-
console.dir(
|
|
65
|
+
JSONSchema202012Element(path) {
|
|
66
|
+
console.dir(path.node);
|
|
68
67
|
},
|
|
69
68
|
};
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
traverse(element, visitor);
|
|
72
71
|
```
|
|
73
72
|
|
|
74
73
|
## Refractors
|
|
@@ -79,37 +78,37 @@ or generic ApiDOM structures into structures built from elements of this namespa
|
|
|
79
78
|
**Refracting JavaScript structures**:
|
|
80
79
|
|
|
81
80
|
```js
|
|
82
|
-
import {
|
|
81
|
+
import { refractLinkDescription } from '@speclynx/apidom-ns-json-schema-2020-12';
|
|
83
82
|
|
|
84
83
|
const object = {
|
|
85
84
|
anchor: 'nodes/{thisNodeId}',
|
|
86
85
|
anchorPointer: '#/relative/json/pointer',
|
|
87
86
|
};
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
refractLinkDescription(object); // => LinkDescriptionElement({ anchor, anchorPointer })
|
|
90
89
|
```
|
|
91
90
|
|
|
92
91
|
**Refracting generic ApiDOM structures**:
|
|
93
92
|
|
|
94
93
|
```js
|
|
95
|
-
import { ObjectElement } from '@speclynx/apidom-
|
|
96
|
-
import {
|
|
94
|
+
import { ObjectElement } from '@speclynx/apidom-datamodel';
|
|
95
|
+
import { refractLinkDescription } from '@speclynx/apidom-ns-json-schema-2020-12';
|
|
97
96
|
|
|
98
97
|
const objectElement = new ObjectElement({
|
|
99
98
|
anchor: 'nodes/{thisNodeId}',
|
|
100
99
|
anchorPointer: '#/relative/json/pointer',
|
|
101
100
|
});
|
|
102
101
|
|
|
103
|
-
|
|
102
|
+
refractLinkDescription(objectElement); // => LinkDescriptionElement({ anchor = 'nodes/{thisNodeId}', anchorPointer = '#/relative/json/pointer' })
|
|
104
103
|
```
|
|
105
104
|
|
|
106
105
|
### Refractor plugins
|
|
107
106
|
|
|
108
|
-
Refractors can accept plugins as a second argument of refract
|
|
107
|
+
Refractors can accept plugins as a second argument of the refract function.
|
|
109
108
|
|
|
110
109
|
```js
|
|
111
|
-
import { ObjectElement } from '@speclynx/apidom-
|
|
112
|
-
import {
|
|
110
|
+
import { ObjectElement } from '@speclynx/apidom-datamodel';
|
|
111
|
+
import { refractLinkDescription } from '@speclynx/apidom-ns-json-schema-2020-12';
|
|
113
112
|
|
|
114
113
|
const objectElement = new ObjectElement({
|
|
115
114
|
anchor: 'nodes/{thisNodeId}',
|
|
@@ -122,8 +121,8 @@ const plugin = ({ predicates, namespace }) => ({
|
|
|
122
121
|
console.dir('runs before traversal');
|
|
123
122
|
},
|
|
124
123
|
visitor: {
|
|
125
|
-
LinkDescriptionElement(
|
|
126
|
-
|
|
124
|
+
LinkDescriptionElement(path) {
|
|
125
|
+
path.node.anchorPointer = '#/relative/json/pointer/x';
|
|
127
126
|
},
|
|
128
127
|
},
|
|
129
128
|
post() {
|
|
@@ -131,7 +130,7 @@ const plugin = ({ predicates, namespace }) => ({
|
|
|
131
130
|
},
|
|
132
131
|
});
|
|
133
132
|
|
|
134
|
-
|
|
133
|
+
refractLinkDescription(objectElement, { plugins: [plugin] }); // => LinkDescriptionElement({ anchor = 'nodes/{thisNodeId}', anchorPointer = '#/relative/json/pointer/x' })
|
|
135
134
|
```
|
|
136
135
|
|
|
137
136
|
You can define as many plugins as needed to enhance the resulting namespaced ApiDOM structure.
|
|
@@ -145,14 +144,14 @@ this missing value with the most appropriate semantic element type.
|
|
|
145
144
|
|
|
146
145
|
```js
|
|
147
146
|
import { parse } from '@speclynx/apidom-parser-adapter-yaml-1-2';
|
|
148
|
-
import { refractorPluginReplaceEmptyElement,
|
|
147
|
+
import { refractorPluginReplaceEmptyElement, refractJSONSchema } from '@speclynx/apidom-ns-json-schema-2020-12';
|
|
149
148
|
|
|
150
149
|
const yamlDefinition = `
|
|
151
150
|
$schema: 'https://json-schema.org/draft/2020-12/schema'
|
|
152
151
|
if:
|
|
153
152
|
`;
|
|
154
153
|
const apiDOM = await parse(yamlDefinition);
|
|
155
|
-
const jsonSchemaElement =
|
|
154
|
+
const jsonSchemaElement = refractJSONSchema(apiDOM.result, {
|
|
156
155
|
plugins: [refractorPluginReplaceEmptyElement()],
|
|
157
156
|
});
|
|
158
157
|
|
|
@@ -183,4 +182,3 @@ Only fully implemented specification objects should be checked here.
|
|
|
183
182
|
- [x] [Link Description Object](https://json-schema.org/draft/2019-09/draft-handrews-json-schema-hyperschema-02#rfc.section.6)
|
|
184
183
|
|
|
185
184
|
|
|
186
|
-
|