@speclynx/apidom-parser-adapter-openapi-yaml-2 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 +4 -0
- package/dist/apidom-parser-adapter-openapi-yaml-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,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-yaml-2
|
|
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-yaml-2
|
|
@@ -44781,7 +44781,9 @@ class Path {
|
|
|
44781
44781
|
*
|
|
44782
44782
|
* @example
|
|
44783
44783
|
* // For a path to $.paths['/pets'].get in an OpenAPI document:
|
|
44784
|
+
* ```
|
|
44784
44785
|
* path.getPathKeys(); // => ['paths', '/pets', 'get']
|
|
44786
|
+
* ```
|
|
44785
44787
|
*/
|
|
44786
44788
|
getPathKeys() {
|
|
44787
44789
|
const keys = [];
|
|
@@ -44816,18 +44818,22 @@ class Path {
|
|
|
44816
44818
|
* or Normalized JSONPath like "$['paths']['/pets']['get']['responses']['200']"
|
|
44817
44819
|
*
|
|
44818
44820
|
* @example
|
|
44821
|
+
* ```
|
|
44819
44822
|
* // JSON Pointer examples:
|
|
44820
44823
|
* path.formatPath(); // "" (root)
|
|
44821
44824
|
* path.formatPath(); // "/info"
|
|
44822
44825
|
* path.formatPath(); // "/paths/~1pets/get"
|
|
44823
44826
|
* path.formatPath(); // "/paths/~1users~1{id}/parameters/0"
|
|
44827
|
+
* ```
|
|
44824
44828
|
*
|
|
44825
44829
|
* @example
|
|
44830
|
+
* ```
|
|
44826
44831
|
* // JSONPath examples:
|
|
44827
44832
|
* path.formatPath('jsonpath'); // "$" (root)
|
|
44828
44833
|
* path.formatPath('jsonpath'); // "$['info']"
|
|
44829
44834
|
* path.formatPath('jsonpath'); // "$['paths']['/pets']['get']"
|
|
44830
44835
|
* path.formatPath('jsonpath'); // "$['paths']['/users/{id}']['parameters'][0]"
|
|
44836
|
+
* ```
|
|
44831
44837
|
*/
|
|
44832
44838
|
formatPath(pathFormat = 'jsonpointer') {
|
|
44833
44839
|
const parts = this.getPathKeys();
|
|
@@ -45037,15 +45043,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
45037
45043
|
/* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72078);
|
|
45038
45044
|
|
|
45039
45045
|
/**
|
|
45040
|
-
* Finds all elements
|
|
45046
|
+
* Finds all paths whose elements match the predicate.
|
|
45041
45047
|
* @public
|
|
45042
45048
|
*/
|
|
45043
45049
|
const filter = (element, predicate) => {
|
|
45044
45050
|
const result = [];
|
|
45045
45051
|
(0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
|
|
45046
45052
|
enter(path) {
|
|
45047
|
-
if (predicate(path
|
|
45048
|
-
result.push(path
|
|
45053
|
+
if (predicate(path)) {
|
|
45054
|
+
result.push(path);
|
|
45049
45055
|
}
|
|
45050
45056
|
}
|
|
45051
45057
|
});
|
|
@@ -45071,7 +45077,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
45071
45077
|
* @public
|
|
45072
45078
|
*/
|
|
45073
45079
|
/**
|
|
45074
|
-
* Finds the most inner node at the given offset.
|
|
45080
|
+
* Finds the path of the most inner node at the given offset.
|
|
45075
45081
|
* If includeRightBound is set, also finds nodes that end at the given offset.
|
|
45076
45082
|
* @public
|
|
45077
45083
|
*/
|
|
@@ -45096,7 +45102,7 @@ const findAtOffset = (element, options) => {
|
|
|
45096
45102
|
const endOffset = node.endOffset;
|
|
45097
45103
|
const isWithinOffsetRange = offset >= startOffset && (offset < endOffset || includeRightBound && offset <= endOffset);
|
|
45098
45104
|
if (isWithinOffsetRange) {
|
|
45099
|
-
result.push(
|
|
45105
|
+
result.push(path);
|
|
45100
45106
|
return; // push to stack and dive in
|
|
45101
45107
|
}
|
|
45102
45108
|
path.skip(); // skip entire sub-tree
|
|
@@ -45119,15 +45125,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
45119
45125
|
/* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72078);
|
|
45120
45126
|
|
|
45121
45127
|
/**
|
|
45122
|
-
*
|
|
45128
|
+
* Finds first path whose element satisfies the provided predicate.
|
|
45123
45129
|
* @public
|
|
45124
45130
|
*/
|
|
45125
45131
|
const find = (element, predicate) => {
|
|
45126
45132
|
let result;
|
|
45127
45133
|
(0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
|
|
45128
45134
|
enter(path) {
|
|
45129
|
-
if (predicate(path
|
|
45130
|
-
result = path
|
|
45135
|
+
if (predicate(path)) {
|
|
45136
|
+
result = path;
|
|
45131
45137
|
path.stop();
|
|
45132
45138
|
}
|
|
45133
45139
|
}
|
|
@@ -45146,9 +45152,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
45146
45152
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
45147
45153
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
45148
45154
|
/* harmony export */ });
|
|
45149
|
-
/* harmony import */ var
|
|
45150
|
-
/* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(72078);
|
|
45151
|
-
|
|
45155
|
+
/* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72078);
|
|
45152
45156
|
|
|
45153
45157
|
/**
|
|
45154
45158
|
* @public
|
|
@@ -45157,7 +45161,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
45157
45161
|
* @public
|
|
45158
45162
|
*/
|
|
45159
45163
|
/**
|
|
45160
|
-
* Executes the callback on this element and all
|
|
45164
|
+
* Executes the callback on this element's path and all descendant paths.
|
|
45161
45165
|
* @public
|
|
45162
45166
|
*/
|
|
45163
45167
|
const forEach = (element, options) => {
|
|
@@ -45165,15 +45169,15 @@ const forEach = (element, options) => {
|
|
|
45165
45169
|
let predicate;
|
|
45166
45170
|
if (typeof options === 'function') {
|
|
45167
45171
|
callback = options;
|
|
45168
|
-
predicate =
|
|
45172
|
+
predicate = () => true;
|
|
45169
45173
|
} else {
|
|
45170
45174
|
callback = options.callback ?? (() => {});
|
|
45171
|
-
predicate = options.predicate ??
|
|
45175
|
+
predicate = options.predicate ?? (() => true);
|
|
45172
45176
|
}
|
|
45173
|
-
(0,
|
|
45177
|
+
(0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
|
|
45174
45178
|
enter(path) {
|
|
45175
|
-
if (predicate(path
|
|
45176
|
-
callback(path
|
|
45179
|
+
if (predicate(path)) {
|
|
45180
|
+
callback(path);
|
|
45177
45181
|
}
|
|
45178
45182
|
}
|
|
45179
45183
|
});
|
|
@@ -45222,11 +45226,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
45222
45226
|
/* harmony import */ var _filter_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(75247);
|
|
45223
45227
|
|
|
45224
45228
|
/**
|
|
45225
|
-
* Complement of filter. Finds all elements NOT
|
|
45229
|
+
* Complement of filter. Finds all paths whose elements do NOT match the predicate.
|
|
45226
45230
|
* @public
|
|
45227
45231
|
*/
|
|
45228
45232
|
const reject = (element, predicate) => {
|
|
45229
|
-
return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element,
|
|
45233
|
+
return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element, path => !predicate(path));
|
|
45230
45234
|
};
|
|
45231
45235
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (reject);
|
|
45232
45236
|
|
|
@@ -45243,7 +45247,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
45243
45247
|
/* harmony import */ var _find_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(44860);
|
|
45244
45248
|
|
|
45245
45249
|
/**
|
|
45246
|
-
* Tests whether at least one element passes the predicate.
|
|
45250
|
+
* Tests whether at least one path's element passes the predicate.
|
|
45247
45251
|
* @public
|
|
45248
45252
|
*/
|
|
45249
45253
|
const some = (element, predicate) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-parser-adapter-openapi-yaml-2",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Parser adapter for parsing YAML 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-yaml-1-2": "
|
|
59
|
+
"@speclynx/apidom-core": "4.0.0",
|
|
60
|
+
"@speclynx/apidom-datamodel": "4.0.0",
|
|
61
|
+
"@speclynx/apidom-ns-openapi-2": "4.0.0",
|
|
62
|
+
"@speclynx/apidom-parser-adapter-yaml-1-2": "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": "
|
|
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 _apidomParserAdapterYaml = require("@speclynx/apidom-parser-adapter-yaml-1-2");
|
|
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 = /(?<YAML>^(["']?)swagger\2\s*:\s*(["'])(?<version_yaml>2\.0)\3(?:\s+|$))|(?<JSON>"swagger"\s*:\s*"(?<version_json>2\.0)")/m;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
const detect = async (source, options = {}) => detectionRegExp.test(source) && (await (0, _apidomParserAdapterYaml.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, _apidomParserAdapterYaml.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 parseYAML, detect as detectYAML } from '@speclynx/apidom-parser-adapter-yaml-1-2';
|
|
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 = /(?<YAML>^(["']?)swagger\2\s*:\s*(["'])(?<version_yaml>2\.0)\3(?:\s+|$))|(?<JSON>"swagger"\s*:\s*"(?<version_json>2\.0)")/m;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
export const detect = async (source, options = {}) => detectionRegExp.test(source) && (await detectYAML(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 parseYAML(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 yamlMediaTypes = new _apidomNsOpenapi.OpenAPIMediaTypes(..._apidomNsOpenapi.mediaTypes.filterByFormat('generic'), ..._apidomNsOpenapi.mediaTypes.filterByFormat('yaml'));
|
|
10
|
-
var _default = exports.default = yamlMediaTypes;
|
package/src/media-types.mjs
DELETED