@speclynx/apidom-parser-adapter-openapi-json-3-1 3.2.1 → 4.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 CHANGED
@@ -3,6 +3,14 @@
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.1](https://github.com/speclynx/apidom/compare/v4.0.0...v4.0.1) (2026-03-11)
7
+
8
+ **Note:** Version bump only for package @speclynx/apidom-parser-adapter-openapi-json-3-1
9
+
10
+ # [4.0.0](https://github.com/speclynx/apidom/compare/v3.2.1...v4.0.0) (2026-03-11)
11
+
12
+ **Note:** Version bump only for package @speclynx/apidom-parser-adapter-openapi-json-3-1
13
+
6
14
  ## [3.2.1](https://github.com/speclynx/apidom/compare/v3.2.0...v3.2.1) (2026-03-09)
7
15
 
8
16
  **Note:** Version bump only for package @speclynx/apidom-parser-adapter-openapi-json-3-1
@@ -39969,7 +39969,9 @@ class Path {
39969
39969
  *
39970
39970
  * @example
39971
39971
  * // For a path to $.paths['/pets'].get in an OpenAPI document:
39972
+ * ```
39972
39973
  * path.getPathKeys(); // => ['paths', '/pets', 'get']
39974
+ * ```
39973
39975
  */
39974
39976
  getPathKeys() {
39975
39977
  const keys = [];
@@ -40004,18 +40006,22 @@ class Path {
40004
40006
  * or Normalized JSONPath like "$['paths']['/pets']['get']['responses']['200']"
40005
40007
  *
40006
40008
  * @example
40009
+ * ```
40007
40010
  * // JSON Pointer examples:
40008
40011
  * path.formatPath(); // "" (root)
40009
40012
  * path.formatPath(); // "/info"
40010
40013
  * path.formatPath(); // "/paths/~1pets/get"
40011
40014
  * path.formatPath(); // "/paths/~1users~1{id}/parameters/0"
40015
+ * ```
40012
40016
  *
40013
40017
  * @example
40018
+ * ```
40014
40019
  * // JSONPath examples:
40015
40020
  * path.formatPath('jsonpath'); // "$" (root)
40016
40021
  * path.formatPath('jsonpath'); // "$['info']"
40017
40022
  * path.formatPath('jsonpath'); // "$['paths']['/pets']['get']"
40018
40023
  * path.formatPath('jsonpath'); // "$['paths']['/users/{id}']['parameters'][0]"
40024
+ * ```
40019
40025
  */
40020
40026
  formatPath(pathFormat = 'jsonpointer') {
40021
40027
  const parts = this.getPathKeys();
@@ -40225,15 +40231,15 @@ __webpack_require__.r(__webpack_exports__);
40225
40231
  /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72078);
40226
40232
 
40227
40233
  /**
40228
- * Finds all elements matching the predicate.
40234
+ * Finds all paths whose elements match the predicate.
40229
40235
  * @public
40230
40236
  */
40231
40237
  const filter = (element, predicate) => {
40232
40238
  const result = [];
40233
40239
  (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
40234
40240
  enter(path) {
40235
- if (predicate(path.node)) {
40236
- result.push(path.node);
40241
+ if (predicate(path)) {
40242
+ result.push(path);
40237
40243
  }
40238
40244
  }
40239
40245
  });
@@ -40259,7 +40265,7 @@ __webpack_require__.r(__webpack_exports__);
40259
40265
  * @public
40260
40266
  */
40261
40267
  /**
40262
- * Finds the most inner node at the given offset.
40268
+ * Finds the path of the most inner node at the given offset.
40263
40269
  * If includeRightBound is set, also finds nodes that end at the given offset.
40264
40270
  * @public
40265
40271
  */
@@ -40284,7 +40290,7 @@ const findAtOffset = (element, options) => {
40284
40290
  const endOffset = node.endOffset;
40285
40291
  const isWithinOffsetRange = offset >= startOffset && (offset < endOffset || includeRightBound && offset <= endOffset);
40286
40292
  if (isWithinOffsetRange) {
40287
- result.push(node);
40293
+ result.push(path);
40288
40294
  return; // push to stack and dive in
40289
40295
  }
40290
40296
  path.skip(); // skip entire sub-tree
@@ -40307,15 +40313,15 @@ __webpack_require__.r(__webpack_exports__);
40307
40313
  /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72078);
40308
40314
 
40309
40315
  /**
40310
- * Find first element that satisfies the provided predicate.
40316
+ * Finds first path whose element satisfies the provided predicate.
40311
40317
  * @public
40312
40318
  */
40313
40319
  const find = (element, predicate) => {
40314
40320
  let result;
40315
40321
  (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
40316
40322
  enter(path) {
40317
- if (predicate(path.node)) {
40318
- result = path.node;
40323
+ if (predicate(path)) {
40324
+ result = path;
40319
40325
  path.stop();
40320
40326
  }
40321
40327
  }
@@ -40334,9 +40340,7 @@ __webpack_require__.r(__webpack_exports__);
40334
40340
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
40335
40341
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
40336
40342
  /* harmony export */ });
40337
- /* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25162);
40338
- /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(72078);
40339
-
40343
+ /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72078);
40340
40344
 
40341
40345
  /**
40342
40346
  * @public
@@ -40345,7 +40349,7 @@ __webpack_require__.r(__webpack_exports__);
40345
40349
  * @public
40346
40350
  */
40347
40351
  /**
40348
- * Executes the callback on this element and all descendants.
40352
+ * Executes the callback on this element's path and all descendant paths.
40349
40353
  * @public
40350
40354
  */
40351
40355
  const forEach = (element, options) => {
@@ -40353,15 +40357,15 @@ const forEach = (element, options) => {
40353
40357
  let predicate;
40354
40358
  if (typeof options === 'function') {
40355
40359
  callback = options;
40356
- predicate = _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isElement;
40360
+ predicate = () => true;
40357
40361
  } else {
40358
40362
  callback = options.callback ?? (() => {});
40359
- predicate = options.predicate ?? _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isElement;
40363
+ predicate = options.predicate ?? (() => true);
40360
40364
  }
40361
- (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_1__.traverse)(element, {
40365
+ (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
40362
40366
  enter(path) {
40363
- if (predicate(path.node)) {
40364
- callback(path.node);
40367
+ if (predicate(path)) {
40368
+ callback(path);
40365
40369
  }
40366
40370
  }
40367
40371
  });
@@ -40410,11 +40414,11 @@ __webpack_require__.r(__webpack_exports__);
40410
40414
  /* harmony import */ var _filter_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(75247);
40411
40415
 
40412
40416
  /**
40413
- * Complement of filter. Finds all elements NOT matching the predicate.
40417
+ * Complement of filter. Finds all paths whose elements do NOT match the predicate.
40414
40418
  * @public
40415
40419
  */
40416
40420
  const reject = (element, predicate) => {
40417
- return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element, el => !predicate(el));
40421
+ return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element, path => !predicate(path));
40418
40422
  };
40419
40423
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (reject);
40420
40424
 
@@ -40431,7 +40435,7 @@ __webpack_require__.r(__webpack_exports__);
40431
40435
  /* harmony import */ var _find_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(44860);
40432
40436
 
40433
40437
  /**
40434
- * Tests whether at least one element passes the predicate.
40438
+ * Tests whether at least one path's element passes the predicate.
40435
40439
  * @public
40436
40440
  */
40437
40441
  const some = (element, predicate) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speclynx/apidom-parser-adapter-openapi-json-3-1",
3
- "version": "3.2.1",
3
+ "version": "4.0.1",
4
4
  "description": "Parser adapter for parsing JSON documents into OpenAPI 3.1.x namespace.",
5
5
  "keywords": [
6
6
  "apidom",
@@ -62,10 +62,10 @@
62
62
  "license": "Apache-2.0",
63
63
  "dependencies": {
64
64
  "@babel/runtime-corejs3": "^7.28.4",
65
- "@speclynx/apidom-core": "3.2.1",
66
- "@speclynx/apidom-datamodel": "3.2.1",
67
- "@speclynx/apidom-ns-openapi-3-1": "3.2.1",
68
- "@speclynx/apidom-parser-adapter-json": "3.2.1",
65
+ "@speclynx/apidom-core": "4.0.1",
66
+ "@speclynx/apidom-datamodel": "4.0.1",
67
+ "@speclynx/apidom-ns-openapi-3-1": "4.0.1",
68
+ "@speclynx/apidom-parser-adapter-json": "4.0.1",
69
69
  "ramda": "~0.32.0",
70
70
  "ramda-adjunct": "^6.0.0"
71
71
  },
@@ -79,5 +79,5 @@
79
79
  "README.md",
80
80
  "CHANGELOG.md"
81
81
  ],
82
- "gitHead": "83a1e97089ef29134e41ff7cacd351973114ea5b"
82
+ "gitHead": "223132a9b00081ca04842efc2736a491f7876f44"
83
83
  }
package/src/adapter.cjs DELETED
@@ -1,53 +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.parse = exports.namespace = exports.mediaTypes = exports.detectionRegExp = exports.detect = void 0;
7
- var _ramda = require("ramda");
8
- var _ramdaAdjunct = require("ramda-adjunct");
9
- var _apidomDatamodel = require("@speclynx/apidom-datamodel");
10
- var _apidomParserAdapterJson = require("@speclynx/apidom-parser-adapter-json");
11
- var _apidomNsOpenapi = _interopRequireWildcard(require("@speclynx/apidom-ns-openapi-3-1"));
12
- var _mediaTypes = _interopRequireDefault(require("./media-types.cjs"));
13
- exports.mediaTypes = _mediaTypes.default;
14
- /**
15
- * @public
16
- */
17
- const detectionRegExp = exports.detectionRegExp = /"openapi"\s*:\s*"(?<version_json>3\.1\.(?:[1-9]\d*|0))"/;
18
-
19
- /**
20
- * @public
21
- */
22
- const detect = async (source, options = {}) => detectionRegExp.test(source) && (await (0, _apidomParserAdapterJson.detect)(source, options));
23
-
24
- /**
25
- * @public
26
- */
27
- exports.detect = detect;
28
- /**
29
- * @public
30
- */
31
- const parse = async (source, options = {}) => {
32
- const refractorOpts = (0, _ramda.propOr)({}, 'refractorOpts', options);
33
- const parserOpts = (0, _ramda.omit)(['refractorOpts'], options);
34
- const parseResultElement = await (0, _apidomParserAdapterJson.parse)(source, parserOpts);
35
- const {
36
- result
37
- } = parseResultElement;
38
- if ((0, _ramdaAdjunct.isNotUndefined)(result)) {
39
- const openApiElement = (0, _apidomNsOpenapi.refractOpenApi3_1)(result, {
40
- consume: true,
41
- ...refractorOpts
42
- });
43
- openApiElement.classes.push('result');
44
- parseResultElement.replaceResult(openApiElement);
45
- }
46
- return parseResultElement;
47
- };
48
-
49
- /**
50
- * @public
51
- */
52
- exports.parse = parse;
53
- const namespace = exports.namespace = new _apidomDatamodel.Namespace().use(_apidomNsOpenapi.default);
package/src/adapter.mjs DELETED
@@ -1,45 +0,0 @@
1
- import { propOr, omit } from 'ramda';
2
- import { isNotUndefined } from 'ramda-adjunct';
3
- import { Namespace } from '@speclynx/apidom-datamodel';
4
- import { parse as parseJSON, detect as detectJSON } from '@speclynx/apidom-parser-adapter-json';
5
- import openApiNamespace, { refractOpenApi3_1 } from '@speclynx/apidom-ns-openapi-3-1';
6
- export { default as mediaTypes } from "./media-types.mjs";
7
- /**
8
- * @public
9
- */
10
- export const detectionRegExp = /"openapi"\s*:\s*"(?<version_json>3\.1\.(?:[1-9]\d*|0))"/;
11
-
12
- /**
13
- * @public
14
- */
15
- export const detect = async (source, options = {}) => detectionRegExp.test(source) && (await detectJSON(source, options));
16
-
17
- /**
18
- * @public
19
- */
20
-
21
- /**
22
- * @public
23
- */
24
- export const parse = async (source, options = {}) => {
25
- const refractorOpts = propOr({}, 'refractorOpts', options);
26
- const parserOpts = omit(['refractorOpts'], options);
27
- const parseResultElement = await parseJSON(source, parserOpts);
28
- const {
29
- result
30
- } = parseResultElement;
31
- if (isNotUndefined(result)) {
32
- const openApiElement = refractOpenApi3_1(result, {
33
- consume: true,
34
- ...refractorOpts
35
- });
36
- openApiElement.classes.push('result');
37
- parseResultElement.replaceResult(openApiElement);
38
- }
39
- return parseResultElement;
40
- };
41
-
42
- /**
43
- * @public
44
- */
45
- export const namespace = new Namespace().use(openApiNamespace);
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _apidomNsOpenapi = require("@speclynx/apidom-ns-openapi-3-1");
6
- /**
7
- * @public
8
- */
9
- const jsonMediaTypes = new _apidomNsOpenapi.OpenAPIMediaTypes(..._apidomNsOpenapi.mediaTypes.filterByFormat('generic'), ..._apidomNsOpenapi.mediaTypes.filterByFormat('json'));
10
- var _default = exports.default = jsonMediaTypes;
@@ -1,7 +0,0 @@
1
- import { mediaTypes, OpenAPIMediaTypes } from '@speclynx/apidom-ns-openapi-3-1';
2
-
3
- /**
4
- * @public
5
- */
6
- const jsonMediaTypes = new OpenAPIMediaTypes(...mediaTypes.filterByFormat('generic'), ...mediaTypes.filterByFormat('json'));
7
- export default jsonMediaTypes;