zudoku 0.41.2 → 0.41.3
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/dist/lib/oas/parser/index.d.ts +1 -1
- package/dist/lib/oas/parser/index.js +3 -3
- package/dist/lib/oas/parser/index.js.map +1 -1
- package/dist/lib/oas/parser/upgrade/index.d.ts +9 -0
- package/dist/lib/oas/parser/upgrade/index.js +90 -0
- package/dist/lib/oas/parser/upgrade/index.js.map +1 -0
- package/lib/{OasProvider-DY8kA-9x.js → OasProvider-C15HpDwF.js} +2 -2
- package/lib/{OasProvider-DY8kA-9x.js.map → OasProvider-C15HpDwF.js.map} +1 -1
- package/lib/{OperationList-BNneqYos.js → OperationList-j4pFeiTb.js} +2 -2
- package/lib/{OperationList-BNneqYos.js.map → OperationList-j4pFeiTb.js.map} +1 -1
- package/lib/{SchemaList-CbFxph_p.js → SchemaList-DRck1myS.js} +2 -2
- package/lib/{SchemaList-CbFxph_p.js.map → SchemaList-DRck1myS.js.map} +1 -1
- package/lib/{createServer-D_5UkLtY.js → createServer-IW7v5hWm.js} +1485 -1459
- package/lib/createServer-IW7v5hWm.js.map +1 -0
- package/lib/{public-api-CrAQFYc4.js → index-DcHeSvkE.js} +684 -651
- package/lib/index-DcHeSvkE.js.map +1 -0
- package/lib/{index-pAogBEk7.js → index-Dk7l9To6.js} +5 -5
- package/lib/{index-pAogBEk7.js.map → index-Dk7l9To6.js.map} +1 -1
- package/lib/zudoku.plugin-openapi.js +1 -1
- package/package.json +1 -1
- package/src/lib/oas/parser/index.ts +3 -4
- package/src/lib/oas/parser/upgrade/index.ts +103 -0
- package/lib/createServer-D_5UkLtY.js.map +0 -1
- package/lib/index-BpThvE5R.js +0 -66
- package/lib/index-BpThvE5R.js.map +0 -1
- package/lib/index-ueM1dihS.js +0 -247
- package/lib/index-ueM1dihS.js.map +0 -1
- package/lib/public-api-CrAQFYc4.js.map +0 -1
|
@@ -3,7 +3,7 @@ import "lucide-react";
|
|
|
3
3
|
import "./chunk-KNED5TY2-BUPjb3LQ.js";
|
|
4
4
|
import "./hook-pPrHCB6G.js";
|
|
5
5
|
import "./ui/Button.js";
|
|
6
|
-
import { U as a, o as e } from "./index-
|
|
6
|
+
import { U as a, o as e } from "./index-Dk7l9To6.js";
|
|
7
7
|
export {
|
|
8
8
|
a as UNTAGGED_PATH,
|
|
9
9
|
e as openApiPlugin
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GraphQLError } from "graphql/error/index.js";
|
|
2
2
|
import { OpenAPIV3, type OpenAPIV3_1 } from "openapi-types";
|
|
3
3
|
import { dereference, type JSONSchema } from "./dereference/index.js";
|
|
4
|
+
import { upgradeSchema } from "./upgrade/index.js";
|
|
4
5
|
|
|
5
6
|
// Must be an interface (not a type) to allow merging with OpenAPI types with index signatures
|
|
6
7
|
interface WithRef {
|
|
@@ -94,10 +95,8 @@ export const validate = async (schemaInput: unknown) => {
|
|
|
94
95
|
throw new GraphQLError("OpenAPI version is not defined");
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
const { upgrade } = await import("@scalar/openapi-parser");
|
|
98
|
-
|
|
99
98
|
const dereferenced = await dereference(schema);
|
|
100
|
-
const upgraded =
|
|
99
|
+
const upgraded = upgradeSchema(dereferenced);
|
|
101
100
|
|
|
102
|
-
return upgraded
|
|
101
|
+
return upgraded;
|
|
103
102
|
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { type RecordAny, traverse } from "../../../util/traverse.js";
|
|
3
|
+
import type { OpenAPIDocument } from "../index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Upgrade from OpenAPI 3.0.x to 3.1.0
|
|
6
|
+
*
|
|
7
|
+
* Taken from https://github.com/scalar/openapi-parser/blob/main/packages/openapi-parser/src/utils/upgradeFromThreeToThreeOne.ts
|
|
8
|
+
* https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export const upgradeSchema = (schema: RecordAny): OpenAPIDocument => {
|
|
12
|
+
if (schema.openapi?.startsWith("3.0")) {
|
|
13
|
+
schema.openapi = "3.1.0";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
schema = traverse(schema, (sub) => {
|
|
17
|
+
if (typeof sub.type !== "undefined" && sub.nullable === true) {
|
|
18
|
+
sub.type = ["null", sub.type];
|
|
19
|
+
delete sub.nullable;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return sub;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
schema = traverse(schema, (sub) => {
|
|
26
|
+
if (sub.exclusiveMinimum === true) {
|
|
27
|
+
sub.exclusiveMinimum = sub.minimum;
|
|
28
|
+
delete sub.minimum;
|
|
29
|
+
} else if (sub.exclusiveMinimum === false) {
|
|
30
|
+
delete sub.exclusiveMinimum;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (sub.exclusiveMaximum === true) {
|
|
34
|
+
sub.exclusiveMaximum = sub.maximum;
|
|
35
|
+
delete sub.maximum;
|
|
36
|
+
} else if (sub.exclusiveMaximum === false) {
|
|
37
|
+
delete sub.exclusiveMaximum;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return sub;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
schema = traverse(schema, (sub) => {
|
|
44
|
+
// may be null or undefined
|
|
45
|
+
if (sub.example) {
|
|
46
|
+
const isExampleObject =
|
|
47
|
+
typeof sub.example === "object" &&
|
|
48
|
+
(sub.example.summary !== undefined ||
|
|
49
|
+
sub.example.description !== undefined ||
|
|
50
|
+
sub.example.value !== undefined ||
|
|
51
|
+
sub.example.externalValue !== undefined);
|
|
52
|
+
|
|
53
|
+
const exampleValue = isExampleObject
|
|
54
|
+
? sub.example
|
|
55
|
+
: { value: sub.example };
|
|
56
|
+
|
|
57
|
+
if (!sub.examples) {
|
|
58
|
+
sub.examples = { default: exampleValue };
|
|
59
|
+
} else {
|
|
60
|
+
sub.examples = {
|
|
61
|
+
default: exampleValue,
|
|
62
|
+
...sub.examples,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
delete sub.example;
|
|
66
|
+
}
|
|
67
|
+
return sub;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
schema = traverse(schema, (sub) => {
|
|
71
|
+
if (sub.type === "object" && sub.properties !== undefined) {
|
|
72
|
+
for (const [, value] of Object.entries(sub.properties)) {
|
|
73
|
+
const v = (value ?? {}) as RecordAny;
|
|
74
|
+
if (v.type === "string" && v.format === "binary") {
|
|
75
|
+
v.contentEncoding = "application/octet-stream";
|
|
76
|
+
delete v.format;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return sub;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
schema = traverse(schema, (sub) => {
|
|
84
|
+
if (sub.type === "string" && sub.format === "binary") {
|
|
85
|
+
return undefined as any;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return sub;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
schema = traverse(schema, (sub) => {
|
|
92
|
+
if (sub.type === "string" && sub.format === "base64") {
|
|
93
|
+
return {
|
|
94
|
+
type: "string",
|
|
95
|
+
contentEncoding: "base64",
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return sub;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return schema as OpenAPIDocument;
|
|
103
|
+
};
|