fumadocs-openapi 10.6.4 → 10.6.6
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/css/generated/shared.css +34 -7
- package/dist/_openapi/types.d.ts +1 -2
- package/dist/generate-file.d.ts +1 -2
- package/dist/generate-file.js +3 -4
- package/dist/i18n.d.ts +2 -2
- package/dist/i18n.js +1 -2
- package/dist/playground/auth.js +92 -0
- package/dist/playground/client.d.ts +5 -10
- package/dist/playground/client.js +280 -199
- package/dist/playground/components/inputs.js +0 -2
- package/dist/playground/components/oauth-dialog.js +125 -164
- package/dist/playground/components/server-select.js +0 -2
- package/dist/playground/components/spinner.js +14 -0
- package/dist/playground/fetcher.d.ts +1 -2
- package/dist/playground/fetcher.js +0 -2
- package/dist/playground/schema.d.ts +1 -2
- package/dist/playground/schema.js +24 -15
- package/dist/playground/status-info.js +0 -2
- package/dist/requests/generators/all.d.ts +1 -2
- package/dist/requests/generators/all.js +0 -2
- package/dist/requests/generators/csharp.d.ts +1 -2
- package/dist/requests/generators/csharp.js +2 -3
- package/dist/requests/generators/curl.d.ts +1 -2
- package/dist/requests/generators/curl.js +5 -7
- package/dist/requests/generators/go.d.ts +1 -2
- package/dist/requests/generators/go.js +5 -7
- package/dist/requests/generators/index.d.ts +1 -2
- package/dist/requests/generators/index.js +0 -2
- package/dist/requests/generators/java.d.ts +1 -2
- package/dist/requests/generators/java.js +4 -6
- package/dist/requests/generators/javascript.d.ts +1 -2
- package/dist/requests/generators/javascript.js +3 -5
- package/dist/requests/generators/python.d.ts +1 -2
- package/dist/requests/generators/python.js +5 -6
- package/dist/requests/media/adapter.d.ts +1 -2
- package/dist/requests/media/adapter.js +7 -9
- package/dist/requests/media/encode.d.ts +1 -2
- package/dist/requests/media/encode.js +0 -2
- package/dist/requests/media/resolve-adapter.js +0 -2
- package/dist/requests/string-utils.js +25 -6
- package/dist/requests/types.d.ts +4 -4
- package/dist/scalar/client.js +0 -2
- package/dist/scalar/index.d.ts +1 -2
- package/dist/scalar/index.js +0 -2
- package/dist/server/create.d.ts +2 -3
- package/dist/server/create.js +0 -2
- package/dist/server/proxy.d.ts +1 -2
- package/dist/server/proxy.js +0 -2
- package/dist/server/source-api.d.ts +1 -2
- package/dist/server/source-api.js +0 -2
- package/dist/types.d.ts +1 -2
- package/dist/ui/api-page.d.ts +1 -2
- package/dist/ui/api-page.js +3 -3
- package/dist/ui/base.d.ts +9 -6
- package/dist/ui/base.js +8 -5
- package/dist/ui/client/boundary.d.ts +1 -2
- package/dist/ui/client/boundary.js +0 -2
- package/dist/ui/client/boundary.lazy.js +2 -3
- package/dist/ui/client/full.js +0 -2
- package/dist/ui/client/i18n.js +0 -2
- package/dist/ui/client/index.d.ts +1 -2
- package/dist/ui/client/index.js +0 -2
- package/dist/ui/client/storage-key.js +1 -3
- package/dist/ui/components/accordion.js +0 -2
- package/dist/ui/components/codeblock.d.ts +1 -2
- package/dist/ui/components/codeblock.js +0 -2
- package/dist/ui/components/dialog.js +0 -2
- package/dist/ui/components/input.js +0 -2
- package/dist/ui/components/method-label.js +0 -2
- package/dist/ui/components/select-tab.js +0 -2
- package/dist/ui/components/select.js +0 -2
- package/dist/ui/contexts/api.d.ts +7 -5
- package/dist/ui/contexts/api.js +7 -4
- package/dist/ui/create-client.d.ts +1 -2
- package/dist/ui/create-client.js +6 -3
- package/dist/ui/index.d.ts +1 -2
- package/dist/ui/index.js +0 -2
- package/dist/ui/operation/client.js +0 -2
- package/dist/ui/operation/get-example-requests.d.ts +1 -2
- package/dist/ui/operation/get-example-requests.js +0 -2
- package/dist/ui/operation/index.js +0 -2
- package/dist/ui/operation/request-tabs.d.ts +10 -0
- package/dist/ui/operation/request-tabs.js +43 -39
- package/dist/ui/operation/response-tabs.d.ts +1 -2
- package/dist/ui/operation/response-tabs.js +0 -2
- package/dist/ui/operation/usage-tabs/client.d.ts +1 -2
- package/dist/ui/operation/usage-tabs/client.js +0 -2
- package/dist/ui/operation/usage-tabs/index.js +0 -2
- package/dist/ui/schema/client.d.ts +1 -2
- package/dist/ui/schema/client.js +0 -2
- package/dist/ui/schema/index.d.ts +3 -4
- package/dist/ui/schema/index.js +1 -3
- package/dist/utils/deep-equal.js +0 -2
- package/dist/utils/document/dereference.d.ts +1 -2
- package/dist/utils/document/dereference.js +0 -2
- package/dist/utils/document/process.d.ts +1 -2
- package/dist/utils/document/process.js +0 -2
- package/dist/utils/id-to-title.js +0 -2
- package/dist/utils/is-plain-object.js +0 -2
- package/dist/utils/pages/builder.d.ts +1 -2
- package/dist/utils/pages/builder.js +0 -2
- package/dist/utils/pages/preset-auto.d.ts +1 -2
- package/dist/utils/pages/preset-auto.js +0 -2
- package/dist/utils/pages/to-static-data.js +0 -2
- package/dist/utils/pages/to-text.d.ts +1 -2
- package/dist/utils/pages/to-text.js +5 -6
- package/dist/utils/remove-undefined.js +0 -2
- package/dist/utils/schema/dereference.js +22 -14
- package/dist/utils/schema/index.d.ts +4 -10
- package/dist/utils/schema/index.js +4 -11
- package/dist/utils/{merge-schema.js → schema/merge.js} +2 -4
- package/dist/utils/schema/pick.js +0 -2
- package/dist/utils/schema/ref.js +0 -2
- package/dist/utils/schema/resolve-ref.js +0 -2
- package/dist/utils/schema/to-string.js +4 -7
- package/dist/utils/url.js +0 -2
- package/dist/utils/use-query.js +2 -3
- package/package.json +2 -2
- package/dist/_openapi/types.d.ts.map +0 -1
- package/dist/generate-file.d.ts.map +0 -1
- package/dist/generate-file.js.map +0 -1
- package/dist/i18n.d.ts.map +0 -1
- package/dist/i18n.js.map +0 -1
- package/dist/playground/client.d.ts.map +0 -1
- package/dist/playground/client.js.map +0 -1
- package/dist/playground/components/inputs.js.map +0 -1
- package/dist/playground/components/oauth-dialog.js.map +0 -1
- package/dist/playground/components/server-select.js.map +0 -1
- package/dist/playground/fetcher.d.ts.map +0 -1
- package/dist/playground/fetcher.js.map +0 -1
- package/dist/playground/schema.d.ts.map +0 -1
- package/dist/playground/schema.js.map +0 -1
- package/dist/playground/status-info.js.map +0 -1
- package/dist/requests/generators/all.d.ts.map +0 -1
- package/dist/requests/generators/all.js.map +0 -1
- package/dist/requests/generators/csharp.d.ts.map +0 -1
- package/dist/requests/generators/csharp.js.map +0 -1
- package/dist/requests/generators/curl.d.ts.map +0 -1
- package/dist/requests/generators/curl.js.map +0 -1
- package/dist/requests/generators/go.d.ts.map +0 -1
- package/dist/requests/generators/go.js.map +0 -1
- package/dist/requests/generators/index.d.ts.map +0 -1
- package/dist/requests/generators/index.js.map +0 -1
- package/dist/requests/generators/java.d.ts.map +0 -1
- package/dist/requests/generators/java.js.map +0 -1
- package/dist/requests/generators/javascript.d.ts.map +0 -1
- package/dist/requests/generators/javascript.js.map +0 -1
- package/dist/requests/generators/python.d.ts.map +0 -1
- package/dist/requests/generators/python.js.map +0 -1
- package/dist/requests/media/adapter.d.ts.map +0 -1
- package/dist/requests/media/adapter.js.map +0 -1
- package/dist/requests/media/encode.d.ts.map +0 -1
- package/dist/requests/media/encode.js.map +0 -1
- package/dist/requests/media/resolve-adapter.js.map +0 -1
- package/dist/requests/string-utils.js.map +0 -1
- package/dist/requests/types.d.ts.map +0 -1
- package/dist/scalar/client.js.map +0 -1
- package/dist/scalar/index.d.ts.map +0 -1
- package/dist/scalar/index.js.map +0 -1
- package/dist/server/create.d.ts.map +0 -1
- package/dist/server/create.js.map +0 -1
- package/dist/server/proxy.d.ts.map +0 -1
- package/dist/server/proxy.js.map +0 -1
- package/dist/server/source-api.d.ts.map +0 -1
- package/dist/server/source-api.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/ui/api-page.d.ts.map +0 -1
- package/dist/ui/api-page.js.map +0 -1
- package/dist/ui/base.d.ts.map +0 -1
- package/dist/ui/base.js.map +0 -1
- package/dist/ui/client/boundary.d.ts.map +0 -1
- package/dist/ui/client/boundary.js.map +0 -1
- package/dist/ui/client/boundary.lazy.js.map +0 -1
- package/dist/ui/client/full.js.map +0 -1
- package/dist/ui/client/i18n.js.map +0 -1
- package/dist/ui/client/index.d.ts.map +0 -1
- package/dist/ui/client/index.js.map +0 -1
- package/dist/ui/client/storage-key.js.map +0 -1
- package/dist/ui/components/accordion.js.map +0 -1
- package/dist/ui/components/codeblock.d.ts.map +0 -1
- package/dist/ui/components/codeblock.js.map +0 -1
- package/dist/ui/components/dialog.js.map +0 -1
- package/dist/ui/components/input.js.map +0 -1
- package/dist/ui/components/method-label.js.map +0 -1
- package/dist/ui/components/select-tab.js.map +0 -1
- package/dist/ui/components/select.js.map +0 -1
- package/dist/ui/contexts/api.d.ts.map +0 -1
- package/dist/ui/contexts/api.js.map +0 -1
- package/dist/ui/create-client.d.ts.map +0 -1
- package/dist/ui/create-client.js.map +0 -1
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/index.js.map +0 -1
- package/dist/ui/operation/client.js.map +0 -1
- package/dist/ui/operation/get-example-requests.d.ts.map +0 -1
- package/dist/ui/operation/get-example-requests.js.map +0 -1
- package/dist/ui/operation/index.js.map +0 -1
- package/dist/ui/operation/request-tabs.js.map +0 -1
- package/dist/ui/operation/response-tabs.d.ts.map +0 -1
- package/dist/ui/operation/response-tabs.js.map +0 -1
- package/dist/ui/operation/usage-tabs/client.d.ts.map +0 -1
- package/dist/ui/operation/usage-tabs/client.js.map +0 -1
- package/dist/ui/operation/usage-tabs/index.js.map +0 -1
- package/dist/ui/schema/client.d.ts.map +0 -1
- package/dist/ui/schema/client.js.map +0 -1
- package/dist/ui/schema/index.d.ts.map +0 -1
- package/dist/ui/schema/index.js.map +0 -1
- package/dist/utils/deep-equal.js.map +0 -1
- package/dist/utils/document/dereference.d.ts.map +0 -1
- package/dist/utils/document/dereference.js.map +0 -1
- package/dist/utils/document/process.d.ts.map +0 -1
- package/dist/utils/document/process.js.map +0 -1
- package/dist/utils/id-to-title.js.map +0 -1
- package/dist/utils/is-plain-object.js.map +0 -1
- package/dist/utils/merge-schema.js.map +0 -1
- package/dist/utils/pages/builder.d.ts.map +0 -1
- package/dist/utils/pages/builder.js.map +0 -1
- package/dist/utils/pages/preset-auto.d.ts.map +0 -1
- package/dist/utils/pages/preset-auto.js.map +0 -1
- package/dist/utils/pages/to-static-data.js.map +0 -1
- package/dist/utils/pages/to-text.d.ts.map +0 -1
- package/dist/utils/pages/to-text.js.map +0 -1
- package/dist/utils/remove-undefined.js.map +0 -1
- package/dist/utils/schema/dereference.js.map +0 -1
- package/dist/utils/schema/index.d.ts.map +0 -1
- package/dist/utils/schema/index.js.map +0 -1
- package/dist/utils/schema/pick.js.map +0 -1
- package/dist/utils/schema/ref.js.map +0 -1
- package/dist/utils/schema/resolve-ref.js.map +0 -1
- package/dist/utils/schema/to-string.js.map +0 -1
- package/dist/utils/url.js.map +0 -1
- package/dist/utils/use-query.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { indent } from "../string-utils.js";
|
|
1
|
+
import { doubleQuote, indent } from "../string-utils.js";
|
|
2
2
|
import { resolveMediaAdapter } from "../media/resolve-adapter.js";
|
|
3
3
|
import "../media/adapter.js";
|
|
4
4
|
//#region src/requests/generators/java.ts
|
|
@@ -31,13 +31,13 @@ const java = {
|
|
|
31
31
|
s.push(indent(".build();"));
|
|
32
32
|
s.push("");
|
|
33
33
|
s.push("HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()");
|
|
34
|
-
s.push(indent(`.uri(URI.create(${
|
|
35
|
-
for (const [key, param] of Object.entries(headers)) s.push(indent(`.header(${
|
|
34
|
+
s.push(indent(`.uri(URI.create(${doubleQuote(url)}))`));
|
|
35
|
+
for (const [key, param] of Object.entries(headers)) s.push(indent(`.header(${doubleQuote(key)}, ${doubleQuote(param.value)})`));
|
|
36
36
|
if (data.bodyMediaType) s.push(indent(`.header("Content-Type", "${data.bodyMediaType}")`));
|
|
37
37
|
const cookies = Object.entries(data.cookie);
|
|
38
38
|
if (cookies.length > 0) {
|
|
39
39
|
const cookieString = cookies.map(([key, param]) => `${key}=${param.value}`).join("; ");
|
|
40
|
-
s.push(indent(`.header("Cookie", ${
|
|
40
|
+
s.push(indent(`.header("Cookie", ${doubleQuote(cookieString)})`));
|
|
41
41
|
}
|
|
42
42
|
const arg = body ? "body" : "";
|
|
43
43
|
s.push(indent(`.${data.method.toUpperCase()}(${arg})`));
|
|
@@ -55,5 +55,3 @@ const java = {
|
|
|
55
55
|
};
|
|
56
56
|
//#endregion
|
|
57
57
|
export { java };
|
|
58
|
-
|
|
59
|
-
//# sourceMappingURL=java.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { indent } from "../string-utils.js";
|
|
1
|
+
import { doubleQuote, indent } from "../string-utils.js";
|
|
2
2
|
import { resolveMediaAdapter } from "../media/resolve-adapter.js";
|
|
3
3
|
import "../media/adapter.js";
|
|
4
4
|
//#region src/requests/generators/javascript.ts
|
|
@@ -9,7 +9,7 @@ const javascript = {
|
|
|
9
9
|
const s = [];
|
|
10
10
|
const options = /* @__PURE__ */ new Map();
|
|
11
11
|
const headers = {};
|
|
12
|
-
options.set("method",
|
|
12
|
+
options.set("method", `"${data.method.toUpperCase()}"`);
|
|
13
13
|
if (data.bodyMediaType) headers["Content-Type"] = data.bodyMediaType;
|
|
14
14
|
for (const [k, v] of Object.entries(data.header)) headers[k] = v.value;
|
|
15
15
|
const cookies = Object.entries(data.cookie);
|
|
@@ -26,7 +26,7 @@ const javascript = {
|
|
|
26
26
|
s.push(body);
|
|
27
27
|
options.set("body", "body");
|
|
28
28
|
}
|
|
29
|
-
const params = [
|
|
29
|
+
const params = [doubleQuote(url)];
|
|
30
30
|
if (options.size > 0) {
|
|
31
31
|
const str = Array.from(options.entries()).map(([k, v]) => indent(k === v ? k : `${k}: ${v}`)).join(",\n");
|
|
32
32
|
params.push(`{\n${str}\n}`);
|
|
@@ -37,5 +37,3 @@ const javascript = {
|
|
|
37
37
|
};
|
|
38
38
|
//#endregion
|
|
39
39
|
export { javascript };
|
|
40
|
-
|
|
41
|
-
//# sourceMappingURL=javascript.js.map
|
|
@@ -4,5 +4,4 @@ import { CodeUsageGenerator } from "./index.js";
|
|
|
4
4
|
declare const python: CodeUsageGenerator;
|
|
5
5
|
declare function generatePythonObject(v: unknown, imports: Set<string>): string;
|
|
6
6
|
//#endregion
|
|
7
|
-
export { generatePythonObject, python };
|
|
8
|
-
//# sourceMappingURL=python.d.ts.map
|
|
7
|
+
export { generatePythonObject, python };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { doubleQuote } from "../string-utils.js";
|
|
1
2
|
import { resolveMediaAdapter } from "../media/resolve-adapter.js";
|
|
2
3
|
import "../media/adapter.js";
|
|
3
4
|
//#region src/requests/generators/python.ts
|
|
@@ -7,7 +8,7 @@ const python = {
|
|
|
7
8
|
generate(url, data, { mediaAdapters }) {
|
|
8
9
|
const headers = {};
|
|
9
10
|
const imports = /* @__PURE__ */ new Set();
|
|
10
|
-
const params = [`"${data.method}"`, "url"];
|
|
11
|
+
const params = [`"${data.method.toUpperCase()}"`, "url"];
|
|
11
12
|
let body;
|
|
12
13
|
imports.add("requests");
|
|
13
14
|
if (data.body && data.bodyMediaType) {
|
|
@@ -26,7 +27,7 @@ const python = {
|
|
|
26
27
|
}
|
|
27
28
|
return `${Array.from(imports).map((name) => "import " + name).join("\n")}
|
|
28
29
|
|
|
29
|
-
url = ${
|
|
30
|
+
url = ${doubleQuote(url)}
|
|
30
31
|
${body ?? ""}
|
|
31
32
|
response = requests.request(${params.join(", ")})
|
|
32
33
|
|
|
@@ -36,16 +37,14 @@ print(response.text)`;
|
|
|
36
37
|
function generatePythonObject(v, imports) {
|
|
37
38
|
if (v === null) return "None";
|
|
38
39
|
else if (typeof v === "boolean") return v ? "True" : "False";
|
|
39
|
-
else if (typeof v === "string") return
|
|
40
|
+
else if (typeof v === "string") return doubleQuote(v);
|
|
40
41
|
else if (typeof v === "number") return v.toString();
|
|
41
42
|
else if (Array.isArray(v)) return `[${v.map((item) => generatePythonObject(item, imports)).join(", ")}]`;
|
|
42
43
|
else if (v instanceof Date) {
|
|
43
44
|
imports.add("datetime");
|
|
44
45
|
return `datetime.datetime(${v.getFullYear()}, ${v.getMonth() + 1}, ${v.getDate()}, ${v.getHours()}, ${v.getMinutes()}, ${v.getSeconds()}, ${v.getMilliseconds()})`;
|
|
45
|
-
} else if (typeof v === "object") return `{\n${Object.entries(v).map(([key, value]) => ` ${
|
|
46
|
+
} else if (typeof v === "object") return `{\n${Object.entries(v).map(([key, value]) => ` ${doubleQuote(key)}: ${generatePythonObject(value, imports)}`).join(", \n")}\n}`;
|
|
46
47
|
else throw new Error(`Unsupported type: ${typeof v}`);
|
|
47
48
|
}
|
|
48
49
|
//#endregion
|
|
49
50
|
export { generatePythonObject, python };
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=python.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { backtickQuote, inputToString, tripleDoubleQuote } from "../string-utils.js";
|
|
2
2
|
import "./resolve-adapter.js";
|
|
3
3
|
import js2xml from "xml-js/lib/js2xml.js";
|
|
4
4
|
//#region src/requests/media/adapter.ts
|
|
@@ -80,7 +80,7 @@ const defaultAdapters = {
|
|
|
80
80
|
s.push("mp := multipart.NewWriter(payload)");
|
|
81
81
|
for (const [key, value] of Object.entries(data.body)) {
|
|
82
82
|
if (!value) continue;
|
|
83
|
-
const escaped =
|
|
83
|
+
const escaped = backtickQuote(inputToString(value, "application/json"));
|
|
84
84
|
s.push(`mp.WriteField("${key}", ${escaped})`);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -103,22 +103,20 @@ const defaultAdapters = {
|
|
|
103
103
|
function str(init, mediaType, ctx) {
|
|
104
104
|
if (ctx.lang === "js") {
|
|
105
105
|
if (mediaType === "application/json") return `const body = JSON.stringify(${JSON.stringify(init, null, 2)})`;
|
|
106
|
-
return `const body = ${
|
|
106
|
+
return `const body = ${backtickQuote(inputToString(init, mediaType))}`;
|
|
107
107
|
}
|
|
108
|
-
if (ctx.lang === "python") return `body = ${
|
|
108
|
+
if (ctx.lang === "python") return `body = ${tripleDoubleQuote(inputToString(init, mediaType))}`;
|
|
109
109
|
if (ctx.lang === "go") {
|
|
110
110
|
const { addImport } = ctx;
|
|
111
111
|
addImport("strings");
|
|
112
|
-
return `body := strings.NewReader(${
|
|
112
|
+
return `body := strings.NewReader(${backtickQuote(inputToString(init, mediaType))})`;
|
|
113
113
|
}
|
|
114
114
|
if (ctx.lang === "java") {
|
|
115
115
|
const { addImport } = ctx;
|
|
116
116
|
addImport("java.net.http.HttpRequest.BodyPublishers");
|
|
117
|
-
return `var body = BodyPublishers.ofString(${
|
|
117
|
+
return `var body = BodyPublishers.ofString(${tripleDoubleQuote(inputToString(init, mediaType))});`;
|
|
118
118
|
}
|
|
119
|
-
if (ctx.lang === "csharp") return `var body = new StringContent(${
|
|
119
|
+
if (ctx.lang === "csharp") return `var body = new StringContent(${tripleDoubleQuote(`\n${inputToString(init, mediaType)}\n`)}, Encoding.UTF8, "${mediaType}");`;
|
|
120
120
|
}
|
|
121
121
|
//#endregion
|
|
122
122
|
export { defaultAdapters };
|
|
123
|
-
|
|
124
|
-
//# sourceMappingURL=adapter.js.map
|
|
@@ -18,15 +18,34 @@ function inputToString(value, format = "application/json") {
|
|
|
18
18
|
spaces: 2
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Returns the input string wrapped in single quotes, escaping internal single quotes and backslashes.
|
|
23
|
+
*/
|
|
24
|
+
function singleQuote(str) {
|
|
25
|
+
return `'${str.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Returns the input string wrapped in double quotes, escaping internal double quotes and backslashes.
|
|
29
|
+
*/
|
|
30
|
+
function doubleQuote(str) {
|
|
31
|
+
return `"${str.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns the input string wrapped in Python triple double-quotes,
|
|
35
|
+
* escaping embedded triple quotes and backslashes.
|
|
36
|
+
*/
|
|
37
|
+
function tripleDoubleQuote(str) {
|
|
38
|
+
return `"""${str.replace(/\\/g, "\\\\").replace(/"""/g, "\\\"\\\"\\\"")}"""`;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns the input string wrapped in backticks, escaping internal backticks and backslashes.
|
|
42
|
+
*/
|
|
43
|
+
function backtickQuote(str) {
|
|
44
|
+
return `\`${str.replace(/\\/g, "\\\\").replace(/`/g, "\\`")}\``;
|
|
24
45
|
}
|
|
25
46
|
function indent(code, tab = 1) {
|
|
26
47
|
const p = " ".repeat(tab);
|
|
27
48
|
return code.split("\n").map((v) => v.length === 0 ? v : p + v).join("\n");
|
|
28
49
|
}
|
|
29
50
|
//#endregion
|
|
30
|
-
export {
|
|
31
|
-
|
|
32
|
-
//# sourceMappingURL=string-utils.js.map
|
|
51
|
+
export { backtickQuote, doubleQuote, indent, inputToString, singleQuote, tripleDoubleQuote };
|
package/dist/requests/types.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { EncodedParameter, EncodedParameterMultiple } from "./media/encode.js";
|
|
2
|
+
import { HttpMethods } from "../types.js";
|
|
2
3
|
|
|
3
4
|
//#region src/requests/types.d.ts
|
|
4
5
|
interface RawRequestData {
|
|
5
|
-
method:
|
|
6
|
+
method: HttpMethods;
|
|
6
7
|
path: Record<string, unknown>;
|
|
7
8
|
query: Record<string, unknown>;
|
|
8
9
|
header: Record<string, unknown>;
|
|
@@ -11,7 +12,7 @@ interface RawRequestData {
|
|
|
11
12
|
bodyMediaType?: string;
|
|
12
13
|
}
|
|
13
14
|
interface RequestData {
|
|
14
|
-
method:
|
|
15
|
+
method: HttpMethods;
|
|
15
16
|
path: Record<string, EncodedParameter>;
|
|
16
17
|
query: Record<string, EncodedParameterMultiple>;
|
|
17
18
|
header: Record<string, EncodedParameter>;
|
|
@@ -20,5 +21,4 @@ interface RequestData {
|
|
|
20
21
|
bodyMediaType?: string;
|
|
21
22
|
}
|
|
22
23
|
//#endregion
|
|
23
|
-
export { RawRequestData, RequestData };
|
|
24
|
-
//# sourceMappingURL=types.d.ts.map
|
|
24
|
+
export { RawRequestData, RequestData };
|
package/dist/scalar/client.js
CHANGED
package/dist/scalar/index.d.ts
CHANGED
package/dist/scalar/index.js
CHANGED
package/dist/server/create.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ProcessedDocument } from "../utils/document/process.js";
|
|
2
1
|
import { InlineCodeUsageGenerator } from "../requests/generators/index.js";
|
|
3
2
|
import { createProxy } from "./proxy.js";
|
|
3
|
+
import { ProcessedDocument } from "../utils/document/process.js";
|
|
4
4
|
import { Document } from "../types.js";
|
|
5
5
|
|
|
6
6
|
//#region src/server/create.d.ts
|
|
@@ -37,5 +37,4 @@ declare function createOpenAPI(options?: OpenAPIOptions): OpenAPIServer;
|
|
|
37
37
|
*/
|
|
38
38
|
declare function createCodeSample<T>(options: InlineCodeUsageGenerator<T>): InlineCodeUsageGenerator<T>;
|
|
39
39
|
//#endregion
|
|
40
|
-
export { OpenAPIOptions, OpenAPIServer, createCodeSample, createOpenAPI };
|
|
41
|
-
//# sourceMappingURL=create.d.ts.map
|
|
40
|
+
export { OpenAPIOptions, OpenAPIServer, createCodeSample, createOpenAPI };
|
package/dist/server/create.js
CHANGED
package/dist/server/proxy.d.ts
CHANGED
package/dist/server/proxy.js
CHANGED
|
@@ -51,5 +51,4 @@ declare function openapiSource(server: OpenAPIServer, options?: SchemaToPagesOpt
|
|
|
51
51
|
*/
|
|
52
52
|
declare function transformerOpenAPI(): PageTreeTransformer;
|
|
53
53
|
//#endregion
|
|
54
|
-
export { InternalOpenAPIMeta, openapiPlugin, openapiSource, transformerOpenAPI };
|
|
55
|
-
//# sourceMappingURL=source-api.d.ts.map
|
|
54
|
+
export { InternalOpenAPIMeta, openapiPlugin, openapiSource, transformerOpenAPI };
|
package/dist/types.d.ts
CHANGED
|
@@ -47,5 +47,4 @@ interface RenderContext extends Pick<OpenAPIOptions, 'proxyUrl'>, Omit<RequireKe
|
|
|
47
47
|
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
48
48
|
type Awaitable<T> = T | Promise<T>;
|
|
49
49
|
//#endregion
|
|
50
|
-
export { Awaitable, CallbackObject, DistributiveOmit, Document, ExampleObject, HttpMethods, MediaTypeObject, MethodInformation, OAuth2SecurityScheme, OperationObject, ParameterObject, PathItemObject, ReferenceObject, RenderContext, RequestBodyObject, ResponseObject, SecuritySchemeObject, ServerObject, ServerVariableObject, TagObject };
|
|
51
|
-
//# sourceMappingURL=types.d.ts.map
|
|
50
|
+
export { Awaitable, CallbackObject, DistributiveOmit, Document, ExampleObject, HttpMethods, MediaTypeObject, MethodInformation, OAuth2SecurityScheme, OperationObject, ParameterObject, PathItemObject, ReferenceObject, RenderContext, RequestBodyObject, ResponseObject, SecuritySchemeObject, ServerObject, ServerVariableObject, TagObject };
|
package/dist/ui/api-page.d.ts
CHANGED
package/dist/ui/api-page.js
CHANGED
|
@@ -9,7 +9,7 @@ function APIPage({ showTitle: hasHead = false, showDescription, operations, webh
|
|
|
9
9
|
className: "flex flex-col gap-24 text-sm @container",
|
|
10
10
|
children: [slots.operations?.map((op) => op.children), slots.webhooks?.map((op) => op.children)]
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
let content = renderPageLayout({
|
|
13
13
|
operations: operations?.map((item) => {
|
|
14
14
|
const pathItem = dereferenced.paths?.[item.path];
|
|
15
15
|
if (!pathItem) throw new Error(`[Fumadocs OpenAPI] Path not found in OpenAPI schema: ${item.path}`);
|
|
@@ -44,7 +44,9 @@ function APIPage({ showTitle: hasHead = false, showDescription, operations, webh
|
|
|
44
44
|
};
|
|
45
45
|
})
|
|
46
46
|
}, ctx);
|
|
47
|
+
if (ctx.playground?.enabled !== false && ctx.playground?.provider) content = ctx.playground.provider({ children: content });
|
|
47
48
|
return /* @__PURE__ */ jsx(ctx.clientBoundary.ApiProvider, {
|
|
49
|
+
schemes: dereferenced.components?.securitySchemes ?? {},
|
|
48
50
|
shikiOptions: ctx.shikiOptions,
|
|
49
51
|
client: ctx.client ?? {},
|
|
50
52
|
children: /* @__PURE__ */ jsx(ctx.clientBoundary.ServerProvider, {
|
|
@@ -55,5 +57,3 @@ function APIPage({ showTitle: hasHead = false, showDescription, operations, webh
|
|
|
55
57
|
}
|
|
56
58
|
//#endregion
|
|
57
59
|
export { APIPage };
|
|
58
|
-
|
|
59
|
-
//# sourceMappingURL=api-page.js.map
|
package/dist/ui/base.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { SchemaUIOptions } from "./schema/index.js";
|
|
|
6
6
|
import { OpenAPIServer } from "../server/create.js";
|
|
7
7
|
import { ApiPageProps, OperationItem, WebhookItem } from "./api-page.js";
|
|
8
8
|
import { ResponseTab } from "./operation/response-tabs.js";
|
|
9
|
+
import { RequestTabsRenderContext } from "./operation/request-tabs.js";
|
|
9
10
|
import { ClientCodeBlockProvider } from "./components/codeblock.js";
|
|
10
11
|
import { Awaitable, MethodInformation, RenderContext } from "../types.js";
|
|
11
12
|
import { NoReference } from "../utils/schema/index.js";
|
|
@@ -74,10 +75,7 @@ interface CreateAPIPageOptions {
|
|
|
74
75
|
*/
|
|
75
76
|
content?: {
|
|
76
77
|
renderResponseTabs?: (tabs: ResponseTab[], ctx: RenderContext) => ReactNode;
|
|
77
|
-
renderRequestTabs?: (items: ExampleRequestItem[], ctx:
|
|
78
|
-
route: string;
|
|
79
|
-
operation: NoReference<MethodInformation>;
|
|
80
|
-
}) => ReactNode;
|
|
78
|
+
renderRequestTabs?: (items: ExampleRequestItem[], ctx: RequestTabsRenderContext) => ReactNode;
|
|
81
79
|
renderAPIExampleLayout?: (slots: {
|
|
82
80
|
selector: ReactNode;
|
|
83
81
|
usageTabs: ReactNode;
|
|
@@ -142,6 +140,12 @@ interface CreateAPIPageOptions {
|
|
|
142
140
|
* @defaultValue true
|
|
143
141
|
*/
|
|
144
142
|
enabled?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* render a page-level provider (useful for handling auth)
|
|
145
|
+
*/
|
|
146
|
+
provider?: (props: {
|
|
147
|
+
children: ReactNode;
|
|
148
|
+
}) => ReactNode;
|
|
145
149
|
/**
|
|
146
150
|
* replace the server-side renderer
|
|
147
151
|
*/
|
|
@@ -159,5 +163,4 @@ interface ServerApiPageProps extends Omit<ApiPageProps, 'document'> {
|
|
|
159
163
|
}
|
|
160
164
|
declare function createAPIPage(server: OpenAPIServer, options: CreateAPIPageOptions): FC<ServerApiPageProps>;
|
|
161
165
|
//#endregion
|
|
162
|
-
export { APIPlaygroundProps, ClientCodeBlockProvider, CreateAPIPageOptions, GenerateTypeScriptDefinitionsContext, ServerApiPageProps, createAPIPage };
|
|
163
|
-
//# sourceMappingURL=base.d.ts.map
|
|
166
|
+
export { APIPlaygroundProps, ClientCodeBlockProvider, CreateAPIPageOptions, GenerateTypeScriptDefinitionsContext, ServerApiPageProps, createAPIPage };
|
package/dist/ui/base.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { parseSecurities } from "../utils/schema/index.js";
|
|
2
2
|
import { defaultAdapters } from "../requests/media/adapter.js";
|
|
3
|
-
import { ClientCodeBlockProvider } from "./components/codeblock.js";
|
|
4
3
|
import { encodeInternalRef } from "../utils/schema/ref.js";
|
|
4
|
+
import { ClientCodeBlockProvider } from "./components/codeblock.js";
|
|
5
5
|
import { APIPage } from "./api-page.js";
|
|
6
6
|
import { pickSchema } from "../utils/schema/pick.js";
|
|
7
|
+
import { PlaygroundAuthProvider } from "./client/boundary.lazy.js";
|
|
7
8
|
import Slugger from "github-slugger";
|
|
8
9
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
9
10
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -38,16 +39,19 @@ function createAPIPage(server, options) {
|
|
|
38
39
|
...options.shikiOptions
|
|
39
40
|
}).use(rehypeReact);
|
|
40
41
|
}
|
|
42
|
+
function renderPlaygroundProviderDefault({ children }) {
|
|
43
|
+
return /* @__PURE__ */ jsx(PlaygroundAuthProvider, { children });
|
|
44
|
+
}
|
|
41
45
|
function renderPlaygroundDefault({ path, method, ctx }) {
|
|
42
46
|
return /* @__PURE__ */ jsx(ctx.clientBoundary.PlaygroundClient, {
|
|
43
47
|
route: path,
|
|
44
48
|
securities: parseSecurities(method, ctx.schema.dereferenced),
|
|
45
49
|
method: method.method,
|
|
46
|
-
doc:
|
|
50
|
+
doc: pickSchema(ctx.schema.bundled, encodeInternalRef([
|
|
47
51
|
"paths",
|
|
48
52
|
path,
|
|
49
53
|
method.method
|
|
50
|
-
]))
|
|
54
|
+
])),
|
|
51
55
|
proxyUrl: ctx.proxyUrl,
|
|
52
56
|
writeOnly: true,
|
|
53
57
|
readOnly: false
|
|
@@ -77,6 +81,7 @@ function createAPIPage(server, options) {
|
|
|
77
81
|
},
|
|
78
82
|
playground: {
|
|
79
83
|
...options.playground,
|
|
84
|
+
provider: options.playground?.provider ?? renderPlaygroundProviderDefault,
|
|
80
85
|
render: options.playground?.render ?? renderPlaygroundDefault
|
|
81
86
|
},
|
|
82
87
|
renderHeading(depth, text, props) {
|
|
@@ -142,5 +147,3 @@ function createAPIPage(server, options) {
|
|
|
142
147
|
}
|
|
143
148
|
//#endregion
|
|
144
149
|
export { ClientCodeBlockProvider, createAPIPage };
|
|
145
|
-
|
|
146
|
-
//# sourceMappingURL=base.js.map
|
|
@@ -8,6 +8,7 @@ const UsageTabsSelector = wrapLazy(() => import("../operation/usage-tabs/client.
|
|
|
8
8
|
const UsageTab = wrapLazy(() => import("../operation/usage-tabs/client.js").then((mod) => ({ default: mod.UsageTab })));
|
|
9
9
|
const SchemaUI = wrapLazy(() => import("../schema/client.js").then((mod) => ({ default: mod.SchemaUI })));
|
|
10
10
|
const PlaygroundClient = wrapLazy(() => import("../../playground/client.js"));
|
|
11
|
+
const PlaygroundAuthProvider = wrapLazy(() => import("../../playground/auth.js").then((mod) => ({ default: mod.AuthProvider })));
|
|
11
12
|
function wrapLazy(load) {
|
|
12
13
|
const V = lazy(load);
|
|
13
14
|
return function wrapper(props) {
|
|
@@ -15,6 +16,4 @@ function wrapLazy(load) {
|
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
//#endregion
|
|
18
|
-
export { ApiProvider, PlaygroundClient, SchemaUI, ServerProvider, UsageTab, UsageTabsSelector };
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=boundary.lazy.js.map
|
|
19
|
+
export { ApiProvider, PlaygroundAuthProvider, PlaygroundClient, SchemaUI, ServerProvider, UsageTab, UsageTabsSelector };
|
package/dist/ui/client/full.js
CHANGED
package/dist/ui/client/i18n.js
CHANGED
|
@@ -34,5 +34,4 @@ interface OperationClientOptions {
|
|
|
34
34
|
}
|
|
35
35
|
declare function defineClientConfig(options?: APIPageClientOptions): APIPageClientOptions;
|
|
36
36
|
//#endregion
|
|
37
|
-
export { APIPageClientOptions, OperationClientOptions, defineClientConfig };
|
|
38
|
-
//# sourceMappingURL=index.d.ts.map
|
|
37
|
+
export { APIPageClientOptions, OperationClientOptions, defineClientConfig };
|
package/dist/ui/client/index.js
CHANGED
|
@@ -5,7 +5,7 @@ function useStorageKey() {
|
|
|
5
5
|
const { storageKeyPrefix } = useApiContext().client;
|
|
6
6
|
return useMemo(() => ({
|
|
7
7
|
of: (name) => getStorageKey(storageKeyPrefix, name),
|
|
8
|
-
AuthField: (
|
|
8
|
+
AuthField: (schemeId) => getStorageKey(storageKeyPrefix, `auth-${schemeId}`)
|
|
9
9
|
}), [storageKeyPrefix]);
|
|
10
10
|
}
|
|
11
11
|
function getStorageKey(prefix = "fumadocs-openapi-", name) {
|
|
@@ -13,5 +13,3 @@ function getStorageKey(prefix = "fumadocs-openapi-", name) {
|
|
|
13
13
|
}
|
|
14
14
|
//#endregion
|
|
15
15
|
export { useStorageKey };
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=storage-key.js.map
|
|
@@ -58,5 +58,3 @@ const DialogDescription = React.forwardRef(({ className, ...props }, ref) => /*
|
|
|
58
58
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
59
59
|
//#endregion
|
|
60
60
|
export { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger };
|
|
61
|
-
|
|
62
|
-
//# sourceMappingURL=dialog.js.map
|
|
@@ -70,5 +70,3 @@ const SelectSeparator = forwardRef(({ className, ...props }, ref) => /* @__PURE_
|
|
|
70
70
|
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
71
71
|
//#endregion
|
|
72
72
|
export { Select, SelectContent, SelectItem, SelectTrigger, SelectValue };
|
|
73
|
-
|
|
74
|
-
//# sourceMappingURL=select.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIPageClientOptions } from "../client/index.js";
|
|
2
|
-
import { RenderContext, ServerObject } from "../../types.js";
|
|
2
|
+
import { RenderContext, SecuritySchemeObject, ServerObject } from "../../types.js";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
5
|
|
|
@@ -7,11 +7,14 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
7
7
|
interface InheritFromContext extends Pick<RenderContext, 'shikiOptions'> {
|
|
8
8
|
client: APIPageClientOptions;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
interface ApiProviderProps extends InheritFromContext {
|
|
11
|
+
schemes: Record<string, SecuritySchemeObject>;
|
|
12
|
+
}
|
|
11
13
|
declare function ApiProvider({
|
|
12
14
|
children,
|
|
13
15
|
shikiOptions,
|
|
14
|
-
client
|
|
16
|
+
client,
|
|
17
|
+
schemes
|
|
15
18
|
}: ApiProviderProps & {
|
|
16
19
|
children: ReactNode;
|
|
17
20
|
}): _$react_jsx_runtime0.JSX.Element;
|
|
@@ -23,5 +26,4 @@ declare function ServerProvider({
|
|
|
23
26
|
children: ReactNode;
|
|
24
27
|
}): _$react_jsx_runtime0.JSX.Element;
|
|
25
28
|
//#endregion
|
|
26
|
-
export { ApiProvider, ServerProvider };
|
|
27
|
-
//# sourceMappingURL=api.d.ts.map
|
|
29
|
+
export { ApiProvider, ServerProvider };
|