@speclynx/apidom-parser-adapter-openapi-json-3-0 3.2.1 → 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,10 @@
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
+ **Note:** Version bump only for package @speclynx/apidom-parser-adapter-openapi-json-3-0
9
+
6
10
  ## [3.2.1](https://github.com/speclynx/apidom/compare/v3.2.0...v3.2.1) (2026-03-09)
7
11
 
8
12
  **Note:** Version bump only for package @speclynx/apidom-parser-adapter-openapi-json-3-0
@@ -34360,7 +34360,9 @@ class Path {
34360
34360
  *
34361
34361
  * @example
34362
34362
  * // For a path to $.paths['/pets'].get in an OpenAPI document:
34363
+ * ```
34363
34364
  * path.getPathKeys(); // => ['paths', '/pets', 'get']
34365
+ * ```
34364
34366
  */
34365
34367
  getPathKeys() {
34366
34368
  const keys = [];
@@ -34395,18 +34397,22 @@ class Path {
34395
34397
  * or Normalized JSONPath like "$['paths']['/pets']['get']['responses']['200']"
34396
34398
  *
34397
34399
  * @example
34400
+ * ```
34398
34401
  * // JSON Pointer examples:
34399
34402
  * path.formatPath(); // "" (root)
34400
34403
  * path.formatPath(); // "/info"
34401
34404
  * path.formatPath(); // "/paths/~1pets/get"
34402
34405
  * path.formatPath(); // "/paths/~1users~1{id}/parameters/0"
34406
+ * ```
34403
34407
  *
34404
34408
  * @example
34409
+ * ```
34405
34410
  * // JSONPath examples:
34406
34411
  * path.formatPath('jsonpath'); // "$" (root)
34407
34412
  * path.formatPath('jsonpath'); // "$['info']"
34408
34413
  * path.formatPath('jsonpath'); // "$['paths']['/pets']['get']"
34409
34414
  * path.formatPath('jsonpath'); // "$['paths']['/users/{id}']['parameters'][0]"
34415
+ * ```
34410
34416
  */
34411
34417
  formatPath(pathFormat = 'jsonpointer') {
34412
34418
  const parts = this.getPathKeys();
@@ -34616,15 +34622,15 @@ __webpack_require__.r(__webpack_exports__);
34616
34622
  /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2078);
34617
34623
 
34618
34624
  /**
34619
- * Finds all elements matching the predicate.
34625
+ * Finds all paths whose elements match the predicate.
34620
34626
  * @public
34621
34627
  */
34622
34628
  const filter = (element, predicate) => {
34623
34629
  const result = [];
34624
34630
  (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
34625
34631
  enter(path) {
34626
- if (predicate(path.node)) {
34627
- result.push(path.node);
34632
+ if (predicate(path)) {
34633
+ result.push(path);
34628
34634
  }
34629
34635
  }
34630
34636
  });
@@ -34650,7 +34656,7 @@ __webpack_require__.r(__webpack_exports__);
34650
34656
  * @public
34651
34657
  */
34652
34658
  /**
34653
- * Finds the most inner node at the given offset.
34659
+ * Finds the path of the most inner node at the given offset.
34654
34660
  * If includeRightBound is set, also finds nodes that end at the given offset.
34655
34661
  * @public
34656
34662
  */
@@ -34675,7 +34681,7 @@ const findAtOffset = (element, options) => {
34675
34681
  const endOffset = node.endOffset;
34676
34682
  const isWithinOffsetRange = offset >= startOffset && (offset < endOffset || includeRightBound && offset <= endOffset);
34677
34683
  if (isWithinOffsetRange) {
34678
- result.push(node);
34684
+ result.push(path);
34679
34685
  return; // push to stack and dive in
34680
34686
  }
34681
34687
  path.skip(); // skip entire sub-tree
@@ -34698,15 +34704,15 @@ __webpack_require__.r(__webpack_exports__);
34698
34704
  /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2078);
34699
34705
 
34700
34706
  /**
34701
- * Find first element that satisfies the provided predicate.
34707
+ * Finds first path whose element satisfies the provided predicate.
34702
34708
  * @public
34703
34709
  */
34704
34710
  const find = (element, predicate) => {
34705
34711
  let result;
34706
34712
  (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
34707
34713
  enter(path) {
34708
- if (predicate(path.node)) {
34709
- result = path.node;
34714
+ if (predicate(path)) {
34715
+ result = path;
34710
34716
  path.stop();
34711
34717
  }
34712
34718
  }
@@ -34725,9 +34731,7 @@ __webpack_require__.r(__webpack_exports__);
34725
34731
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
34726
34732
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
34727
34733
  /* harmony export */ });
34728
- /* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5162);
34729
- /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2078);
34730
-
34734
+ /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2078);
34731
34735
 
34732
34736
  /**
34733
34737
  * @public
@@ -34736,7 +34740,7 @@ __webpack_require__.r(__webpack_exports__);
34736
34740
  * @public
34737
34741
  */
34738
34742
  /**
34739
- * Executes the callback on this element and all descendants.
34743
+ * Executes the callback on this element's path and all descendant paths.
34740
34744
  * @public
34741
34745
  */
34742
34746
  const forEach = (element, options) => {
@@ -34744,15 +34748,15 @@ const forEach = (element, options) => {
34744
34748
  let predicate;
34745
34749
  if (typeof options === 'function') {
34746
34750
  callback = options;
34747
- predicate = _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isElement;
34751
+ predicate = () => true;
34748
34752
  } else {
34749
34753
  callback = options.callback ?? (() => {});
34750
- predicate = options.predicate ?? _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isElement;
34754
+ predicate = options.predicate ?? (() => true);
34751
34755
  }
34752
- (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_1__.traverse)(element, {
34756
+ (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
34753
34757
  enter(path) {
34754
- if (predicate(path.node)) {
34755
- callback(path.node);
34758
+ if (predicate(path)) {
34759
+ callback(path);
34756
34760
  }
34757
34761
  }
34758
34762
  });
@@ -34801,11 +34805,11 @@ __webpack_require__.r(__webpack_exports__);
34801
34805
  /* harmony import */ var _filter_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5247);
34802
34806
 
34803
34807
  /**
34804
- * Complement of filter. Finds all elements NOT matching the predicate.
34808
+ * Complement of filter. Finds all paths whose elements do NOT match the predicate.
34805
34809
  * @public
34806
34810
  */
34807
34811
  const reject = (element, predicate) => {
34808
- return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element, el => !predicate(el));
34812
+ return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element, path => !predicate(path));
34809
34813
  };
34810
34814
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (reject);
34811
34815
 
@@ -34822,7 +34826,7 @@ __webpack_require__.r(__webpack_exports__);
34822
34826
  /* harmony import */ var _find_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4860);
34823
34827
 
34824
34828
  /**
34825
- * Tests whether at least one element passes the predicate.
34829
+ * Tests whether at least one path's element passes the predicate.
34826
34830
  * @public
34827
34831
  */
34828
34832
  const some = (element, predicate) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speclynx/apidom-parser-adapter-openapi-json-3-0",
3
- "version": "3.2.1",
3
+ "version": "4.0.0",
4
4
  "description": "Parser adapter for parsing JSON documents into OpenAPI 3.0.x namespace.",
5
5
  "keywords": [
6
6
  "apidom",
@@ -56,10 +56,10 @@
56
56
  "license": "Apache-2.0",
57
57
  "dependencies": {
58
58
  "@babel/runtime-corejs3": "^7.28.4",
59
- "@speclynx/apidom-core": "3.2.1",
60
- "@speclynx/apidom-datamodel": "3.2.1",
61
- "@speclynx/apidom-ns-openapi-3-0": "3.2.1",
62
- "@speclynx/apidom-parser-adapter-json": "3.2.1",
59
+ "@speclynx/apidom-core": "4.0.0",
60
+ "@speclynx/apidom-datamodel": "4.0.0",
61
+ "@speclynx/apidom-ns-openapi-3-0": "4.0.0",
62
+ "@speclynx/apidom-parser-adapter-json": "4.0.0",
63
63
  "ramda": "~0.32.0",
64
64
  "ramda-adjunct": "^6.0.0"
65
65
  },
@@ -73,5 +73,5 @@
73
73
  "README.md",
74
74
  "CHANGELOG.md"
75
75
  ],
76
- "gitHead": "83a1e97089ef29134e41ff7cacd351973114ea5b"
76
+ "gitHead": "384ff82a1bb68d015fd6801de641898b4b582876"
77
77
  }
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-0"));
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\.0\.(?:[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_0)(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_0 } from '@speclynx/apidom-ns-openapi-3-0';
6
- export { default as mediaTypes } from "./media-types.mjs";
7
- /**
8
- * @public
9
- */
10
- export const detectionRegExp = /"openapi"\s*:\s*"(?<version_json>3\.0\.(?:[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_0(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-0");
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-0';
2
-
3
- /**
4
- * @public
5
- */
6
- const jsonMediaTypes = new OpenAPIMediaTypes(...mediaTypes.filterByFormat('generic'), ...mediaTypes.filterByFormat('json'));
7
- export default jsonMediaTypes;