@scalar/openapi-parser 0.20.6 → 0.21.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 +18 -0
- package/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +2 -2
- package/dist/utils/upgrade.d.ts.map +1 -1
- package/dist/utils/upgrade.js +5 -12
- package/dist/utils/upgrade.js.map +2 -2
- package/package.json +5 -4
- package/dist/utils/escape-json-pointer.d.ts +0 -7
- package/dist/utils/escape-json-pointer.d.ts.map +0 -1
- package/dist/utils/escape-json-pointer.js +0 -7
- package/dist/utils/escape-json-pointer.js.map +0 -7
- package/dist/utils/upgrade-from-three-to-three-one.d.ts +0 -31
- package/dist/utils/upgrade-from-three-to-three-one.d.ts.map +0 -1
- package/dist/utils/upgrade-from-three-to-three-one.js +0 -117
- package/dist/utils/upgrade-from-three-to-three-one.js.map +0 -7
- package/dist/utils/upgrade-from-two-to-three.d.ts +0 -9
- package/dist/utils/upgrade-from-two-to-three.d.ts.map +0 -1
- package/dist/utils/upgrade-from-two-to-three.js +0 -352
- package/dist/utils/upgrade-from-two-to-three.js.map +0 -7
- package/dist/utils/upgrade.bench.d.ts +0 -2
- package/dist/utils/upgrade.bench.d.ts.map +0 -1
- package/dist/utils/upgrade.bench.js +0 -31
- package/dist/utils/upgrade.bench.js.map +0 -7
- package/dist/utils/upgrade.test-d.d.ts +0 -2
- package/dist/utils/upgrade.test-d.d.ts.map +0 -1
- package/dist/utils/upgrade.test-d.js +0 -16
- package/dist/utils/upgrade.test-d.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @scalar/openapi-parser
|
|
2
2
|
|
|
3
|
+
## 0.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a1f865c: refactor: move upgrade() to @scalar/openapi-upgrader
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- a1f865c: refactor: use @scalar/openapi-upgrader
|
|
12
|
+
- dcf50ef: refactor: move escapeJsonPointer to @scalar/json-magic
|
|
13
|
+
- Updated dependencies [6221e4a]
|
|
14
|
+
- Updated dependencies [fe46413]
|
|
15
|
+
- Updated dependencies [2d612e4]
|
|
16
|
+
- Updated dependencies [dcf50ef]
|
|
17
|
+
- Updated dependencies [02085ef]
|
|
18
|
+
- @scalar/openapi-upgrader@0.1.0
|
|
19
|
+
- @scalar/json-magic@0.5.0
|
|
20
|
+
|
|
3
21
|
## 0.20.6
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
+
/** @deprecated Please import from @scalar/json-magic/helpers/escape-json-pointer instead */
|
|
2
|
+
export { escapeJsonPointer } from '@scalar/json-magic/helpers/escape-json-pointer';
|
|
3
|
+
/** @deprecated Please import from @scalar/openapi-upgrader/2.0-to-3.0 instead */
|
|
4
|
+
export { upgradeFromTwoToThree } from '@scalar/openapi-upgrader/2.0-to-3.0';
|
|
5
|
+
/** @deprecated Please import from @scalar/openapi-upgrader/3.0-to-3.1 instead */
|
|
6
|
+
export { upgradeFromThreeToThreeOne } from '@scalar/openapi-upgrader/3.0-to-3.1';
|
|
7
|
+
export type { AnyObject, ErrorObject, Filesystem, LoadResult } from './types/index.js';
|
|
1
8
|
export { dereference } from './utils/dereference.js';
|
|
2
|
-
export { escapeJsonPointer } from './utils/escape-json-pointer.js';
|
|
3
9
|
export { filter } from './utils/filter.js';
|
|
4
10
|
export { isJson } from './utils/is-json.js';
|
|
5
11
|
export { isYaml } from './utils/is-yaml.js';
|
|
12
|
+
export { join } from './utils/join/index.js';
|
|
6
13
|
export { load } from './utils/load/index.js';
|
|
7
14
|
export { normalize } from './utils/normalize.js';
|
|
8
|
-
export {
|
|
15
|
+
export { openapi } from './utils/openapi/openapi.js';
|
|
9
16
|
export { toJson } from './utils/to-json.js';
|
|
10
17
|
export { toYaml } from './utils/to-yaml.js';
|
|
18
|
+
export { sanitize } from './utils/transform/sanitize.js';
|
|
11
19
|
export { traverse } from './utils/traverse.js';
|
|
12
20
|
export { unescapeJsonPointer } from './utils/unescape-json-pointer.js';
|
|
13
21
|
export { upgrade } from './utils/upgrade.js';
|
|
14
|
-
export { upgradeFromThreeToThreeOne } from './utils/upgrade-from-three-to-three-one.js';
|
|
15
|
-
export { upgradeFromTwoToThree } from './utils/upgrade-from-two-to-three.js';
|
|
16
22
|
export { validate } from './utils/validate.js';
|
|
17
|
-
export { join } from './utils/join/index.js';
|
|
18
|
-
export type { LoadResult, Filesystem, AnyObject, ErrorObject } from './types/index.js';
|
|
19
|
-
export { openapi } from './utils/openapi/openapi.js';
|
|
20
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,4FAA4F;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAA;AAClF,iFAAiF;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,iFAAiF;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAA;AAEhF,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
+
import { escapeJsonPointer } from "@scalar/json-magic/helpers/escape-json-pointer";
|
|
2
|
+
import { upgradeFromTwoToThree } from "@scalar/openapi-upgrader/2.0-to-3.0";
|
|
3
|
+
import { upgradeFromThreeToThreeOne } from "@scalar/openapi-upgrader/3.0-to-3.1";
|
|
1
4
|
import { dereference } from "./utils/dereference.js";
|
|
2
|
-
import { escapeJsonPointer } from "./utils/escape-json-pointer.js";
|
|
3
5
|
import { filter } from "./utils/filter.js";
|
|
4
6
|
import { isJson } from "./utils/is-json.js";
|
|
5
7
|
import { isYaml } from "./utils/is-yaml.js";
|
|
8
|
+
import { join } from "./utils/join/index.js";
|
|
6
9
|
import { load } from "./utils/load/index.js";
|
|
7
10
|
import { normalize } from "./utils/normalize.js";
|
|
8
|
-
import {
|
|
11
|
+
import { openapi } from "./utils/openapi/openapi.js";
|
|
9
12
|
import { toJson } from "./utils/to-json.js";
|
|
10
13
|
import { toYaml } from "./utils/to-yaml.js";
|
|
14
|
+
import { sanitize } from "./utils/transform/sanitize.js";
|
|
11
15
|
import { traverse } from "./utils/traverse.js";
|
|
12
16
|
import { unescapeJsonPointer } from "./utils/unescape-json-pointer.js";
|
|
13
17
|
import { upgrade } from "./utils/upgrade.js";
|
|
14
|
-
import { upgradeFromThreeToThreeOne } from "./utils/upgrade-from-three-to-three-one.js";
|
|
15
|
-
import { upgradeFromTwoToThree } from "./utils/upgrade-from-two-to-three.js";
|
|
16
18
|
import { validate } from "./utils/validate.js";
|
|
17
|
-
import { join } from "./utils/join/index.js";
|
|
18
|
-
import { openapi } from "./utils/openapi/openapi.js";
|
|
19
19
|
export {
|
|
20
20
|
dereference,
|
|
21
21
|
escapeJsonPointer,
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["// biome-ignore lint/performance/noBarrelFile: <explanation>\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["// biome-ignore lint/performance/noBarrelFile: <explanation>\n\n/** @deprecated Please import from @scalar/json-magic/helpers/escape-json-pointer instead */\nexport { escapeJsonPointer } from '@scalar/json-magic/helpers/escape-json-pointer'\n/** @deprecated Please import from @scalar/openapi-upgrader/2.0-to-3.0 instead */\nexport { upgradeFromTwoToThree } from '@scalar/openapi-upgrader/2.0-to-3.0'\n/** @deprecated Please import from @scalar/openapi-upgrader/3.0-to-3.1 instead */\nexport { upgradeFromThreeToThreeOne } from '@scalar/openapi-upgrader/3.0-to-3.1'\n\nexport type { AnyObject, ErrorObject, Filesystem, LoadResult } from './types'\nexport { dereference } from './utils/dereference'\nexport { filter } from './utils/filter'\nexport { isJson } from './utils/is-json'\nexport { isYaml } from './utils/is-yaml'\nexport { join } from './utils/join'\nexport { load } from './utils/load'\nexport { normalize } from './utils/normalize'\nexport { openapi } from './utils/openapi/openapi'\nexport { toJson } from './utils/to-json'\nexport { toYaml } from './utils/to-yaml'\nexport { sanitize } from './utils/transform/sanitize'\nexport { traverse } from './utils/traverse'\nexport { unescapeJsonPointer } from './utils/unescape-json-pointer'\nexport { upgrade } from './utils/upgrade'\nexport { validate } from './utils/validate'\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,yBAAyB;AAElC,SAAS,6BAA6B;AAEtC,SAAS,kCAAkC;AAG3C,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,2BAA2B;AACpC,SAAS,eAAe;AACxB,SAAS,gBAAgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAIxD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAMzE;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CAmBnG"}
|
package/dist/utils/upgrade.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
+
import { upgrade as originalUpgrade } from "@scalar/openapi-upgrader";
|
|
1
2
|
import { getEntrypoint } from "./get-entrypoint.js";
|
|
2
3
|
import { isFilesystem } from "./is-filesystem.js";
|
|
3
4
|
import { normalize } from "./normalize.js";
|
|
4
|
-
import { upgradeFromThreeToThreeOne } from "./upgrade-from-three-to-three-one.js";
|
|
5
|
-
import { upgradeFromTwoToThree } from "./upgrade-from-two-to-three.js";
|
|
6
|
-
const upgraders = [
|
|
7
|
-
// Swagger 2.0 -> OpenAPI 3.0
|
|
8
|
-
upgradeFromTwoToThree,
|
|
9
|
-
// OpenAPI 3.0 -> OpenAPI 3.1
|
|
10
|
-
upgradeFromThreeToThreeOne
|
|
11
|
-
];
|
|
12
5
|
function upgrade(value) {
|
|
13
6
|
if (!value) {
|
|
14
7
|
return {
|
|
@@ -16,12 +9,12 @@ function upgrade(value) {
|
|
|
16
9
|
version: "3.1"
|
|
17
10
|
};
|
|
18
11
|
}
|
|
19
|
-
const
|
|
20
|
-
(
|
|
21
|
-
|
|
12
|
+
const document = originalUpgrade(
|
|
13
|
+
isFilesystem(value) ? getEntrypoint(value).specification : normalize(value),
|
|
14
|
+
"3.1"
|
|
22
15
|
);
|
|
23
16
|
return {
|
|
24
|
-
specification:
|
|
17
|
+
specification: document,
|
|
25
18
|
// TODO: Make dynamic
|
|
26
19
|
version: "3.1"
|
|
27
20
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/upgrade.ts"],
|
|
4
|
-
"sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { upgrade as originalUpgrade } from '@scalar/openapi-upgrader'\nimport type { UnknownObject } from '@scalar/types/utils'\n\nimport type { AnyObject, Filesystem, UpgradeResult } from '@/types/index'\n\nimport { getEntrypoint } from './get-entrypoint'\nimport { isFilesystem } from './is-filesystem'\nimport { normalize } from './normalize'\n\n/**\n * Upgrade specification to OpenAPI 3.1.0\n */\nexport function upgrade(value: string | AnyObject | Filesystem): UpgradeResult<OpenAPIV3_1.Document> {\n if (!value) {\n return {\n specification: null,\n version: '3.1',\n }\n }\n\n // TODO: Run upgrade over the whole filesystem\n const document = originalUpgrade(\n isFilesystem(value) ? getEntrypoint(value).specification : (normalize(value) as UnknownObject),\n '3.1',\n )\n\n return {\n specification: document,\n // TODO: Make dynamic\n version: '3.1',\n } as UpgradeResult<OpenAPIV3_1.Document>\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,WAAW,uBAAuB;AAK3C,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAKnB,SAAS,QAAQ,OAA6E;AACnG,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,MACL,eAAe;AAAA,MACf,SAAS;AAAA,IACX;AAAA,EACF;AAGA,QAAM,WAAW;AAAA,IACf,aAAa,KAAK,IAAI,cAAc,KAAK,EAAE,gBAAiB,UAAU,KAAK;AAAA,IAC3E;AAAA,EACF;AAEA,SAAO;AAAA,IACL,eAAe;AAAA;AAAA,IAEf,SAAS;AAAA,EACX;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"parser",
|
|
18
18
|
"typescript"
|
|
19
19
|
],
|
|
20
|
-
"version": "0.
|
|
20
|
+
"version": "0.21.0",
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
"leven": "^4.0.0",
|
|
56
56
|
"yaml": "2.8.0",
|
|
57
57
|
"@scalar/openapi-types": "0.3.7",
|
|
58
|
-
"@scalar/json-magic": "0.
|
|
58
|
+
"@scalar/json-magic": "0.5.0",
|
|
59
|
+
"@scalar/openapi-upgrader": "0.1.0"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
62
|
"@apidevtools/swagger-parser": "10.1.0",
|
|
@@ -65,8 +66,8 @@
|
|
|
65
66
|
"just-diff": "^6.0.2",
|
|
66
67
|
"tinybench": "^2.8.0",
|
|
67
68
|
"vite": "7.1.5",
|
|
68
|
-
"@scalar/
|
|
69
|
-
"@scalar/
|
|
69
|
+
"@scalar/build-tooling": "0.2.7",
|
|
70
|
+
"@scalar/types": "0.2.16"
|
|
70
71
|
},
|
|
71
72
|
"scripts": {
|
|
72
73
|
"build": "scalar-build-esbuild",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"escape-json-pointer.d.ts","sourceRoot":"","sources":["../../src/utils/escape-json-pointer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,UAE5C"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/escape-json-pointer.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Escapes a JSON pointer string.\n *\n * Example: `/foo/bar~baz` -> `/foo~1bar~0baz`\n */\nexport function escapeJsonPointer(str: string) {\n return str.replace(/~/g, '~0').replace(/\\//g, '~1')\n}\n"],
|
|
5
|
-
"mappings": "AAKO,SAAS,kBAAkB,KAAa;AAC7C,SAAO,IAAI,QAAQ,MAAM,IAAI,EAAE,QAAQ,OAAO,IAAI;AACpD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
2
|
-
import type { UnknownObject } from '@scalar/types/utils';
|
|
3
|
-
/** Determine if the current path is within a schema - optimized version */
|
|
4
|
-
export declare function isSchemaPath(path: string[]): boolean;
|
|
5
|
-
/**
|
|
6
|
-
* Upgrade from OpenAPI 3.0.x to 3.1.1
|
|
7
|
-
*
|
|
8
|
-
* https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0
|
|
9
|
-
*/
|
|
10
|
-
export declare function upgradeFromThreeToThreeOne(originalContent: UnknownObject): (Omit<Omit<import("@scalar/openapi-types").OpenAPIV3.Document<{}>, "paths" | "components">, keyof {
|
|
11
|
-
[customExtension: `x-${string}`]: any;
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
}> & {
|
|
14
|
-
openapi?: "3.1.0" | "3.1.1";
|
|
15
|
-
swagger?: undefined;
|
|
16
|
-
info?: OpenAPIV3_1.InfoObject;
|
|
17
|
-
jsonSchemaDialect?: string;
|
|
18
|
-
servers?: OpenAPIV3_1.ServerObject[];
|
|
19
|
-
} & Pick<{
|
|
20
|
-
paths?: OpenAPIV3_1.PathsObject<{}, {}>;
|
|
21
|
-
webhooks?: Record<string, OpenAPIV3_1.PathItemObject | OpenAPIV3_1.ReferenceObject>;
|
|
22
|
-
components?: OpenAPIV3_1.ComponentsObject;
|
|
23
|
-
}, "paths"> & Omit<Partial<{
|
|
24
|
-
paths?: OpenAPIV3_1.PathsObject<{}, {}>;
|
|
25
|
-
webhooks?: Record<string, OpenAPIV3_1.PathItemObject | OpenAPIV3_1.ReferenceObject>;
|
|
26
|
-
components?: OpenAPIV3_1.ComponentsObject;
|
|
27
|
-
}>, "paths"> & {
|
|
28
|
-
[customExtension: `x-${string}`]: any;
|
|
29
|
-
[key: string]: any;
|
|
30
|
-
}) | UnknownObject;
|
|
31
|
-
//# sourceMappingURL=upgrade-from-three-to-three-one.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-from-three-to-three-one.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade-from-three-to-three-one.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAgBxD,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAiBpD;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,eAAe,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;mBAcxE"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { traverse } from "./traverse.js";
|
|
2
|
-
const SCHEMA_SEGMENTS = /* @__PURE__ */ new Set([
|
|
3
|
-
"properties",
|
|
4
|
-
"items",
|
|
5
|
-
"allOf",
|
|
6
|
-
"anyOf",
|
|
7
|
-
"oneOf",
|
|
8
|
-
"not",
|
|
9
|
-
"additionalProperties",
|
|
10
|
-
"schema"
|
|
11
|
-
]);
|
|
12
|
-
function isSchemaPath(path) {
|
|
13
|
-
if (path.some((segment) => SCHEMA_SEGMENTS.has(segment))) {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
if (path.some((segment) => segment.endsWith("Schema"))) {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
if (path.length >= 2 && path[0] === "components" && path[1] === "schemas") {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
function upgradeFromThreeToThreeOne(originalContent) {
|
|
25
|
-
let content = originalContent;
|
|
26
|
-
if (content === null || typeof content.openapi !== "string" || !content.openapi.startsWith("3.0")) {
|
|
27
|
-
return content;
|
|
28
|
-
}
|
|
29
|
-
content.openapi = "3.1.1";
|
|
30
|
-
content = traverse(content, applyChangesToDocument);
|
|
31
|
-
return content;
|
|
32
|
-
}
|
|
33
|
-
const applyChangesToDocument = (schema, path) => {
|
|
34
|
-
if (schema.type !== void 0 && schema.nullable === true) {
|
|
35
|
-
schema.type = [schema.type, "null"];
|
|
36
|
-
delete schema.nullable;
|
|
37
|
-
}
|
|
38
|
-
if (schema.exclusiveMinimum === true) {
|
|
39
|
-
schema.exclusiveMinimum = schema.minimum;
|
|
40
|
-
delete schema.minimum;
|
|
41
|
-
} else if (schema.exclusiveMinimum === false) {
|
|
42
|
-
delete schema.exclusiveMinimum;
|
|
43
|
-
}
|
|
44
|
-
if (schema.exclusiveMaximum === true) {
|
|
45
|
-
schema.exclusiveMaximum = schema.maximum;
|
|
46
|
-
delete schema.maximum;
|
|
47
|
-
} else if (schema.exclusiveMaximum === false) {
|
|
48
|
-
delete schema.exclusiveMaximum;
|
|
49
|
-
}
|
|
50
|
-
if (schema.example !== void 0) {
|
|
51
|
-
if (isSchemaPath(path)) {
|
|
52
|
-
schema.examples = [schema.example];
|
|
53
|
-
} else {
|
|
54
|
-
schema.examples = {
|
|
55
|
-
default: {
|
|
56
|
-
value: schema.example
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
delete schema.example;
|
|
61
|
-
}
|
|
62
|
-
if (schema.type === "object" && schema.properties !== void 0) {
|
|
63
|
-
const parentPath = path.slice(0, -1);
|
|
64
|
-
const isMultipart = parentPath.some((segment, index) => {
|
|
65
|
-
return segment === "content" && path[index + 1] === "multipart/form-data";
|
|
66
|
-
});
|
|
67
|
-
if (isMultipart) {
|
|
68
|
-
for (const value of Object.values(schema.properties)) {
|
|
69
|
-
if (typeof value === "object" && value !== null && "type" in value && "format" in value && value.type === "string" && value.format === "binary") {
|
|
70
|
-
;
|
|
71
|
-
value.contentMediaType = "application/octet-stream";
|
|
72
|
-
delete value.format;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (path.includes("content") && path.includes("application/octet-stream")) {
|
|
78
|
-
return {};
|
|
79
|
-
}
|
|
80
|
-
const { format: _, ...rest } = schema;
|
|
81
|
-
if (schema.type === "string") {
|
|
82
|
-
if (schema.format === "binary") {
|
|
83
|
-
return {
|
|
84
|
-
...rest,
|
|
85
|
-
type: "string",
|
|
86
|
-
contentMediaType: "application/octet-stream"
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
if (schema.format === "base64") {
|
|
90
|
-
return {
|
|
91
|
-
...rest,
|
|
92
|
-
type: "string",
|
|
93
|
-
contentEncoding: "base64"
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
if (schema.format === "byte") {
|
|
97
|
-
const parentPath = path.slice(0, -1);
|
|
98
|
-
const contentMediaType = parentPath.find((_2, index) => path[index - 1] === "content");
|
|
99
|
-
return {
|
|
100
|
-
...rest,
|
|
101
|
-
type: "string",
|
|
102
|
-
contentEncoding: "base64",
|
|
103
|
-
contentMediaType
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (schema["x-webhooks"] !== void 0) {
|
|
108
|
-
schema.webhooks = schema["x-webhooks"];
|
|
109
|
-
delete schema["x-webhooks"];
|
|
110
|
-
}
|
|
111
|
-
return schema;
|
|
112
|
-
};
|
|
113
|
-
export {
|
|
114
|
-
isSchemaPath,
|
|
115
|
-
upgradeFromThreeToThreeOne
|
|
116
|
-
};
|
|
117
|
-
//# sourceMappingURL=upgrade-from-three-to-three-one.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/upgrade-from-three-to-three-one.ts"],
|
|
4
|
-
"sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { UnknownObject } from '@scalar/types/utils'\n\nimport { traverse } from './traverse'\n\n// Create Sets for faster schema path lookups\nconst SCHEMA_SEGMENTS = new Set([\n 'properties',\n 'items',\n 'allOf',\n 'anyOf',\n 'oneOf',\n 'not',\n 'additionalProperties',\n 'schema',\n])\n\n/** Determine if the current path is within a schema - optimized version */\nexport function isSchemaPath(path: string[]): boolean {\n // Check for schema segments first (most common case)\n if (path.some((segment) => SCHEMA_SEGMENTS.has(segment))) {\n return true\n }\n\n // Check for schema suffix\n if (path.some((segment) => segment.endsWith('Schema'))) {\n return true\n }\n\n // Check for components/schemas path\n if (path.length >= 2 && path[0] === 'components' && path[1] === 'schemas') {\n return true\n }\n\n return false\n}\n\n/**\n * Upgrade from OpenAPI 3.0.x to 3.1.1\n *\n * https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0\n */\nexport function upgradeFromThreeToThreeOne(originalContent: UnknownObject) {\n let content = originalContent\n\n // Version check - early return if not 3.0.x\n if (content === null || typeof content.openapi !== 'string' || !content.openapi.startsWith('3.0')) {\n return content\n }\n\n content.openapi = '3.1.1'\n\n // Single traversal that handles all transformations\n content = traverse(content, applyChangesToDocument)\n\n return content as OpenAPIV3_1.Document\n}\n\nconst applyChangesToDocument = (schema: UnknownObject, path: string[]) => {\n // 1. Handle nullable types\n if (schema.type !== undefined && schema.nullable === true) {\n schema.type = [schema.type, 'null']\n delete schema.nullable\n }\n\n // 2. Handle exclusiveMinimum and exclusiveMaximum\n if (schema.exclusiveMinimum === true) {\n schema.exclusiveMinimum = schema.minimum\n delete schema.minimum\n } else if (schema.exclusiveMinimum === false) {\n delete schema.exclusiveMinimum\n }\n\n if (schema.exclusiveMaximum === true) {\n schema.exclusiveMaximum = schema.maximum\n delete schema.maximum\n } else if (schema.exclusiveMaximum === false) {\n delete schema.exclusiveMaximum\n }\n\n // 3. Handle examples\n if (schema.example !== undefined) {\n if (isSchemaPath(path)) {\n schema.examples = [schema.example]\n } else {\n schema.examples = {\n default: {\n value: schema.example,\n },\n }\n }\n delete schema.example\n }\n\n // 4. Handle multipart file uploads\n if (schema.type === 'object' && schema.properties !== undefined) {\n const parentPath = path.slice(0, -1)\n const isMultipart = parentPath.some((segment, index) => {\n return segment === 'content' && path[index + 1] === 'multipart/form-data'\n })\n\n if (isMultipart) {\n for (const value of Object.values(schema.properties)) {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'type' in value &&\n 'format' in value &&\n value.type === 'string' &&\n value.format === 'binary'\n ) {\n ;(value as any).contentMediaType = 'application/octet-stream'\n delete (value as any).format\n }\n }\n }\n }\n\n // 5. Handle binary file uploads\n if (path.includes('content') && path.includes('application/octet-stream')) {\n return {}\n }\n\n // 6. Handle older formats\n const { format: _, ...rest } = schema\n\n if (schema.type === 'string') {\n if (schema.format === 'binary') {\n return {\n ...rest,\n type: 'string',\n contentMediaType: 'application/octet-stream',\n }\n }\n\n if (schema.format === 'base64') {\n return {\n ...rest,\n type: 'string',\n contentEncoding: 'base64',\n }\n }\n\n if (schema.format === 'byte') {\n const parentPath = path.slice(0, -1)\n const contentMediaType = parentPath.find((_, index) => path[index - 1] === 'content')\n return {\n ...rest,\n type: 'string',\n contentEncoding: 'base64',\n contentMediaType,\n }\n }\n }\n\n // 7. Handle x-webhooks\n if (schema['x-webhooks'] !== undefined) {\n schema.webhooks = schema['x-webhooks']\n delete schema['x-webhooks']\n }\n\n return schema\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,gBAAgB;AAGzB,MAAM,kBAAkB,oBAAI,IAAI;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,SAAS,aAAa,MAAyB;AAEpD,MAAI,KAAK,KAAK,CAAC,YAAY,gBAAgB,IAAI,OAAO,CAAC,GAAG;AACxD,WAAO;AAAA,EACT;AAGA,MAAI,KAAK,KAAK,CAAC,YAAY,QAAQ,SAAS,QAAQ,CAAC,GAAG;AACtD,WAAO;AAAA,EACT;AAGA,MAAI,KAAK,UAAU,KAAK,KAAK,CAAC,MAAM,gBAAgB,KAAK,CAAC,MAAM,WAAW;AACzE,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAOO,SAAS,2BAA2B,iBAAgC;AACzE,MAAI,UAAU;AAGd,MAAI,YAAY,QAAQ,OAAO,QAAQ,YAAY,YAAY,CAAC,QAAQ,QAAQ,WAAW,KAAK,GAAG;AACjG,WAAO;AAAA,EACT;AAEA,UAAQ,UAAU;AAGlB,YAAU,SAAS,SAAS,sBAAsB;AAElD,SAAO;AACT;AAEA,MAAM,yBAAyB,CAAC,QAAuB,SAAmB;AAExE,MAAI,OAAO,SAAS,UAAa,OAAO,aAAa,MAAM;AACzD,WAAO,OAAO,CAAC,OAAO,MAAM,MAAM;AAClC,WAAO,OAAO;AA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AAG;AAAA,QACH,MAAM;AAAA,QACN,kBAAkB;AAAA,MACpB;AAAA,IACF;AAEA,QAAI,OAAO,WAAW,UAAU;AAC9B,aAAO;AAAA,QACL,GAAG;AAAA,QACH,MAAM;AAAA,QACN,iBAAiB;AAAA,MACnB;AAAA,IACF;AAEA,QAAI,OAAO,WAAW,QAAQ;AAC5B,YAAM,aAAa,KAAK,MAAM,GAAG,EAAE;AACnC,YAAM,mBAAmB,WAAW,KAAK,CAACA,IAAG,UAAU,KAAK,QAAQ,CAAC,MAAM,SAAS;AACpF,aAAO;AAAA,QACL,GAAG;AAAA,QACH,MAAM;AAAA,QACN,iBAAiB;AAAA,QACjB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,MAAI,OAAO,YAAY,MAAM,QAAW;AACtC,WAAO,WAAW,OAAO,YAAY;AACrC,WAAO,OAAO,YAAY;AAAA,EAC5B;AAEA,SAAO;AACT;",
|
|
6
|
-
"names": ["_"]
|
|
7
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIV3 } from '@scalar/openapi-types';
|
|
2
|
-
import type { UnknownObject } from '@scalar/types/utils';
|
|
3
|
-
/**
|
|
4
|
-
* Upgrade Swagger 2.0 to OpenAPI 3.0
|
|
5
|
-
*
|
|
6
|
-
* https://swagger.io/blog/news/whats-new-in-openapi-3-0/
|
|
7
|
-
*/
|
|
8
|
-
export declare function upgradeFromTwoToThree(originalSpecification: UnknownObject): OpenAPIV3.Document<{}> | UnknownObject;
|
|
9
|
-
//# sourceMappingURL=upgrade-from-two-to-three.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-from-two-to-three.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade-from-two-to-three.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAoBxD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,qBAAqB,EAAE,aAAa,0CA6PzE"}
|
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
import { traverse } from "./traverse.js";
|
|
2
|
-
const upgradeFlow = (flow) => {
|
|
3
|
-
switch (flow) {
|
|
4
|
-
case "application":
|
|
5
|
-
return "clientCredentials";
|
|
6
|
-
case "accessCode":
|
|
7
|
-
return "authorizationCode";
|
|
8
|
-
case "implicit":
|
|
9
|
-
return "implicit";
|
|
10
|
-
case "password":
|
|
11
|
-
return "password";
|
|
12
|
-
default:
|
|
13
|
-
return flow;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
function upgradeFromTwoToThree(originalSpecification) {
|
|
17
|
-
let specification = originalSpecification;
|
|
18
|
-
if (specification !== null && typeof specification === "object" && typeof specification.swagger === "string" && specification.swagger?.startsWith("2.0")) {
|
|
19
|
-
specification.openapi = "3.0.4";
|
|
20
|
-
delete specification.swagger;
|
|
21
|
-
} else {
|
|
22
|
-
return specification;
|
|
23
|
-
}
|
|
24
|
-
if (specification.host) {
|
|
25
|
-
const schemes = Array.isArray(specification.schemes) && specification.schemes?.length ? specification.schemes : ["http"];
|
|
26
|
-
specification.servers = schemes.map((scheme) => ({
|
|
27
|
-
url: `${scheme}://${specification.host}${specification.basePath ?? ""}`
|
|
28
|
-
}));
|
|
29
|
-
delete specification.basePath;
|
|
30
|
-
delete specification.schemes;
|
|
31
|
-
delete specification.host;
|
|
32
|
-
} else if (specification.basePath) {
|
|
33
|
-
specification.servers = [{ url: specification.basePath }];
|
|
34
|
-
delete specification.basePath;
|
|
35
|
-
}
|
|
36
|
-
if (specification.definitions) {
|
|
37
|
-
specification.components = Object.assign({}, specification.components, {
|
|
38
|
-
schemas: specification.definitions
|
|
39
|
-
});
|
|
40
|
-
delete specification.definitions;
|
|
41
|
-
specification = traverse(specification, (schema) => {
|
|
42
|
-
if (typeof schema.$ref === "string" && schema.$ref.startsWith("#/definitions/")) {
|
|
43
|
-
schema.$ref = schema.$ref.replace(/^#\/definitions\//, "#/components/schemas/");
|
|
44
|
-
}
|
|
45
|
-
return schema;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
specification = traverse(specification, (schema) => {
|
|
49
|
-
if (schema.type === "file") {
|
|
50
|
-
schema.type = "string";
|
|
51
|
-
schema.format = "binary";
|
|
52
|
-
}
|
|
53
|
-
return schema;
|
|
54
|
-
});
|
|
55
|
-
if (Object.hasOwn(specification, "parameters")) {
|
|
56
|
-
specification = traverse(specification, (schema) => {
|
|
57
|
-
if (typeof schema.$ref === "string" && schema.$ref.startsWith("#/parameters/")) {
|
|
58
|
-
const schemaName = schema.$ref.split("/")[2];
|
|
59
|
-
const param = specification.parameters?.[schemaName];
|
|
60
|
-
if (param?.in === "body" || param?.in === "formData") {
|
|
61
|
-
schema.$ref = schema.$ref.replace(/^#\/parameters\//, "#/components/requestBodies/");
|
|
62
|
-
} else {
|
|
63
|
-
schema.$ref = schema.$ref.replace(/^#\/parameters\//, "#/components/parameters/");
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return schema;
|
|
67
|
-
});
|
|
68
|
-
specification.components ??= {};
|
|
69
|
-
const params = {};
|
|
70
|
-
const bodyParams = {};
|
|
71
|
-
for (const [name, param] of Object.entries(specification.parameters ?? {})) {
|
|
72
|
-
if (param.in === "body") {
|
|
73
|
-
bodyParams[name] = migrateBodyParameter(
|
|
74
|
-
param,
|
|
75
|
-
specification.consumes ?? ["application/json"]
|
|
76
|
-
);
|
|
77
|
-
} else if (param.in === "formData") {
|
|
78
|
-
bodyParams[name] = migrateFormDataParameter(param);
|
|
79
|
-
} else {
|
|
80
|
-
params[name] = transformParameterObject(param);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (Object.keys(params).length > 0) {
|
|
84
|
-
;
|
|
85
|
-
specification.components.parameters = params;
|
|
86
|
-
}
|
|
87
|
-
if (Object.keys(bodyParams).length > 0) {
|
|
88
|
-
;
|
|
89
|
-
specification.components.requestBodies = bodyParams;
|
|
90
|
-
}
|
|
91
|
-
delete specification.parameters;
|
|
92
|
-
}
|
|
93
|
-
if (typeof specification.paths === "object") {
|
|
94
|
-
for (const path in specification.paths) {
|
|
95
|
-
if (Object.hasOwn(specification.paths, path)) {
|
|
96
|
-
const pathItem = specification.paths[path];
|
|
97
|
-
let requestBodyObject;
|
|
98
|
-
for (const methodOrParameters in pathItem) {
|
|
99
|
-
if (methodOrParameters === "parameters" && Object.hasOwn(pathItem, methodOrParameters)) {
|
|
100
|
-
const pathItemParameters = migrateParameters(
|
|
101
|
-
pathItem.parameters,
|
|
102
|
-
specification.consumes ?? ["application/json"]
|
|
103
|
-
);
|
|
104
|
-
pathItem.parameters = pathItemParameters.parameters;
|
|
105
|
-
requestBodyObject = pathItemParameters.requestBody;
|
|
106
|
-
} else if (Object.hasOwn(pathItem, methodOrParameters)) {
|
|
107
|
-
const operationItem = pathItem[methodOrParameters];
|
|
108
|
-
if (requestBodyObject) {
|
|
109
|
-
operationItem.requestBody = requestBodyObject;
|
|
110
|
-
}
|
|
111
|
-
if (operationItem.parameters) {
|
|
112
|
-
const migrationResult = migrateParameters(
|
|
113
|
-
operationItem.parameters,
|
|
114
|
-
operationItem.consumes ?? specification.consumes ?? ["application/json"]
|
|
115
|
-
);
|
|
116
|
-
operationItem.parameters = migrationResult.parameters;
|
|
117
|
-
if (migrationResult.requestBody) {
|
|
118
|
-
operationItem.requestBody = migrationResult.requestBody;
|
|
119
|
-
}
|
|
120
|
-
delete operationItem.consumes;
|
|
121
|
-
}
|
|
122
|
-
if (operationItem.responses) {
|
|
123
|
-
for (const response in operationItem.responses) {
|
|
124
|
-
if (Object.hasOwn(operationItem.responses, response)) {
|
|
125
|
-
const responseItem = operationItem.responses[response];
|
|
126
|
-
if (responseItem.headers) {
|
|
127
|
-
responseItem.headers = Object.entries(responseItem.headers).reduce((acc, [name, header]) => {
|
|
128
|
-
return {
|
|
129
|
-
[name]: transformParameterObject(header),
|
|
130
|
-
...acc
|
|
131
|
-
};
|
|
132
|
-
}, {});
|
|
133
|
-
}
|
|
134
|
-
if (responseItem.schema) {
|
|
135
|
-
const produces = specification.produces ?? operationItem.produces ?? ["application/json"];
|
|
136
|
-
if (typeof responseItem.content !== "object") {
|
|
137
|
-
responseItem.content = {};
|
|
138
|
-
}
|
|
139
|
-
for (const type of produces) {
|
|
140
|
-
responseItem.content[type] = {
|
|
141
|
-
schema: responseItem.schema
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
delete responseItem.schema;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
delete operationItem.produces;
|
|
150
|
-
if (operationItem.parameters?.length === 0) {
|
|
151
|
-
delete operationItem.parameters;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (specification.securityDefinitions) {
|
|
159
|
-
if (typeof specification.components !== "object") {
|
|
160
|
-
specification.components = {};
|
|
161
|
-
}
|
|
162
|
-
specification.components = specification.components;
|
|
163
|
-
Object.assign(specification.components, { securitySchemes: {} });
|
|
164
|
-
for (const [key, securityScheme] of Object.entries(specification.securityDefinitions)) {
|
|
165
|
-
if (typeof securityScheme === "object") {
|
|
166
|
-
if ("type" in securityScheme && securityScheme.type === "oauth2") {
|
|
167
|
-
const { flow, authorizationUrl, tokenUrl, scopes } = securityScheme;
|
|
168
|
-
Object.assign(specification.components.securitySchemes, {
|
|
169
|
-
[key]: {
|
|
170
|
-
type: "oauth2",
|
|
171
|
-
flows: {
|
|
172
|
-
[upgradeFlow(flow)]: Object.assign(
|
|
173
|
-
{},
|
|
174
|
-
authorizationUrl && { authorizationUrl },
|
|
175
|
-
tokenUrl && { tokenUrl },
|
|
176
|
-
scopes && { scopes }
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
} else if ("type" in securityScheme && securityScheme.type === "basic") {
|
|
182
|
-
Object.assign(specification.components.securitySchemes, {
|
|
183
|
-
[key]: {
|
|
184
|
-
type: "http",
|
|
185
|
-
scheme: "basic"
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
} else {
|
|
189
|
-
Object.assign(specification.components.securitySchemes, {
|
|
190
|
-
[key]: securityScheme
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
delete specification.securityDefinitions;
|
|
196
|
-
}
|
|
197
|
-
delete specification.consumes;
|
|
198
|
-
delete specification.produces;
|
|
199
|
-
return specification;
|
|
200
|
-
}
|
|
201
|
-
function transformItemsObject(obj) {
|
|
202
|
-
const schemaProperties = [
|
|
203
|
-
"type",
|
|
204
|
-
"format",
|
|
205
|
-
"items",
|
|
206
|
-
"maximum",
|
|
207
|
-
"exclusiveMaximum",
|
|
208
|
-
"minimum",
|
|
209
|
-
"exclusiveMinimum",
|
|
210
|
-
"maxLength",
|
|
211
|
-
"minLength",
|
|
212
|
-
"pattern",
|
|
213
|
-
"maxItems",
|
|
214
|
-
"minItems",
|
|
215
|
-
"uniqueItems",
|
|
216
|
-
"enum",
|
|
217
|
-
"multipleOf"
|
|
218
|
-
];
|
|
219
|
-
return schemaProperties.reduce((acc, property) => {
|
|
220
|
-
if (Object.hasOwn(obj, property)) {
|
|
221
|
-
acc[property] = obj[property];
|
|
222
|
-
delete obj[property];
|
|
223
|
-
}
|
|
224
|
-
return acc;
|
|
225
|
-
}, {});
|
|
226
|
-
}
|
|
227
|
-
function transformParameterObject(parameter) {
|
|
228
|
-
const serializationStyle = getParameterSerializationStyle(parameter);
|
|
229
|
-
const schema = transformItemsObject(parameter);
|
|
230
|
-
delete parameter.collectionFormat;
|
|
231
|
-
delete parameter.default;
|
|
232
|
-
return {
|
|
233
|
-
schema,
|
|
234
|
-
...serializationStyle,
|
|
235
|
-
...parameter
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
const querySerialization = {
|
|
239
|
-
ssv: {
|
|
240
|
-
style: "spaceDelimited",
|
|
241
|
-
explode: false
|
|
242
|
-
},
|
|
243
|
-
pipes: {
|
|
244
|
-
style: "pipeDelimited",
|
|
245
|
-
explode: false
|
|
246
|
-
},
|
|
247
|
-
multi: {
|
|
248
|
-
style: "form",
|
|
249
|
-
explode: true
|
|
250
|
-
},
|
|
251
|
-
csv: {
|
|
252
|
-
style: "form",
|
|
253
|
-
explode: false
|
|
254
|
-
},
|
|
255
|
-
tsv: {}
|
|
256
|
-
};
|
|
257
|
-
const pathAndHeaderSerialization = {
|
|
258
|
-
ssv: {},
|
|
259
|
-
pipes: {},
|
|
260
|
-
multi: {},
|
|
261
|
-
csv: {
|
|
262
|
-
style: "simple",
|
|
263
|
-
explode: false
|
|
264
|
-
},
|
|
265
|
-
tsv: {}
|
|
266
|
-
};
|
|
267
|
-
const serializationStyles = {
|
|
268
|
-
header: pathAndHeaderSerialization,
|
|
269
|
-
query: querySerialization,
|
|
270
|
-
path: pathAndHeaderSerialization
|
|
271
|
-
};
|
|
272
|
-
function getParameterSerializationStyle(parameter) {
|
|
273
|
-
if (parameter.type !== "array" || !(parameter.in === "query" || parameter.in === "path" || parameter.in === "header")) {
|
|
274
|
-
return {};
|
|
275
|
-
}
|
|
276
|
-
const collectionFormat = parameter.collectionFormat ?? "csv";
|
|
277
|
-
return serializationStyles[parameter.in][collectionFormat];
|
|
278
|
-
}
|
|
279
|
-
function migrateBodyParameter(bodyParameter, consumes) {
|
|
280
|
-
delete bodyParameter.name;
|
|
281
|
-
delete bodyParameter.in;
|
|
282
|
-
const { schema, ...requestBody } = bodyParameter;
|
|
283
|
-
const requestBodyObject = {
|
|
284
|
-
content: {},
|
|
285
|
-
...requestBody
|
|
286
|
-
};
|
|
287
|
-
for (const type of consumes) {
|
|
288
|
-
requestBodyObject.content[type] = {
|
|
289
|
-
schema
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
return requestBodyObject;
|
|
293
|
-
}
|
|
294
|
-
function migrateFormDataParameter(parameters) {
|
|
295
|
-
const requestBodyObject = {
|
|
296
|
-
content: {}
|
|
297
|
-
};
|
|
298
|
-
requestBodyObject.content["application/x-www-form-urlencoded"] = {
|
|
299
|
-
schema: {
|
|
300
|
-
type: "object",
|
|
301
|
-
properties: {},
|
|
302
|
-
required: []
|
|
303
|
-
// Initialize required array
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
for (const param of parameters) {
|
|
307
|
-
requestBodyObject.content["application/x-www-form-urlencoded"].schema.properties[param.name] = {
|
|
308
|
-
type: param.type,
|
|
309
|
-
description: param.description
|
|
310
|
-
};
|
|
311
|
-
if (param.required) {
|
|
312
|
-
requestBodyObject.content["application/x-www-form-urlencoded"].schema.required.push(param.name);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
return requestBodyObject;
|
|
316
|
-
}
|
|
317
|
-
function migrateParameters(parameters, consumes) {
|
|
318
|
-
const result = {
|
|
319
|
-
parameters: parameters.filter((parameter) => !(parameter.in === "body" || parameter.in === "formData")).map((parameter) => transformParameterObject(parameter))
|
|
320
|
-
};
|
|
321
|
-
const bodyParameter = structuredClone(
|
|
322
|
-
parameters.find((parameter) => parameter.in === "body") ?? {}
|
|
323
|
-
);
|
|
324
|
-
if (bodyParameter && Object.keys(bodyParameter).length) {
|
|
325
|
-
result.requestBody = migrateBodyParameter(bodyParameter, consumes);
|
|
326
|
-
}
|
|
327
|
-
const formDataParameters = parameters.filter((parameter) => parameter.in === "formData");
|
|
328
|
-
if (formDataParameters.length > 0) {
|
|
329
|
-
const requestBodyObject = migrateFormDataParameter(formDataParameters);
|
|
330
|
-
if (typeof result.requestBody !== "object") {
|
|
331
|
-
result.requestBody = requestBodyObject;
|
|
332
|
-
} else {
|
|
333
|
-
result.requestBody = {
|
|
334
|
-
...result.requestBody,
|
|
335
|
-
content: {
|
|
336
|
-
...result.requestBody.content,
|
|
337
|
-
...requestBodyObject.content
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
if (typeof result.requestBody !== "object") {
|
|
342
|
-
result.requestBody = {
|
|
343
|
-
content: {}
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return result;
|
|
348
|
-
}
|
|
349
|
-
export {
|
|
350
|
-
upgradeFromTwoToThree
|
|
351
|
-
};
|
|
352
|
-
//# sourceMappingURL=upgrade-from-two-to-three.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/upgrade-from-two-to-three.ts"],
|
|
4
|
-
"sourcesContent": ["import type { OpenAPIV2, OpenAPIV3 } from '@scalar/openapi-types'\nimport type { UnknownObject } from '@scalar/types/utils'\n\nimport { traverse } from './traverse'\n\n/** Update the flow names to OpenAPI 3.1.0 format */\nconst upgradeFlow = (flow: string): 'implicit' | 'password' | 'clientCredentials' | 'authorizationCode' => {\n switch (flow) {\n case 'application':\n return 'clientCredentials'\n case 'accessCode':\n return 'authorizationCode'\n case 'implicit':\n return 'implicit'\n case 'password':\n return 'password'\n default:\n return flow as never\n }\n}\n\n/**\n * Upgrade Swagger 2.0 to OpenAPI 3.0\n *\n * https://swagger.io/blog/news/whats-new-in-openapi-3-0/\n */\nexport function upgradeFromTwoToThree(originalSpecification: UnknownObject) {\n let specification = originalSpecification\n\n // Version\n if (\n specification !== null &&\n typeof specification === 'object' &&\n typeof specification.swagger === 'string' &&\n specification.swagger?.startsWith('2.0')\n ) {\n specification.openapi = '3.0.4'\n delete specification.swagger\n } else {\n // Skip if it's something else than 3.0.x\n return specification\n }\n\n // Servers\n if (specification.host) {\n const schemes =\n Array.isArray(specification.schemes) && specification.schemes?.length ? specification.schemes : ['http']\n\n specification.servers = schemes.map((scheme: string[]) => ({\n url: `${scheme}://${specification.host}${specification.basePath ?? ''}`,\n }))\n\n delete specification.basePath\n delete specification.schemes\n delete specification.host\n } else if (specification.basePath) {\n specification.servers = [{ url: specification.basePath }]\n delete specification.basePath\n }\n\n // Schemas\n if (specification.definitions) {\n specification.components = Object.assign({}, specification.components, {\n schemas: specification.definitions,\n })\n\n delete specification.definitions\n\n // Rewrite $refs to definitions\n specification = traverse(specification, (schema) => {\n // Rewrite $refs to components\n if (typeof schema.$ref === 'string' && schema.$ref.startsWith('#/definitions/')) {\n schema.$ref = schema.$ref.replace(/^#\\/definitions\\//, '#/components/schemas/')\n }\n\n return schema\n })\n }\n\n // Transform file type to string with binary format\n specification = traverse(specification, (schema) => {\n if (schema.type === 'file') {\n schema.type = 'string'\n schema.format = 'binary'\n }\n\n return schema\n })\n\n if (Object.hasOwn(specification, 'parameters')) {\n // update all the $refs before we do any transformations\n specification = traverse(specification, (schema) => {\n if (typeof schema.$ref === 'string' && schema.$ref.startsWith('#/parameters/')) {\n const schemaName = schema.$ref.split('/')[2]\n\n const param = specification.parameters?.[schemaName]\n\n if (param?.in === 'body' || param?.in === 'formData') {\n schema.$ref = schema.$ref.replace(/^#\\/parameters\\//, '#/components/requestBodies/')\n } else {\n schema.$ref = schema.$ref.replace(/^#\\/parameters\\//, '#/components/parameters/')\n }\n }\n\n return schema\n })\n\n specification.components ??= {}\n\n const params = {}\n const bodyParams = {}\n for (const [name, param] of Object.entries(specification.parameters ?? {})) {\n if (param.in === 'body') {\n bodyParams[name] = migrateBodyParameter(\n param,\n (specification.consumes as string[] | undefined) ?? ['application/json'],\n )\n } else if (param.in === 'formData') {\n bodyParams[name] = migrateFormDataParameter(param)\n } else {\n params[name] = transformParameterObject(param)\n }\n }\n\n if (Object.keys(params).length > 0) {\n ;(specification.components as UnknownObject).parameters = params\n }\n\n if (Object.keys(bodyParams).length > 0) {\n ;(specification.components as UnknownObject).requestBodies = bodyParams\n }\n\n delete specification.parameters\n }\n\n // Paths\n if (typeof specification.paths === 'object') {\n for (const path in specification.paths) {\n if (Object.hasOwn(specification.paths, path)) {\n const pathItem = specification.paths[path]\n\n let requestBodyObject: OpenAPIV3.RequestBodyObject | undefined\n\n for (const methodOrParameters in pathItem) {\n if (methodOrParameters === 'parameters' && Object.hasOwn(pathItem, methodOrParameters)) {\n const pathItemParameters = migrateParameters(\n pathItem.parameters,\n (specification.consumes as string[] | undefined) ?? ['application/json'],\n )\n\n pathItem.parameters = pathItemParameters.parameters\n requestBodyObject = pathItemParameters.requestBody\n } else if (Object.hasOwn(pathItem, methodOrParameters)) {\n const operationItem = pathItem[methodOrParameters]\n\n if (requestBodyObject) {\n operationItem.requestBody = requestBodyObject\n }\n\n if (operationItem.parameters) {\n const migrationResult = migrateParameters(\n operationItem.parameters,\n operationItem.consumes ?? specification.consumes ?? ['application/json'],\n )\n\n operationItem.parameters = migrationResult.parameters\n\n if (migrationResult.requestBody) {\n operationItem.requestBody = migrationResult.requestBody\n }\n\n delete operationItem.consumes\n }\n\n // Responses\n if (operationItem.responses) {\n for (const response in operationItem.responses) {\n if (Object.hasOwn(operationItem.responses, response)) {\n const responseItem = operationItem.responses[response]\n\n if (responseItem.headers) {\n responseItem.headers = Object.entries(responseItem.headers).reduce((acc, [name, header]) => {\n return {\n [name]: transformParameterObject(header),\n ...acc,\n }\n }, {})\n }\n if (responseItem.schema) {\n const produces = specification.produces ?? operationItem.produces ?? ['application/json']\n\n if (typeof responseItem.content !== 'object') {\n responseItem.content = {}\n }\n\n for (const type of produces) {\n responseItem.content[type] = {\n schema: responseItem.schema,\n }\n }\n\n delete responseItem.schema\n }\n }\n }\n }\n\n delete operationItem.produces\n\n // Delete empty parameters\n if (operationItem.parameters?.length === 0) {\n delete operationItem.parameters\n }\n }\n }\n }\n }\n }\n\n // Upgrade securityDefinitions\n if (specification.securityDefinitions) {\n if (typeof specification.components !== 'object') {\n specification.components = {}\n }\n\n // Assert that components is of type OpenAPIV3.ComponentsObject\n specification.components = specification.components as OpenAPIV3.ComponentsObject\n\n Object.assign(specification.components, { securitySchemes: {} })\n\n for (const [key, securityScheme] of Object.entries(specification.securityDefinitions)) {\n if (typeof securityScheme === 'object') {\n if ('type' in securityScheme && securityScheme.type === 'oauth2') {\n const { flow, authorizationUrl, tokenUrl, scopes } = securityScheme as {\n type: 'oauth2'\n flow?: string\n authorizationUrl?: string\n tokenUrl?: string\n scopes?: Record<string, string>\n }\n\n // Convert flow values to OpenAPI 3.1.0 format\n\n // Assert that securitySchemes is of type OpenAPIV3.SecuritySchemeObject\n Object.assign((specification.components as OpenAPIV3.ComponentsObject).securitySchemes, {\n [key]: {\n type: 'oauth2',\n flows: {\n [upgradeFlow(flow)]: Object.assign(\n {},\n authorizationUrl && { authorizationUrl },\n tokenUrl && { tokenUrl },\n scopes && { scopes },\n ),\n },\n },\n })\n } else if ('type' in securityScheme && securityScheme.type === 'basic') {\n Object.assign((specification.components as OpenAPIV3.ComponentsObject).securitySchemes, {\n [key]: {\n type: 'http',\n scheme: 'basic',\n },\n })\n } else {\n Object.assign((specification.components as OpenAPIV3.ComponentsObject).securitySchemes, {\n [key]: securityScheme,\n })\n }\n }\n }\n\n delete specification.securityDefinitions\n }\n\n delete specification.consumes\n delete specification.produces\n\n return specification as OpenAPIV3.Document\n}\n\nfunction transformItemsObject<T extends Record<PropertyKey, unknown>>(obj: T): OpenAPIV3.SchemaObject {\n const schemaProperties = [\n 'type',\n 'format',\n 'items',\n 'maximum',\n 'exclusiveMaximum',\n 'minimum',\n 'exclusiveMinimum',\n 'maxLength',\n 'minLength',\n 'pattern',\n 'maxItems',\n 'minItems',\n 'uniqueItems',\n 'enum',\n 'multipleOf',\n ]\n\n return schemaProperties.reduce((acc, property) => {\n if (Object.hasOwn(obj, property)) {\n acc[property] = obj[property]\n delete obj[property]\n }\n\n return acc\n }, {} as OpenAPIV3.SchemaObject)\n}\n\nfunction transformParameterObject(parameter: OpenAPIV2.ParameterObject): OpenAPIV3.ParameterObject {\n // it is important to call getParameterSerializationStyle first because transformItemsObject modifies properties on which getParameterSerializationStyle rely on\n const serializationStyle = getParameterSerializationStyle(parameter)\n const schema = transformItemsObject(parameter)\n\n delete parameter.collectionFormat\n delete parameter.default\n\n return {\n schema,\n ...serializationStyle,\n ...parameter,\n }\n}\n\ntype CollectionFormat = 'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi'\n\ntype ParameterSerializationStyle = { style?: string; explode?: boolean }\n\nconst querySerialization: Record<CollectionFormat, ParameterSerializationStyle> = {\n ssv: {\n style: 'spaceDelimited',\n explode: false,\n },\n pipes: {\n style: 'pipeDelimited',\n explode: false,\n },\n multi: {\n style: 'form',\n explode: true,\n },\n csv: {\n style: 'form',\n explode: false,\n },\n tsv: {},\n}\n\nconst pathAndHeaderSerialization: Record<CollectionFormat, ParameterSerializationStyle> = {\n ssv: {},\n pipes: {},\n multi: {},\n csv: {\n style: 'simple',\n explode: false,\n },\n tsv: {},\n}\n\nconst serializationStyles = {\n header: pathAndHeaderSerialization,\n query: querySerialization,\n path: pathAndHeaderSerialization,\n} as const\n\nfunction getParameterSerializationStyle(parameter: OpenAPIV2.ParameterObject): ParameterSerializationStyle {\n if (\n parameter.type !== 'array' ||\n !(parameter.in === 'query' || parameter.in === 'path' || parameter.in === 'header')\n ) {\n return {}\n }\n\n const collectionFormat = parameter.collectionFormat ?? 'csv'\n\n return serializationStyles[parameter.in][collectionFormat]\n}\n\ntype ParameterMigrationResult = {\n parameters: OpenAPIV3.ParameterObject[]\n requestBody?: OpenAPIV3.RequestBodyObject\n}\n\nfunction migrateBodyParameter(\n bodyParameter: OpenAPIV2.ParameterObject,\n consumes: string[],\n): OpenAPIV3.RequestBodyObject {\n delete bodyParameter.name\n delete bodyParameter.in\n\n const { schema, ...requestBody } = bodyParameter\n\n const requestBodyObject: OpenAPIV3.RequestBodyObject = {\n content: {},\n ...requestBody,\n }\n\n for (const type of consumes) {\n requestBodyObject.content[type] = {\n schema: schema,\n }\n }\n\n return requestBodyObject\n}\n\nfunction migrateFormDataParameter(parameters: OpenAPIV2.ParameterObject[]): OpenAPIV3.RequestBodyObject {\n const requestBodyObject: OpenAPIV3.RequestBodyObject = {\n content: {},\n }\n\n requestBodyObject.content['application/x-www-form-urlencoded'] = {\n schema: {\n type: 'object',\n properties: {},\n required: [], // Initialize required array\n },\n }\n\n for (const param of parameters) {\n requestBodyObject.content['application/x-www-form-urlencoded'].schema.properties[param.name] = {\n type: param.type,\n description: param.description,\n }\n\n // Add to required array if param is required\n if (param.required) {\n requestBodyObject.content['application/x-www-form-urlencoded'].schema.required.push(param.name)\n }\n }\n\n return requestBodyObject\n}\n\nfunction migrateParameters(parameters: OpenAPIV2.ParameterObject[], consumes: string[]): ParameterMigrationResult {\n const result: ParameterMigrationResult = {\n parameters: parameters\n .filter((parameter) => !(parameter.in === 'body' || parameter.in === 'formData'))\n .map((parameter) => transformParameterObject(parameter)),\n }\n\n const bodyParameter = structuredClone(\n parameters.find((parameter: OpenAPIV3.ParameterObject) => parameter.in === 'body') ?? {},\n )\n\n if (bodyParameter && Object.keys(bodyParameter).length) {\n result.requestBody = migrateBodyParameter(bodyParameter, consumes)\n }\n\n const formDataParameters = parameters.filter((parameter: OpenAPIV2.ParameterObject) => parameter.in === 'formData')\n\n if (formDataParameters.length > 0) {\n const requestBodyObject = migrateFormDataParameter(formDataParameters)\n\n if (typeof result.requestBody !== 'object') {\n result.requestBody = requestBodyObject\n } else {\n result.requestBody = {\n ...result.requestBody,\n content: {\n ...result.requestBody.content,\n ...requestBodyObject.content,\n },\n }\n }\n\n if (typeof result.requestBody !== 'object') {\n result.requestBody = {\n content: {},\n }\n }\n }\n\n return result\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,gBAAgB;AAGzB,MAAM,cAAc,CAAC,SAAsF;AACzG,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAOO,SAAS,sBAAsB,uBAAsC;AAC1E,MAAI,gBAAgB;AAGpB,MACE,kBAAkB,QAClB,OAAO,kB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cAAc,yBAAyB,SAAS,CAAC;AAAA,EAC3D;AAEA,QAAM,gBAAgB;AAAA,IACpB,WAAW,KAAK,CAAC,cAAyC,UAAU,OAAO,MAAM,KAAK,CAAC;AAAA,EACzF;AAEA,MAAI,iBAAiB,OAAO,KAAK,aAAa,EAAE,QAAQ;AACtD,WAAO,cAAc,qBAAqB,eAAe,QAAQ;AAAA,EACnE;AAEA,QAAM,qBAAqB,WAAW,OAAO,CAAC,cAAyC,UAAU,OAAO,UAAU;AAElH,MAAI,mBAAmB,SAAS,GAAG;AACjC,UAAM,oBAAoB,yBAAyB,kBAAkB;AAErE,QAAI,OAAO,OAAO,gBAAgB,UAAU;AAC1C,aAAO,cAAc;AAAA,IACvB,OAAO;AACL,aAAO,cAAc;AAAA,QACnB,GAAG,OAAO;AAAA,QACV,SAAS;AAAA,UACP,GAAG,OAAO,YAAY;AAAA,UACtB,GAAG,kBAAkB;AAAA,QACvB;AAAA,MACF;AAAA,IACF;AAEA,QAAI,OAAO,OAAO,gBAAgB,UAAU;AAC1C,aAAO,cAAc;AAAA,QACnB,SAAS,CAAC;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.bench.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade.bench.ts"],"names":[],"mappings":""}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { bench, describe, expect } from "vitest";
|
|
2
|
-
import { upgrade } from "./upgrade.js";
|
|
3
|
-
import { upgradeFromTwoToThree } from "./upgrade-from-two-to-three.js";
|
|
4
|
-
const STRIPE = await fetch(
|
|
5
|
-
"https://raw.githubusercontent.com/stripe/openapi/refs/heads/master/openapi/spec3.json"
|
|
6
|
-
).then((r) => r.json());
|
|
7
|
-
const PETSTORE = await fetch("https://petstore.swagger.io/v2/swagger.json").then((r) => r.json());
|
|
8
|
-
describe("upgrade", () => {
|
|
9
|
-
describe("Petstore: Swagger 2.0 to OpenAPI 3.0", () => {
|
|
10
|
-
bench("new", () => {
|
|
11
|
-
expect(PETSTORE.swagger).toBe("2.0");
|
|
12
|
-
const result = upgradeFromTwoToThree({ ...PETSTORE });
|
|
13
|
-
expect(result.openapi).toBe("3.0.4");
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
describe("Stripe: OpenAPI 3.0 to 3.1", () => {
|
|
17
|
-
bench("new", () => {
|
|
18
|
-
expect(STRIPE.openapi).toBe("3.0.0");
|
|
19
|
-
const { specification } = upgrade(JSON.stringify(STRIPE));
|
|
20
|
-
expect(specification?.openapi).toBe("3.1.1");
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
describe("Petstore: Swagger 2.0 to OpenAPI 3.1", () => {
|
|
24
|
-
bench("new", () => {
|
|
25
|
-
expect(PETSTORE.swagger).toBe("2.0");
|
|
26
|
-
const { specification } = upgrade(JSON.stringify(PETSTORE));
|
|
27
|
-
expect(specification?.openapi).toBe("3.1.1");
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=upgrade.bench.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/upgrade.bench.ts"],
|
|
4
|
-
"sourcesContent": ["import { bench, describe, expect } from 'vitest'\n\n// import { upgrade as upgradeOld } from './slow/upgrade'\n// import { upgradeFromTwoToThree as upgradeFromTwoToThreeOld } from './slow/upgradeFromTwoToThree'\nimport { upgrade } from './upgrade'\nimport { upgradeFromTwoToThree } from './upgrade-from-two-to-three'\n\n// Setup the test data\nconst STRIPE = await fetch(\n 'https://raw.githubusercontent.com/stripe/openapi/refs/heads/master/openapi/spec3.json',\n).then((r) => r.json())\n\nconst PETSTORE = await fetch('https://petstore.swagger.io/v2/swagger.json').then((r) => r.json())\n\ndescribe('upgrade', () => {\n describe('Petstore: Swagger 2.0 to OpenAPI 3.0', () => {\n bench('new', () => {\n expect(PETSTORE.swagger).toBe('2.0')\n\n const result = upgradeFromTwoToThree({ ...PETSTORE })\n\n expect(result.openapi).toBe('3.0.4')\n })\n\n // bench('old', () => {\n // expect(PETSTORE.swagger).toBe('2.0')\n\n // const result = upgradeFromTwoToThreeOld({ ...PETSTORE })\n\n // expect(result.openapi).toBe('3.0.4')\n // })\n })\n\n describe('Stripe: OpenAPI 3.0 to 3.1', () => {\n bench('new', () => {\n expect(STRIPE.openapi).toBe('3.0.0')\n\n const { specification } = upgrade(JSON.stringify(STRIPE))\n\n expect(specification?.openapi).toBe('3.1.1')\n })\n\n // bench('old', () => {\n // expect(STRIPE.openapi).toBe('3.0.0')\n\n // const { specification } = upgradeOld(JSON.stringify(STRIPE))\n\n // expect(specification?.openapi).toBe('3.1.1')\n // })\n })\n\n describe('Petstore: Swagger 2.0 to OpenAPI 3.1', () => {\n bench('new', () => {\n expect(PETSTORE.swagger).toBe('2.0')\n\n const { specification } = upgrade(JSON.stringify(PETSTORE))\n\n expect(specification?.openapi).toBe('3.1.1')\n })\n\n // bench('old', () => {\n // expect(PETSTORE.swagger).toBe('2.0')\n\n // const { specification } = upgradeOld(JSON.stringify(PETSTORE))\n\n // expect(specification?.openapi).toBe('3.1.1')\n // })\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,OAAO,UAAU,cAAc;AAIxC,SAAS,eAAe;AACxB,SAAS,6BAA6B;AAGtC,MAAM,SAAS,MAAM;AAAA,EACnB;AACF,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC;AAEtB,MAAM,WAAW,MAAM,MAAM,6CAA6C,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC;AAEhG,SAAS,WAAW,MAAM;AACxB,WAAS,wCAAwC,MAAM;AACrD,UAAM,OAAO,MAAM;AACjB,aAAO,SAAS,OAAO,EAAE,KAAK,KAAK;AAEnC,YAAM,SAAS,sBAAsB,EAAE,GAAG,SAAS,CAAC;AAEpD,aAAO,OAAO,OAAO,EAAE,KAAK,OAAO;AAAA,IACrC,CAAC;AAAA,EASH,CAAC;AAED,WAAS,8BAA8B,MAAM;AAC3C,UAAM,OAAO,MAAM;AACjB,aAAO,OAAO,OAAO,EAAE,KAAK,OAAO;AAEnC,YAAM,EAAE,cAAc,IAAI,QAAQ,KAAK,UAAU,MAAM,CAAC;AAExD,aAAO,eAAe,OAAO,EAAE,KAAK,OAAO;AAAA,IAC7C,CAAC;AAAA,EASH,CAAC;AAED,WAAS,wCAAwC,MAAM;AACrD,UAAM,OAAO,MAAM;AACjB,aAAO,SAAS,OAAO,EAAE,KAAK,KAAK;AAEnC,YAAM,EAAE,cAAc,IAAI,QAAQ,KAAK,UAAU,QAAQ,CAAC;AAE1D,aAAO,eAAe,OAAO,EAAE,KAAK,OAAO;AAAA,IAC7C,CAAC;AAAA,EASH,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.test-d.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { describe, expectTypeOf, it } from "vitest";
|
|
2
|
-
import { upgrade } from "./upgrade.js";
|
|
3
|
-
describe("OpenAPI", () => {
|
|
4
|
-
it("narrows it down to OpenAPI 3.1", () => {
|
|
5
|
-
const { specification } = upgrade({
|
|
6
|
-
openapi: "3.0.0",
|
|
7
|
-
info: {
|
|
8
|
-
title: "Hello World",
|
|
9
|
-
version: "1.0.0"
|
|
10
|
-
},
|
|
11
|
-
paths: {}
|
|
12
|
-
});
|
|
13
|
-
expectTypeOf(specification).toMatchTypeOf();
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=upgrade.test-d.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/upgrade.test-d.ts"],
|
|
4
|
-
"sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { describe, expectTypeOf, it } from 'vitest'\n\nimport { upgrade } from './upgrade'\n\ndescribe('OpenAPI', () => {\n it('narrows it down to OpenAPI 3.1', () => {\n const { specification } = upgrade({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n\n expectTypeOf(specification).toMatchTypeOf<OpenAPIV3_1.Document>()\n })\n})\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,UAAU,cAAc,UAAU;AAE3C,SAAS,eAAe;AAExB,SAAS,WAAW,MAAM;AACxB,KAAG,kCAAkC,MAAM;AACzC,UAAM,EAAE,cAAc,IAAI,QAAQ;AAAA,MAChC,SAAS;AAAA,MACT,MAAM;AAAA,QACJ,OAAO;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,OAAO,CAAC;AAAA,IACV,CAAC;AAED,iBAAa,aAAa,EAAE,cAAoC;AAAA,EAClE,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|