@speclynx/apidom-ns-json-schema-draft-6 1.12.2 → 2.1.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.
- package/CHANGELOG.md +25 -0
- package/NOTICE +16 -7
- package/README.md +24 -24
- package/dist/apidom-ns-json-schema-draft-6.browser.js +1 -1
- package/package.json +11 -9
- package/src/elements/JSONSchema.cjs +14 -6
- package/src/elements/JSONSchema.mjs +14 -6
- package/src/elements/LinkDescription.cjs +4 -0
- package/src/elements/LinkDescription.mjs +4 -0
- package/src/index.cjs +8 -21
- package/src/index.mjs +2 -5
- package/src/predicates.cjs +4 -15
- package/src/predicates.mjs +2 -15
- package/src/refractor/index.cjs +38 -17
- package/src/refractor/index.mjs +33 -15
- package/src/refractor/inspect.cjs +47 -0
- package/src/refractor/inspect.mjs +39 -0
- package/src/refractor/plugins/replace-empty-element.cjs +28 -26
- package/src/refractor/plugins/replace-empty-element.mjs +14 -11
- package/src/refractor/specification.cjs +14 -2
- package/src/refractor/specification.mjs +14 -2
- package/src/refractor/toolbox.cjs +8 -3
- package/src/refractor/toolbox.mjs +6 -2
- package/src/refractor/visitors/json-schema/ExamplesVisitor.cjs +2 -3
- package/src/refractor/visitors/json-schema/ExamplesVisitor.mjs +2 -3
- package/src/refractor/visitors/json-schema/ItemsVisitor.cjs +3 -4
- package/src/refractor/visitors/json-schema/ItemsVisitor.mjs +3 -4
- package/src/refractor/visitors/json-schema/index.cjs +4 -3
- package/src/refractor/visitors/json-schema/index.mjs +4 -3
- package/src/refractor/visitors/json-schema/link-description/index.cjs +2 -0
- package/src/refractor/visitors/json-schema/link-description/index.mjs +2 -0
- package/types/apidom-ns-json-schema-draft-6.d.ts +90 -245
- package/src/refractor/registration.cjs +0 -13
- package/src/refractor/registration.mjs +0 -6
- package/src/traversal/visitor.cjs +0 -17
- package/src/traversal/visitor.mjs +0 -13
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.1.0](https://github.com/speclynx/apidom/compare/v2.0.1...v2.1.0) (2026-01-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @speclynx/apidom-ns-json-schema-draft-6
|
|
9
|
+
|
|
10
|
+
## [2.0.1](https://github.com/speclynx/apidom/compare/v2.0.0...v2.0.1) (2026-01-14)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @speclynx/apidom-ns-json-schema-draft-6
|
|
13
|
+
|
|
14
|
+
# [2.0.0](https://github.com/speclynx/apidom/compare/v1.12.2...v2.0.0) (2026-01-14)
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
- limit source maps memory consuption ([#20](https://github.com/speclynx/apidom/issues/20)) ([4a0574f](https://github.com/speclynx/apidom/commit/4a0574fd6d466be7c33c8a5871baacd384918d22))
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
- apply innovations learned during last 3 years ([#11](https://github.com/speclynx/apidom/issues/11)) ([cfdbbfc](https://github.com/speclynx/apidom/commit/cfdbbfc2721b0dadc77eeba31dd4e8768c078d22))
|
|
23
|
+
- **traverse:** move traverse operations to apidom-traverse package ([#18](https://github.com/speclynx/apidom/issues/18)) ([36c9d49](https://github.com/speclynx/apidom/commit/36c9d490ceac2ea961e2b23fbbc72df7fb54bbf3))
|
|
24
|
+
|
|
25
|
+
### BREAKING CHANGES
|
|
26
|
+
|
|
27
|
+
- source maps have been completely rewritten
|
|
28
|
+
- **traverse:** move traverse operations from core to traverse package
|
|
29
|
+
- breaking changes introduced to every package public API
|
|
30
|
+
|
|
6
31
|
## [1.12.2](https://github.com/speclynx/apidom/compare/v1.12.1...v1.12.2) (2025-12-23)
|
|
7
32
|
|
|
8
33
|
**Note:** Version bump only for package @speclynx/apidom-ns-json-schema-draft-6
|
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,13 +13,14 @@ You can install this package via [npm CLI](https://docs.npmjs.com/cli) by runnin
|
|
|
13
13
|
## JSON Schema Draft 6 namespace
|
|
14
14
|
|
|
15
15
|
JSON Schema Draft 6 namespace consists of [number of elements](https://github.com/speclynx/apidom/tree/main/packages/apidom-ns-json-schema-draft-6/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 {
|
|
19
|
+
import { Namespace } from '@speclynx/apidom-datamodel';
|
|
20
20
|
import jsonShemaDraft6Namespace from '@speclynx/apidom-ns-json-schema-draft-6';
|
|
21
21
|
|
|
22
|
-
const namespace =
|
|
22
|
+
const namespace = new Namespace();
|
|
23
|
+
namespace.use(jsonShemaDraft6Namespace);
|
|
23
24
|
|
|
24
25
|
const objectElement = new namespace.elements.Object();
|
|
25
26
|
const jsonSchemaElement = new namespace.elements.JSONSchemaDraft6();
|
|
@@ -54,23 +55,22 @@ isJSONSchemaElement(jsonSchemaElement); // => true
|
|
|
54
55
|
|
|
55
56
|
## Traversal
|
|
56
57
|
|
|
57
|
-
Traversing ApiDOM in this namespace is possible by using `
|
|
58
|
-
|
|
59
|
-
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).
|
|
58
|
+
Traversing ApiDOM in this namespace is possible by using `traverse` function from `@speclynx/apidom-traverse` package.
|
|
59
|
+
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).
|
|
60
60
|
|
|
61
61
|
```js
|
|
62
|
-
import {
|
|
63
|
-
import { JSONSchemaElement
|
|
62
|
+
import { traverse } from '@speclynx/apidom-traverse';
|
|
63
|
+
import { JSONSchemaElement } from '@speclynx/apidom-ns-json-schema-draft-6';
|
|
64
64
|
|
|
65
65
|
const element = new JSONSchemaElement();
|
|
66
66
|
|
|
67
67
|
const visitor = {
|
|
68
|
-
JSONSchemaDraft6Element(
|
|
69
|
-
console.dir(
|
|
68
|
+
JSONSchemaDraft6Element(path) {
|
|
69
|
+
console.dir(path.node);
|
|
70
70
|
},
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
traverse(element, visitor);
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
## Refractors
|
|
@@ -81,37 +81,37 @@ or generic ApiDOM structures into structures built from elements of this namespa
|
|
|
81
81
|
**Refracting JavaScript structures**:
|
|
82
82
|
|
|
83
83
|
```js
|
|
84
|
-
import {
|
|
84
|
+
import { refractMedia } from '@speclynx/apidom-ns-json-schema-draft-6';
|
|
85
85
|
|
|
86
86
|
const object = {
|
|
87
87
|
binaryEncoding: 'base64',
|
|
88
88
|
type: 'image/png',
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
refractMedia(object); // => MediaElement({ binaryEncoding, type })
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
**Refracting generic ApiDOM structures**:
|
|
95
95
|
|
|
96
96
|
```js
|
|
97
|
-
import { ObjectElement } from '@speclynx/apidom-
|
|
98
|
-
import {
|
|
97
|
+
import { ObjectElement } from '@speclynx/apidom-datamodel';
|
|
98
|
+
import { refractMedia } from '@speclynx/apidom-ns-json-schema-draft-6';
|
|
99
99
|
|
|
100
100
|
const objectElement = new ObjectElement({
|
|
101
101
|
binaryEncoding: 'base64',
|
|
102
102
|
type: 'image/png',
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
refractMedia(objectElement); // => MediaElement({ binaryEncoding = 'base64', type = 'image/png' })
|
|
106
106
|
```
|
|
107
107
|
|
|
108
108
|
### Refractor plugins
|
|
109
109
|
|
|
110
|
-
Refractors can accept plugins as a second argument of refract
|
|
110
|
+
Refractors can accept plugins as a second argument of refract function.
|
|
111
111
|
|
|
112
112
|
```js
|
|
113
|
-
import { ObjectElement } from '@speclynx/apidom-
|
|
114
|
-
import {
|
|
113
|
+
import { ObjectElement } from '@speclynx/apidom-datamodel';
|
|
114
|
+
import { refractMedia } from '@speclynx/apidom-ns-json-schema-draft-6';
|
|
115
115
|
|
|
116
116
|
const objectElement = new ObjectElement({
|
|
117
117
|
binaryEncoding: 'base64',
|
|
@@ -124,8 +124,8 @@ const plugin = ({ predicates, namespace }) => ({
|
|
|
124
124
|
console.dir('runs before traversal');
|
|
125
125
|
},
|
|
126
126
|
visitor: {
|
|
127
|
-
MediaElement(
|
|
128
|
-
|
|
127
|
+
MediaElement(path) {
|
|
128
|
+
path.node.type = 'image/gif';
|
|
129
129
|
},
|
|
130
130
|
},
|
|
131
131
|
post() {
|
|
@@ -133,7 +133,7 @@ const plugin = ({ predicates, namespace }) => ({
|
|
|
133
133
|
},
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
refractMedia(objectElement, { plugins: [plugin] }); // => MediaElement({ binaryEncoding = 'base64', type = 'image/gif' })
|
|
137
137
|
```
|
|
138
138
|
|
|
139
139
|
You can define as many plugins as needed to enhance the resulting namespaced ApiDOM structure.
|
|
@@ -147,14 +147,14 @@ this missing value with the most appropriate semantic element type.
|
|
|
147
147
|
|
|
148
148
|
```js
|
|
149
149
|
import { parse } from '@speclynx/apidom-parser-adapter-yaml-1-2';
|
|
150
|
-
import { refractorPluginReplaceEmptyElement,
|
|
150
|
+
import { refractorPluginReplaceEmptyElement, refractJSONSchema } from '@speclynx/apidom-ns-json-schema-draft-6';
|
|
151
151
|
|
|
152
152
|
const yamlDefinition = `
|
|
153
153
|
$schema: 'https://json-schema.org/draft-06/schema#'
|
|
154
154
|
additionalProperties:
|
|
155
155
|
`;
|
|
156
156
|
const apiDOM = await parse(yamlDefinition);
|
|
157
|
-
const jsonSchemaElement =
|
|
157
|
+
const jsonSchemaElement = refractJSONSchema(apiDOM.result, {
|
|
158
158
|
plugins: [refractorPluginReplaceEmptyElement()],
|
|
159
159
|
});
|
|
160
160
|
|