@speclynx/apidom-parser-adapter-openapi-json-2 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 +8 -0
- package/dist/apidom-parser-adapter-openapi-json-2.browser.js +24 -20
- package/package.json +6 -6
- package/src/adapter.cjs +0 -53
- package/src/adapter.mjs +0 -45
- package/src/media-types.cjs +0 -10
- package/src/media-types.mjs +0 -7
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-2
|
|
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-2
|
|
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-2
|
|
@@ -32054,7 +32054,9 @@ class Path {
|
|
|
32054
32054
|
*
|
|
32055
32055
|
* @example
|
|
32056
32056
|
* // For a path to $.paths['/pets'].get in an OpenAPI document:
|
|
32057
|
+
* ```
|
|
32057
32058
|
* path.getPathKeys(); // => ['paths', '/pets', 'get']
|
|
32059
|
+
* ```
|
|
32058
32060
|
*/
|
|
32059
32061
|
getPathKeys() {
|
|
32060
32062
|
const keys = [];
|
|
@@ -32089,18 +32091,22 @@ class Path {
|
|
|
32089
32091
|
* or Normalized JSONPath like "$['paths']['/pets']['get']['responses']['200']"
|
|
32090
32092
|
*
|
|
32091
32093
|
* @example
|
|
32094
|
+
* ```
|
|
32092
32095
|
* // JSON Pointer examples:
|
|
32093
32096
|
* path.formatPath(); // "" (root)
|
|
32094
32097
|
* path.formatPath(); // "/info"
|
|
32095
32098
|
* path.formatPath(); // "/paths/~1pets/get"
|
|
32096
32099
|
* path.formatPath(); // "/paths/~1users~1{id}/parameters/0"
|
|
32100
|
+
* ```
|
|
32097
32101
|
*
|
|
32098
32102
|
* @example
|
|
32103
|
+
* ```
|
|
32099
32104
|
* // JSONPath examples:
|
|
32100
32105
|
* path.formatPath('jsonpath'); // "$" (root)
|
|
32101
32106
|
* path.formatPath('jsonpath'); // "$['info']"
|
|
32102
32107
|
* path.formatPath('jsonpath'); // "$['paths']['/pets']['get']"
|
|
32103
32108
|
* path.formatPath('jsonpath'); // "$['paths']['/users/{id}']['parameters'][0]"
|
|
32109
|
+
* ```
|
|
32104
32110
|
*/
|
|
32105
32111
|
formatPath(pathFormat = 'jsonpointer') {
|
|
32106
32112
|
const parts = this.getPathKeys();
|
|
@@ -32310,15 +32316,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
32310
32316
|
/* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2078);
|
|
32311
32317
|
|
|
32312
32318
|
/**
|
|
32313
|
-
* Finds all elements
|
|
32319
|
+
* Finds all paths whose elements match the predicate.
|
|
32314
32320
|
* @public
|
|
32315
32321
|
*/
|
|
32316
32322
|
const filter = (element, predicate) => {
|
|
32317
32323
|
const result = [];
|
|
32318
32324
|
(0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
|
|
32319
32325
|
enter(path) {
|
|
32320
|
-
if (predicate(path
|
|
32321
|
-
result.push(path
|
|
32326
|
+
if (predicate(path)) {
|
|
32327
|
+
result.push(path);
|
|
32322
32328
|
}
|
|
32323
32329
|
}
|
|
32324
32330
|
});
|
|
@@ -32344,7 +32350,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
32344
32350
|
* @public
|
|
32345
32351
|
*/
|
|
32346
32352
|
/**
|
|
32347
|
-
* Finds the most inner node at the given offset.
|
|
32353
|
+
* Finds the path of the most inner node at the given offset.
|
|
32348
32354
|
* If includeRightBound is set, also finds nodes that end at the given offset.
|
|
32349
32355
|
* @public
|
|
32350
32356
|
*/
|
|
@@ -32369,7 +32375,7 @@ const findAtOffset = (element, options) => {
|
|
|
32369
32375
|
const endOffset = node.endOffset;
|
|
32370
32376
|
const isWithinOffsetRange = offset >= startOffset && (offset < endOffset || includeRightBound && offset <= endOffset);
|
|
32371
32377
|
if (isWithinOffsetRange) {
|
|
32372
|
-
result.push(
|
|
32378
|
+
result.push(path);
|
|
32373
32379
|
return; // push to stack and dive in
|
|
32374
32380
|
}
|
|
32375
32381
|
path.skip(); // skip entire sub-tree
|
|
@@ -32392,15 +32398,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
32392
32398
|
/* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2078);
|
|
32393
32399
|
|
|
32394
32400
|
/**
|
|
32395
|
-
*
|
|
32401
|
+
* Finds first path whose element satisfies the provided predicate.
|
|
32396
32402
|
* @public
|
|
32397
32403
|
*/
|
|
32398
32404
|
const find = (element, predicate) => {
|
|
32399
32405
|
let result;
|
|
32400
32406
|
(0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
|
|
32401
32407
|
enter(path) {
|
|
32402
|
-
if (predicate(path
|
|
32403
|
-
result = path
|
|
32408
|
+
if (predicate(path)) {
|
|
32409
|
+
result = path;
|
|
32404
32410
|
path.stop();
|
|
32405
32411
|
}
|
|
32406
32412
|
}
|
|
@@ -32419,9 +32425,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
32419
32425
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
32420
32426
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
32421
32427
|
/* harmony export */ });
|
|
32422
|
-
/* harmony import */ var
|
|
32423
|
-
/* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2078);
|
|
32424
|
-
|
|
32428
|
+
/* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2078);
|
|
32425
32429
|
|
|
32426
32430
|
/**
|
|
32427
32431
|
* @public
|
|
@@ -32430,7 +32434,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
32430
32434
|
* @public
|
|
32431
32435
|
*/
|
|
32432
32436
|
/**
|
|
32433
|
-
* Executes the callback on this element and all
|
|
32437
|
+
* Executes the callback on this element's path and all descendant paths.
|
|
32434
32438
|
* @public
|
|
32435
32439
|
*/
|
|
32436
32440
|
const forEach = (element, options) => {
|
|
@@ -32438,15 +32442,15 @@ const forEach = (element, options) => {
|
|
|
32438
32442
|
let predicate;
|
|
32439
32443
|
if (typeof options === 'function') {
|
|
32440
32444
|
callback = options;
|
|
32441
|
-
predicate =
|
|
32445
|
+
predicate = () => true;
|
|
32442
32446
|
} else {
|
|
32443
32447
|
callback = options.callback ?? (() => {});
|
|
32444
|
-
predicate = options.predicate ??
|
|
32448
|
+
predicate = options.predicate ?? (() => true);
|
|
32445
32449
|
}
|
|
32446
|
-
(0,
|
|
32450
|
+
(0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
|
|
32447
32451
|
enter(path) {
|
|
32448
|
-
if (predicate(path
|
|
32449
|
-
callback(path
|
|
32452
|
+
if (predicate(path)) {
|
|
32453
|
+
callback(path);
|
|
32450
32454
|
}
|
|
32451
32455
|
}
|
|
32452
32456
|
});
|
|
@@ -32495,11 +32499,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
32495
32499
|
/* harmony import */ var _filter_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5247);
|
|
32496
32500
|
|
|
32497
32501
|
/**
|
|
32498
|
-
* Complement of filter. Finds all elements NOT
|
|
32502
|
+
* Complement of filter. Finds all paths whose elements do NOT match the predicate.
|
|
32499
32503
|
* @public
|
|
32500
32504
|
*/
|
|
32501
32505
|
const reject = (element, predicate) => {
|
|
32502
|
-
return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element,
|
|
32506
|
+
return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element, path => !predicate(path));
|
|
32503
32507
|
};
|
|
32504
32508
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (reject);
|
|
32505
32509
|
|
|
@@ -32516,7 +32520,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
32516
32520
|
/* harmony import */ var _find_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4860);
|
|
32517
32521
|
|
|
32518
32522
|
/**
|
|
32519
|
-
* Tests whether at least one element passes the predicate.
|
|
32523
|
+
* Tests whether at least one path's element passes the predicate.
|
|
32520
32524
|
* @public
|
|
32521
32525
|
*/
|
|
32522
32526
|
const some = (element, predicate) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-parser-adapter-openapi-json-2",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Parser adapter for parsing JSON documents into OpenAPI 2.0 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": "
|
|
60
|
-
"@speclynx/apidom-datamodel": "
|
|
61
|
-
"@speclynx/apidom-ns-openapi-2": "
|
|
62
|
-
"@speclynx/apidom-parser-adapter-json": "
|
|
59
|
+
"@speclynx/apidom-core": "4.0.1",
|
|
60
|
+
"@speclynx/apidom-datamodel": "4.0.1",
|
|
61
|
+
"@speclynx/apidom-ns-openapi-2": "4.0.1",
|
|
62
|
+
"@speclynx/apidom-parser-adapter-json": "4.0.1",
|
|
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": "
|
|
76
|
+
"gitHead": "223132a9b00081ca04842efc2736a491f7876f44"
|
|
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-2"));
|
|
12
|
-
var _mediaTypes = _interopRequireDefault(require("./media-types.cjs"));
|
|
13
|
-
exports.mediaTypes = _mediaTypes.default;
|
|
14
|
-
/**
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
const detectionRegExp = exports.detectionRegExp = /"swagger"\s*:\s*"(?<version_json>2\.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 swaggerElement = (0, _apidomNsOpenapi.refractSwagger)(result, {
|
|
40
|
-
consume: true,
|
|
41
|
-
...refractorOpts
|
|
42
|
-
});
|
|
43
|
-
swaggerElement.classes.push('result');
|
|
44
|
-
parseResultElement.replaceResult(swaggerElement);
|
|
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, { refractSwagger } from '@speclynx/apidom-ns-openapi-2';
|
|
6
|
-
export { default as mediaTypes } from "./media-types.mjs";
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export const detectionRegExp = /"swagger"\s*:\s*"(?<version_json>2\.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 swaggerElement = refractSwagger(result, {
|
|
33
|
-
consume: true,
|
|
34
|
-
...refractorOpts
|
|
35
|
-
});
|
|
36
|
-
swaggerElement.classes.push('result');
|
|
37
|
-
parseResultElement.replaceResult(swaggerElement);
|
|
38
|
-
}
|
|
39
|
-
return parseResultElement;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @public
|
|
44
|
-
*/
|
|
45
|
-
export const namespace = new Namespace().use(openApiNamespace);
|
package/src/media-types.cjs
DELETED
|
@@ -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-2");
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
const jsonMediaTypes = new _apidomNsOpenapi.OpenAPIMediaTypes(..._apidomNsOpenapi.mediaTypes.filterByFormat('generic'), ..._apidomNsOpenapi.mediaTypes.filterByFormat('json'));
|
|
10
|
-
var _default = exports.default = jsonMediaTypes;
|
package/src/media-types.mjs
DELETED