@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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
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
+ # [4.0.0](https://github.com/speclynx/apidom/compare/v3.2.1...v4.0.0) (2026-03-11)
7
+
8
+ ### Features
9
+
10
+ - **traverse:** all traverse operations work on Path and not Element ([#153](https://github.com/speclynx/apidom/issues/153)) ([67d244c](https://github.com/speclynx/apidom/commit/67d244cfd3e77f6a9db704cede50ba8e45d10b11))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ - **traverse:** This is a breaking change as operation callbacks
15
+ now accept Path instead of Element. By accepting Path, full
16
+ context of traversal is exposed to consumer instead of just Element.
17
+
18
+ ## [3.2.1](https://github.com/speclynx/apidom/compare/v3.2.0...v3.2.1) (2026-03-09)
19
+
20
+ **Note:** Version bump only for package @speclynx/apidom-ns-json-schema-draft-7
21
+
6
22
  # [3.2.0](https://github.com/speclynx/apidom/compare/v3.1.0...v3.2.0) (2026-03-08)
7
23
 
8
24
  ### Features
@@ -22525,7 +22525,9 @@ class Path {
22525
22525
  *
22526
22526
  * @example
22527
22527
  * // For a path to $.paths['/pets'].get in an OpenAPI document:
22528
+ * ```
22528
22529
  * path.getPathKeys(); // => ['paths', '/pets', 'get']
22530
+ * ```
22529
22531
  */
22530
22532
  getPathKeys() {
22531
22533
  const keys = [];
@@ -22560,18 +22562,22 @@ class Path {
22560
22562
  * or Normalized JSONPath like "$['paths']['/pets']['get']['responses']['200']"
22561
22563
  *
22562
22564
  * @example
22565
+ * ```
22563
22566
  * // JSON Pointer examples:
22564
22567
  * path.formatPath(); // "" (root)
22565
22568
  * path.formatPath(); // "/info"
22566
22569
  * path.formatPath(); // "/paths/~1pets/get"
22567
22570
  * path.formatPath(); // "/paths/~1users~1{id}/parameters/0"
22571
+ * ```
22568
22572
  *
22569
22573
  * @example
22574
+ * ```
22570
22575
  * // JSONPath examples:
22571
22576
  * path.formatPath('jsonpath'); // "$" (root)
22572
22577
  * path.formatPath('jsonpath'); // "$['info']"
22573
22578
  * path.formatPath('jsonpath'); // "$['paths']['/pets']['get']"
22574
22579
  * path.formatPath('jsonpath'); // "$['paths']['/users/{id}']['parameters'][0]"
22580
+ * ```
22575
22581
  */
22576
22582
  formatPath(pathFormat = 'jsonpointer') {
22577
22583
  const parts = this.getPathKeys();
@@ -22779,15 +22785,15 @@ __webpack_require__.r(__webpack_exports__);
22779
22785
  /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2078);
22780
22786
 
22781
22787
  /**
22782
- * Finds all elements matching the predicate.
22788
+ * Finds all paths whose elements match the predicate.
22783
22789
  * @public
22784
22790
  */
22785
22791
  const filter = (element, predicate) => {
22786
22792
  const result = [];
22787
22793
  (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
22788
22794
  enter(path) {
22789
- if (predicate(path.node)) {
22790
- result.push(path.node);
22795
+ if (predicate(path)) {
22796
+ result.push(path);
22791
22797
  }
22792
22798
  }
22793
22799
  });
@@ -22812,7 +22818,7 @@ __webpack_require__.r(__webpack_exports__);
22812
22818
  * @public
22813
22819
  */
22814
22820
  /**
22815
- * Finds the most inner node at the given offset.
22821
+ * Finds the path of the most inner node at the given offset.
22816
22822
  * If includeRightBound is set, also finds nodes that end at the given offset.
22817
22823
  * @public
22818
22824
  */
@@ -22837,7 +22843,7 @@ const findAtOffset = (element, options) => {
22837
22843
  const endOffset = node.endOffset;
22838
22844
  const isWithinOffsetRange = offset >= startOffset && (offset < endOffset || includeRightBound && offset <= endOffset);
22839
22845
  if (isWithinOffsetRange) {
22840
- result.push(node);
22846
+ result.push(path);
22841
22847
  return; // push to stack and dive in
22842
22848
  }
22843
22849
  path.skip(); // skip entire sub-tree
@@ -22859,15 +22865,15 @@ __webpack_require__.r(__webpack_exports__);
22859
22865
  /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2078);
22860
22866
 
22861
22867
  /**
22862
- * Find first element that satisfies the provided predicate.
22868
+ * Finds first path whose element satisfies the provided predicate.
22863
22869
  * @public
22864
22870
  */
22865
22871
  const find = (element, predicate) => {
22866
22872
  let result;
22867
22873
  (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
22868
22874
  enter(path) {
22869
- if (predicate(path.node)) {
22870
- result = path.node;
22875
+ if (predicate(path)) {
22876
+ result = path;
22871
22877
  path.stop();
22872
22878
  }
22873
22879
  }
@@ -22885,9 +22891,7 @@ __webpack_require__.r(__webpack_exports__);
22885
22891
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
22886
22892
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
22887
22893
  /* harmony export */ });
22888
- /* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5162);
22889
- /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2078);
22890
-
22894
+ /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2078);
22891
22895
 
22892
22896
  /**
22893
22897
  * @public
@@ -22896,7 +22900,7 @@ __webpack_require__.r(__webpack_exports__);
22896
22900
  * @public
22897
22901
  */
22898
22902
  /**
22899
- * Executes the callback on this element and all descendants.
22903
+ * Executes the callback on this element's path and all descendant paths.
22900
22904
  * @public
22901
22905
  */
22902
22906
  const forEach = (element, options) => {
@@ -22904,15 +22908,15 @@ const forEach = (element, options) => {
22904
22908
  let predicate;
22905
22909
  if (typeof options === 'function') {
22906
22910
  callback = options;
22907
- predicate = _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isElement;
22911
+ predicate = () => true;
22908
22912
  } else {
22909
22913
  callback = options.callback ?? (() => {});
22910
- predicate = options.predicate ?? _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isElement;
22914
+ predicate = options.predicate ?? (() => true);
22911
22915
  }
22912
- (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_1__.traverse)(element, {
22916
+ (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
22913
22917
  enter(path) {
22914
- if (predicate(path.node)) {
22915
- callback(path.node);
22918
+ if (predicate(path)) {
22919
+ callback(path);
22916
22920
  }
22917
22921
  }
22918
22922
  });
@@ -22959,11 +22963,11 @@ __webpack_require__.r(__webpack_exports__);
22959
22963
  /* harmony import */ var _filter_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5247);
22960
22964
 
22961
22965
  /**
22962
- * Complement of filter. Finds all elements NOT matching the predicate.
22966
+ * Complement of filter. Finds all paths whose elements do NOT match the predicate.
22963
22967
  * @public
22964
22968
  */
22965
22969
  const reject = (element, predicate) => {
22966
- return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element, el => !predicate(el));
22970
+ return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element, path => !predicate(path));
22967
22971
  };
22968
22972
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (reject);
22969
22973
 
@@ -22979,7 +22983,7 @@ __webpack_require__.r(__webpack_exports__);
22979
22983
  /* harmony import */ var _find_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4860);
22980
22984
 
22981
22985
  /**
22982
- * Tests whether at least one element passes the predicate.
22986
+ * Tests whether at least one path's element passes the predicate.
22983
22987
  * @public
22984
22988
  */
22985
22989
  const some = (element, predicate) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speclynx/apidom-ns-json-schema-draft-7",
3
- "version": "3.2.0",
3
+ "version": "4.0.0",
4
4
  "description": "JSON Schema Draft 7 namespace for ApiDOM.",
5
5
  "keywords": [
6
6
  "apidom",
@@ -57,11 +57,11 @@
57
57
  "license": "Apache-2.0",
58
58
  "dependencies": {
59
59
  "@babel/runtime-corejs3": "^7.28.4",
60
- "@speclynx/apidom-core": "3.2.0",
61
- "@speclynx/apidom-datamodel": "3.2.0",
62
- "@speclynx/apidom-error": "3.2.0",
63
- "@speclynx/apidom-ns-json-schema-draft-6": "3.2.0",
64
- "@speclynx/apidom-traverse": "3.2.0",
60
+ "@speclynx/apidom-core": "4.0.0",
61
+ "@speclynx/apidom-datamodel": "4.0.0",
62
+ "@speclynx/apidom-error": "4.0.0",
63
+ "@speclynx/apidom-ns-json-schema-draft-6": "4.0.0",
64
+ "@speclynx/apidom-traverse": "4.0.0",
65
65
  "ramda": "~0.32.0",
66
66
  "ramda-adjunct": "^6.0.0",
67
67
  "ts-mixer": "^6.0.4"
@@ -76,5 +76,5 @@
76
76
  "README.md",
77
77
  "CHANGELOG.md"
78
78
  ],
79
- "gitHead": "eeb2f01cd34fb0a95617f02bc1b6683aefc028f2"
79
+ "gitHead": "384ff82a1bb68d015fd6801de641898b4b582876"
80
80
  }
@@ -1,122 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _apidomError = require("@speclynx/apidom-error");
6
- var _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-6");
7
- /**
8
- * @public
9
- */
10
- class JSONSchema extends _apidomNsJsonSchemaDraft.JSONSchemaElement {
11
- constructor(content, meta, attributes) {
12
- super(content, meta, attributes);
13
- this.element = 'JSONSchemaDraft7';
14
- }
15
-
16
- /**
17
- * Core vocabulary
18
- *
19
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-01
20
- */
21
-
22
- get $comment() {
23
- return this.get('$comment');
24
- }
25
- set $comment($comment) {
26
- this.set('$comment', $comment);
27
- }
28
-
29
- /**
30
- * Validation vocabulary
31
- *
32
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01
33
- */
34
-
35
- /**
36
- * Validation keywords for arrays
37
- */
38
-
39
- get itemsField() {
40
- return this.get('items');
41
- }
42
- set itemsField(items) {
43
- this.set('items', items);
44
- }
45
-
46
- /**
47
- * Keywords for Applying Subschemas Conditionally
48
- *
49
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-6.6
50
- */
51
-
52
- get if() {
53
- return this.get('if');
54
- }
55
- set if(ifValue) {
56
- this.set('if', ifValue);
57
- }
58
- get then() {
59
- return this.get('then');
60
- }
61
- set then(then) {
62
- this.set('then', then);
63
- }
64
- get else() {
65
- return this.get('else');
66
- }
67
- set else(elseValue) {
68
- this.set('else', elseValue);
69
- }
70
-
71
- /**
72
- * Keywords for Applying Subschemas With Boolean Logic
73
- *
74
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-6.7
75
- */
76
-
77
- get not() {
78
- return this.get('not');
79
- }
80
- set not(not) {
81
- this.set('not', not);
82
- }
83
-
84
- /**
85
- * String-Encoding Non-JSON Data
86
- *
87
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-00#section-8
88
- */
89
-
90
- get contentEncoding() {
91
- return this.get('contentEncoding');
92
- }
93
- set contentEncoding(contentEncoding) {
94
- this.set('contentEncoding', contentEncoding);
95
- }
96
- get contentMediaType() {
97
- return this.get('contentMediaType');
98
- }
99
- set contentMediaType(contentMediaType) {
100
- this.set('contentMediaType', contentMediaType);
101
- }
102
- get media() {
103
- throw new _apidomError.UnsupportedOperationError('media keyword from Hyper-Schema vocabulary has been moved to validation vocabulary as "contentMediaType" / "contentEncoding"');
104
- }
105
- set media(_media) {
106
- throw new _apidomError.UnsupportedOperationError('media keyword from Hyper-Schema vocabulary has been moved to validation vocabulary as "contentMediaType" / "contentEncoding"');
107
- }
108
-
109
- /**
110
- * Schema annotations
111
- *
112
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10
113
- */
114
-
115
- get writeOnly() {
116
- return this.get('writeOnly');
117
- }
118
- set writeOnly(writeOnly) {
119
- this.set('writeOnly', writeOnly);
120
- }
121
- }
122
- var _default = exports.default = JSONSchema;
@@ -1,119 +0,0 @@
1
- import { UnsupportedOperationError } from '@speclynx/apidom-error';
2
- import { JSONSchemaElement } from '@speclynx/apidom-ns-json-schema-draft-6';
3
-
4
- /**
5
- * @public
6
- */
7
- class JSONSchema extends JSONSchemaElement {
8
- constructor(content, meta, attributes) {
9
- super(content, meta, attributes);
10
- this.element = 'JSONSchemaDraft7';
11
- }
12
-
13
- /**
14
- * Core vocabulary
15
- *
16
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-01
17
- */
18
-
19
- get $comment() {
20
- return this.get('$comment');
21
- }
22
- set $comment($comment) {
23
- this.set('$comment', $comment);
24
- }
25
-
26
- /**
27
- * Validation vocabulary
28
- *
29
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01
30
- */
31
-
32
- /**
33
- * Validation keywords for arrays
34
- */
35
-
36
- get itemsField() {
37
- return this.get('items');
38
- }
39
- set itemsField(items) {
40
- this.set('items', items);
41
- }
42
-
43
- /**
44
- * Keywords for Applying Subschemas Conditionally
45
- *
46
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-6.6
47
- */
48
-
49
- get if() {
50
- return this.get('if');
51
- }
52
- set if(ifValue) {
53
- this.set('if', ifValue);
54
- }
55
- get then() {
56
- return this.get('then');
57
- }
58
- set then(then) {
59
- this.set('then', then);
60
- }
61
- get else() {
62
- return this.get('else');
63
- }
64
- set else(elseValue) {
65
- this.set('else', elseValue);
66
- }
67
-
68
- /**
69
- * Keywords for Applying Subschemas With Boolean Logic
70
- *
71
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-6.7
72
- */
73
-
74
- get not() {
75
- return this.get('not');
76
- }
77
- set not(not) {
78
- this.set('not', not);
79
- }
80
-
81
- /**
82
- * String-Encoding Non-JSON Data
83
- *
84
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-00#section-8
85
- */
86
-
87
- get contentEncoding() {
88
- return this.get('contentEncoding');
89
- }
90
- set contentEncoding(contentEncoding) {
91
- this.set('contentEncoding', contentEncoding);
92
- }
93
- get contentMediaType() {
94
- return this.get('contentMediaType');
95
- }
96
- set contentMediaType(contentMediaType) {
97
- this.set('contentMediaType', contentMediaType);
98
- }
99
- get media() {
100
- throw new UnsupportedOperationError('media keyword from Hyper-Schema vocabulary has been moved to validation vocabulary as "contentMediaType" / "contentEncoding"');
101
- }
102
- set media(_media) {
103
- throw new UnsupportedOperationError('media keyword from Hyper-Schema vocabulary has been moved to validation vocabulary as "contentMediaType" / "contentEncoding"');
104
- }
105
-
106
- /**
107
- * Schema annotations
108
- *
109
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10
110
- */
111
-
112
- get writeOnly() {
113
- return this.get('writeOnly');
114
- }
115
- set writeOnly(writeOnly) {
116
- this.set('writeOnly', writeOnly);
117
- }
118
- }
119
- export default JSONSchema;
@@ -1,138 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _apidomError = require("@speclynx/apidom-error");
6
- var _apidomNsJsonSchemaDraft = require("@speclynx/apidom-ns-json-schema-draft-6");
7
- /**
8
- * URI: https://datatracker.ietf.org/doc/html/draft-wright-json-schema-hyperschema-01#section-6
9
- * @public
10
- */
11
-
12
- class LinkDescription extends _apidomNsJsonSchemaDraft.LinkDescriptionElement {
13
- /**
14
- * Link context.
15
- *
16
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-01#section-6.1
17
- */
18
-
19
- get anchor() {
20
- return this.get('anchor');
21
- }
22
- set anchor(anchor) {
23
- this.set('anchor', anchor);
24
- }
25
- get anchorPointer() {
26
- return this.get('anchorPointer');
27
- }
28
- set anchorPointer(anchorPointer) {
29
- this.set('anchorPointer', anchorPointer);
30
- }
31
-
32
- /**
33
- * Adjusting URI Template Resolution.
34
- *
35
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-01#section-6.4
36
- */
37
-
38
- get templatePointers() {
39
- return this.get('templatePointers');
40
- }
41
- set templatePointers(templatePointers) {
42
- this.set('templatePointers', templatePointers);
43
- }
44
- get templateRequired() {
45
- return this.get('templateRequired');
46
- }
47
- set templateRequired(templateRequired) {
48
- this.set('templateRequired', templateRequired);
49
- }
50
-
51
- /**
52
- * Link Target Attributes.
53
- *
54
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-01#section-6.5
55
- */
56
-
57
- get targetSchema() {
58
- return this.get('targetSchema');
59
- }
60
- set targetSchema(targetSchema) {
61
- this.set('targetSchema', targetSchema);
62
- }
63
- get mediaType() {
64
- throw new _apidomError.UnsupportedOperationError('mediaType keyword from Hyper-Schema vocabulary has been renamed to targetMediaType.');
65
- }
66
- set mediaType(mediaType) {
67
- throw new _apidomError.UnsupportedOperationError('mediaType keyword from Hyper-Schema vocabulary has been renamed to targetMediaType.');
68
- }
69
- get targetMediaType() {
70
- return this.get('targetMediaType');
71
- }
72
- set targetMediaType(targetMediaType) {
73
- this.set('targetMediaType', targetMediaType);
74
- }
75
- get targetHints() {
76
- return this.get('targetHints');
77
- }
78
- set targetHints(targetHints) {
79
- this.set('targetHints', targetHints);
80
- }
81
- get description() {
82
- return this.get('description');
83
- }
84
- set description(description) {
85
- this.set('description', description);
86
- }
87
- get $comment() {
88
- return this.get('$comment');
89
- }
90
- set $comment($comment) {
91
- this.set('$comment', $comment);
92
- }
93
-
94
- /**
95
- * Link Input.
96
- *
97
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-01#section-6.6
98
- */
99
-
100
- get hrefSchema() {
101
- return this.get('hrefSchema');
102
- }
103
- set hrefSchema(hrefSchema) {
104
- this.set('hrefSchema', hrefSchema);
105
- }
106
- get headerSchema() {
107
- return this.get('headerSchema');
108
- }
109
- set headerSchema(headerSchema) {
110
- this.set('headerSchema', headerSchema);
111
- }
112
-
113
- /**
114
- * Submitting Data for Processing.
115
- *
116
- * URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-01#section-6.6.4
117
- */
118
-
119
- get submissionSchema() {
120
- return this.get('submissionSchema');
121
- }
122
- set submissionSchema(submissionSchema) {
123
- this.set('submissionSchema', submissionSchema);
124
- }
125
- get submissionEncType() {
126
- throw new _apidomError.UnsupportedOperationError('submissionEncType keyword from Hyper-Schema vocabulary has been renamed to submissionMediaType.');
127
- }
128
- set submissionEncType(submissionEncType) {
129
- throw new _apidomError.UnsupportedOperationError('submissionEncType keyword from Hyper-Schema vocabulary has been renamed to submissionMediaType.');
130
- }
131
- get submissionMediaType() {
132
- return this.get('submissionMediaType');
133
- }
134
- set submissionMediaType(submissionMediaType) {
135
- this.set('submissionMediaType', submissionMediaType);
136
- }
137
- }
138
- var _default = exports.default = LinkDescription;