fumadocs-openapi 4.3.0 → 4.3.1
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.
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
useRef,
|
|
16
16
|
useState as useState3
|
|
17
17
|
} from "react";
|
|
18
|
-
import { Controller as Controller2, useForm } from "react-hook-form";
|
|
18
|
+
import { Controller as Controller2, useForm, useWatch } from "react-hook-form";
|
|
19
19
|
import useSWRImmutable from "swr/immutable";
|
|
20
20
|
import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
|
|
21
21
|
import { cn as cn5, buttonVariants as buttonVariants2 } from "fumadocs-ui/components/api";
|
|
@@ -889,16 +889,12 @@ function APIPlayground({
|
|
|
889
889
|
input ? [baseUrl, route, method, input, bodyType] : null,
|
|
890
890
|
async () => {
|
|
891
891
|
if (!input) return;
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
if (typeof paramValue === "string")
|
|
896
|
-
pathname = pathname.replace(`{${key}}`, paramValue);
|
|
897
|
-
});
|
|
898
|
-
const url = new URL(`${baseUrl ?? window.location.origin}${pathname}`);
|
|
892
|
+
const url = new URL(
|
|
893
|
+
`${baseUrl ?? window.location.origin}${createPathnameFromInput(route, input.path)}`
|
|
894
|
+
);
|
|
899
895
|
Object.keys(input.query).forEach((key) => {
|
|
900
896
|
const paramValue = input.query[key];
|
|
901
|
-
if (typeof paramValue === "string")
|
|
897
|
+
if (typeof paramValue === "string" && paramValue.length > 0)
|
|
902
898
|
url.searchParams.append(key, paramValue);
|
|
903
899
|
});
|
|
904
900
|
const headers = new Headers({
|
|
@@ -909,7 +905,8 @@ function APIPlayground({
|
|
|
909
905
|
}
|
|
910
906
|
Object.keys(input.header).forEach((key) => {
|
|
911
907
|
const paramValue = input.header[key];
|
|
912
|
-
if (typeof paramValue === "string"
|
|
908
|
+
if (typeof paramValue === "string" && paramValue.length > 0)
|
|
909
|
+
headers.append(key, paramValue);
|
|
913
910
|
});
|
|
914
911
|
const bodyValue = body && input.body && Object.keys(input.body).length > 0 ? createBodyFromValue(
|
|
915
912
|
bodyType,
|
|
@@ -969,7 +966,7 @@ function APIPlayground({
|
|
|
969
966
|
onSubmit,
|
|
970
967
|
children: [
|
|
971
968
|
/* @__PURE__ */ jsxs3("div", { className: "flex flex-row gap-2", children: [
|
|
972
|
-
/* @__PURE__ */ jsx6(
|
|
969
|
+
/* @__PURE__ */ jsx6(RouteDisplay, { route }),
|
|
973
970
|
/* @__PURE__ */ jsx6(
|
|
974
971
|
"button",
|
|
975
972
|
{
|
|
@@ -1025,6 +1022,25 @@ function APIPlayground({
|
|
|
1025
1022
|
}
|
|
1026
1023
|
) });
|
|
1027
1024
|
}
|
|
1025
|
+
function createPathnameFromInput(route, input) {
|
|
1026
|
+
let pathname = route;
|
|
1027
|
+
Object.keys(input).forEach((key) => {
|
|
1028
|
+
const paramValue = input[key];
|
|
1029
|
+
if (typeof paramValue === "string" && paramValue.length > 0)
|
|
1030
|
+
pathname = pathname.replace(`{${key}}`, paramValue);
|
|
1031
|
+
});
|
|
1032
|
+
return pathname;
|
|
1033
|
+
}
|
|
1034
|
+
function RouteDisplay({ route }) {
|
|
1035
|
+
const pathInput = useWatch({
|
|
1036
|
+
name: "path"
|
|
1037
|
+
});
|
|
1038
|
+
const pathname = useMemo(
|
|
1039
|
+
() => createPathnameFromInput(route, pathInput),
|
|
1040
|
+
[route, pathInput]
|
|
1041
|
+
);
|
|
1042
|
+
return /* @__PURE__ */ jsx6("code", { className: "flex-1 overflow-auto text-nowrap rounded-lg border bg-fd-secondary px-3 py-1.5 text-sm", children: pathname });
|
|
1043
|
+
}
|
|
1028
1044
|
function ResultDisplay({
|
|
1029
1045
|
data
|
|
1030
1046
|
}) {
|
package/dist/ui/index.js
CHANGED
|
@@ -176,7 +176,7 @@ function CopyRouteButton({
|
|
|
176
176
|
|
|
177
177
|
// src/ui/index.ts
|
|
178
178
|
var APIPlayground = dynamic(
|
|
179
|
-
() => import("../playground-
|
|
179
|
+
() => import("../playground-GIGTWHCL.js").then((mod) => mod.APIPlayground)
|
|
180
180
|
);
|
|
181
181
|
var Responses = Tabs;
|
|
182
182
|
var Response = Tab;
|