@scalar/openapi-parser 0.10.9 → 0.10.11
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 +12 -0
- package/README.md +0 -2
- package/dist/polyfills/path.d.ts.map +1 -1
- package/dist/polyfills/path.js +11 -14
- package/dist/utils/isYaml.js +1 -1
- package/dist/utils/load/load.js +1 -1
- package/dist/utils/normalize.js +1 -1
- package/dist/utils/resolveReferences.js +5 -3
- package/dist/utils/upgradeFromTwoToThree.d.ts.map +1 -1
- package/dist/utils/upgradeFromTwoToThree.js +0 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @scalar/openapi-parser
|
|
2
2
|
|
|
3
|
+
## 0.10.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0f13162: chore: enable more Biome flags, apply linter fixes
|
|
8
|
+
|
|
9
|
+
## 0.10.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 0d8a24f: chore: remove Swagger 2.0 upgrade warning
|
|
14
|
+
|
|
3
15
|
## 0.10.9
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -101,8 +101,6 @@ const { specification } = filter(
|
|
|
101
101
|
|
|
102
102
|
There’s an `upgrade` command to upgrade all your OpenAPI documents to the latest OpenAPI version.
|
|
103
103
|
|
|
104
|
-
> ⚠️ The upgrade from Swagger 2.0 is still experimental and probably lacks features.
|
|
105
|
-
|
|
106
104
|
```ts
|
|
107
105
|
import { upgrade } from '@scalar/openapi-parser'
|
|
108
106
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/polyfills/path.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/polyfills/path.ts"],"names":[],"mappings":"AA4DA,wBAAgB,OAAO,CAAC,GAAG,UAAU,OAAA,UA6BpC;AAID,wBAAgB,SAAS,CAAC,IAAI,KAAA,UAkB7B;AAGD,wBAAgB,UAAU,CAAC,IAAI,KAAA,WAE9B;AAGD,wBAAgB,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,UAStC;AAID,wBAAgB,QAAQ,CAAC,IAAI,KAAA,EAAE,EAAE,KAAA,UA6ChC;AAED,eAAO,MAAM,GAAG,MAAM,CAAA;AACtB,eAAO,MAAM,SAAS,MAAM,CAAA;AAE5B,wBAAgB,OAAO,CAAC,IAAI,KAAA,UAiB3B;AAED,wBAAgB,QAAQ,CAAC,IAAI,KAAA,EAAE,GAAG,KAAA,UAOjC;AAED,wBAAgB,OAAO,CAAC,IAAI,KAAA,UAE3B;;;;;;;;;;;;;AACD,wBAWC"}
|
package/dist/polyfills/path.js
CHANGED
|
@@ -51,17 +51,13 @@ function normalizeArray(parts, allowAboveRoot) {
|
|
|
51
51
|
// Split a filename into [root, dir, basename, ext], unix version
|
|
52
52
|
// 'root' is just a slash, or nothing.
|
|
53
53
|
const splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/;
|
|
54
|
-
const splitPath =
|
|
55
|
-
return splitPathRe.exec(filename).slice(1);
|
|
56
|
-
};
|
|
54
|
+
const splitPath = (filename) => splitPathRe.exec(filename).slice(1);
|
|
57
55
|
// path.normalize(path)
|
|
58
56
|
// posix version
|
|
59
57
|
function normalize(path) {
|
|
60
58
|
const isPathAbsolute = isAbsolute(path), trailingSlash = substr(path, -1) === '/';
|
|
61
59
|
// Normalize the path
|
|
62
|
-
path = normalizeArray(filter(path.split('/'),
|
|
63
|
-
return !!p;
|
|
64
|
-
}), !isPathAbsolute).join('/');
|
|
60
|
+
path = normalizeArray(filter(path.split('/'), (p) => !!p), !isPathAbsolute).join('/');
|
|
65
61
|
if (!path && !isPathAbsolute) {
|
|
66
62
|
path = '.';
|
|
67
63
|
}
|
|
@@ -76,7 +72,7 @@ function isAbsolute(path) {
|
|
|
76
72
|
}
|
|
77
73
|
// posix version
|
|
78
74
|
function join(...paths) {
|
|
79
|
-
return normalize(filter(paths,
|
|
75
|
+
return normalize(filter(paths, (p, _index) => {
|
|
80
76
|
if (typeof p !== 'string') {
|
|
81
77
|
throw new TypeError('Arguments to path.join must be strings');
|
|
82
78
|
}
|
|
@@ -97,23 +93,24 @@ function dirname(path) {
|
|
|
97
93
|
return root + dir;
|
|
98
94
|
}
|
|
99
95
|
function filter(xs, f) {
|
|
100
|
-
if (xs.filter)
|
|
96
|
+
if (xs.filter) {
|
|
101
97
|
return xs.filter(f);
|
|
98
|
+
}
|
|
102
99
|
const res = [];
|
|
103
100
|
for (let i = 0; i < xs.length; i++) {
|
|
104
|
-
if (f(xs[i], i, xs))
|
|
101
|
+
if (f(xs[i], i, xs)) {
|
|
105
102
|
res.push(xs[i]);
|
|
103
|
+
}
|
|
106
104
|
}
|
|
107
105
|
return res;
|
|
108
106
|
}
|
|
109
107
|
// String.prototype.substr - negative index don't work in IE8
|
|
110
108
|
const substr = 'ab'.substr(-1) === 'b'
|
|
111
|
-
?
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
: function (str, start, len) {
|
|
115
|
-
if (start < 0)
|
|
109
|
+
? (str, start, len) => str.substr(start, len)
|
|
110
|
+
: (str, start, len) => {
|
|
111
|
+
if (start < 0) {
|
|
116
112
|
start = str.length + start;
|
|
113
|
+
}
|
|
117
114
|
return str.substr(start, len);
|
|
118
115
|
};
|
|
119
116
|
|
package/dist/utils/isYaml.js
CHANGED
package/dist/utils/load/load.js
CHANGED
package/dist/utils/normalize.js
CHANGED
|
@@ -41,8 +41,9 @@ function dereference(schema, filesystem, entrypoint,
|
|
|
41
41
|
resolvedSchemas,
|
|
42
42
|
// error output
|
|
43
43
|
errors, options) {
|
|
44
|
-
if (schema === null || resolvedSchemas.has(schema))
|
|
44
|
+
if (schema === null || resolvedSchemas.has(schema)) {
|
|
45
45
|
return;
|
|
46
|
+
}
|
|
46
47
|
resolvedSchemas.add(schema);
|
|
47
48
|
function resolveExternal(externalFile) {
|
|
48
49
|
dereference(externalFile.specification, filesystem, externalFile, resolvedSchemas, errors, options);
|
|
@@ -52,8 +53,9 @@ errors, options) {
|
|
|
52
53
|
// Find the referenced content
|
|
53
54
|
const resolved = resolveUri(schema.$ref, options, entrypoint, filesystem, resolveExternal, errors);
|
|
54
55
|
// invalid
|
|
55
|
-
if (typeof resolved !== 'object' || resolved === null)
|
|
56
|
+
if (typeof resolved !== 'object' || resolved === null) {
|
|
56
57
|
break;
|
|
58
|
+
}
|
|
57
59
|
const dereferencedRef = schema.$ref;
|
|
58
60
|
// Get rid of the reference
|
|
59
61
|
delete schema.$ref;
|
|
@@ -133,7 +135,7 @@ resolve, errors) {
|
|
|
133
135
|
return acc[key];
|
|
134
136
|
}, file.specification);
|
|
135
137
|
}
|
|
136
|
-
catch (
|
|
138
|
+
catch (_error) {
|
|
137
139
|
if (options?.throwOnError) {
|
|
138
140
|
throw new Error(ERRORS.INVALID_REFERENCE.replace('%s', uri));
|
|
139
141
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgradeFromTwoToThree.d.ts","sourceRoot":"","sources":["../../src/utils/upgradeFromTwoToThree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAIxD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,qBAAqB,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"upgradeFromTwoToThree.d.ts","sourceRoot":"","sources":["../../src/utils/upgradeFromTwoToThree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAIxD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,qBAAqB,EAAE,aAAa,0CAgOzE"}
|
|
@@ -16,7 +16,6 @@ function upgradeFromTwoToThree(originalSpecification) {
|
|
|
16
16
|
// Skip if it’s something else than 3.0.x
|
|
17
17
|
return specification;
|
|
18
18
|
}
|
|
19
|
-
console.warn(`[upgradeFromTwoToThree] The upgrade from Swagger 2.0 to OpenAPI 3.0 documents is experimental and lacks features.`);
|
|
20
19
|
// Servers
|
|
21
20
|
if (specification.host) {
|
|
22
21
|
const schemes = Array.isArray(specification.schemes) && specification.schemes?.length ? specification.schemes : ['http'];
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"parser",
|
|
18
18
|
"typescript"
|
|
19
19
|
],
|
|
20
|
-
"version": "0.10.
|
|
20
|
+
"version": "0.10.11",
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=18"
|
|
23
23
|
},
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"json-to-ast": "^2.1.0",
|
|
65
65
|
"just-diff": "^6.0.2",
|
|
66
66
|
"tinybench": "^2.8.0",
|
|
67
|
-
"@scalar/build-tooling": "0.1.
|
|
68
|
-
"@scalar/types": "0.
|
|
69
|
-
"@scalar/
|
|
67
|
+
"@scalar/build-tooling": "0.1.17",
|
|
68
|
+
"@scalar/openapi-types": "0.1.9",
|
|
69
|
+
"@scalar/types": "0.1.2"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "scalar-build-rollup",
|