fumadocs-openapi 10.3.9 → 10.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/generated/shared.css +7 -6
- package/dist/playground/client.js +11 -7
- package/dist/playground/components/inputs.js +35 -35
- package/dist/playground/components/oauth-dialog.js +1 -1
- package/dist/playground/components/server-select.js +3 -2
- package/dist/playground/index.d.ts +1 -1
- package/dist/playground/schema.js +33 -33
- package/dist/ui/components/accordion.js +1 -1
- package/dist/ui/operation/client.js +1 -1
- package/dist/ui/operation/index.js +3 -3
- package/dist/ui/operation/request-tabs.js +1 -1
- package/dist/ui/operation/usage-tabs/client.js +1 -1
- package/dist/ui/schema/client.js +3 -3
- package/dist/ui/schema/index.js +1 -1
- package/package.json +3 -3
package/css/generated/shared.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@source inline("!
|
|
1
|
+
@source inline("!isDefined");
|
|
2
2
|
@source inline("*:min-w-0");
|
|
3
3
|
@source inline("--fd-docs-row-1");
|
|
4
4
|
@source inline("--initial-height");
|
|
@@ -59,7 +59,6 @@
|
|
|
59
59
|
@source inline("assume");
|
|
60
60
|
@source inline("async");
|
|
61
61
|
@source inline("at");
|
|
62
|
-
@source inline("attachedData");
|
|
63
62
|
@source inline("auth-specific");
|
|
64
63
|
@source inline("authCodeCallback");
|
|
65
64
|
@source inline("authNode");
|
|
@@ -246,7 +245,8 @@
|
|
|
246
245
|
@source inline("fetch");
|
|
247
246
|
@source inline("fetcher");
|
|
248
247
|
@source inline("field");
|
|
249
|
-
@source inline("
|
|
248
|
+
@source inline("fieldData");
|
|
249
|
+
@source inline("fieldLabelVariants");
|
|
250
250
|
@source inline("fieldName");
|
|
251
251
|
@source inline("fields");
|
|
252
252
|
@source inline("file");
|
|
@@ -366,7 +366,6 @@
|
|
|
366
366
|
@source inline("infoTags");
|
|
367
367
|
@source inline("initAuthValues");
|
|
368
368
|
@source inline("initial");
|
|
369
|
-
@source inline("initialInfo");
|
|
370
369
|
@source inline("initialPath");
|
|
371
370
|
@source inline("inline-flex");
|
|
372
371
|
@source inline("input");
|
|
@@ -379,6 +378,7 @@
|
|
|
379
378
|
@source inline("interface");
|
|
380
379
|
@source inline("intersection");
|
|
381
380
|
@source inline("is");
|
|
381
|
+
@source inline("isDefined");
|
|
382
382
|
@source inline("isDuplicated");
|
|
383
383
|
@source inline("isDynamic");
|
|
384
384
|
@source inline("isLoading");
|
|
@@ -426,7 +426,6 @@
|
|
|
426
426
|
@source inline("lucide-react");
|
|
427
427
|
@source inline("map");
|
|
428
428
|
@source inline("mapInputs");
|
|
429
|
-
@source inline("match");
|
|
430
429
|
@source inline("max");
|
|
431
430
|
@source inline("max-age");
|
|
432
431
|
@source inline("max-h-[460px]");
|
|
@@ -467,6 +466,7 @@
|
|
|
467
466
|
@source inline("my-4");
|
|
468
467
|
@source inline("name");
|
|
469
468
|
@source inline("name!");
|
|
469
|
+
@source inline("namespace");
|
|
470
470
|
@source inline("necessary");
|
|
471
471
|
@source inline("need");
|
|
472
472
|
@source inline("nested");
|
|
@@ -878,10 +878,11 @@
|
|
|
878
878
|
@source inline("useApiClientModal");
|
|
879
879
|
@source inline("useApiContext");
|
|
880
880
|
@source inline("useCopyButton");
|
|
881
|
-
@source inline("useDataEngine");
|
|
882
881
|
@source inline("useExampleRequests");
|
|
882
|
+
@source inline("useFieldValue");
|
|
883
883
|
@source inline("useForm");
|
|
884
884
|
@source inline("useMemo");
|
|
885
|
+
@source inline("useNamespace");
|
|
885
886
|
@source inline("useObject");
|
|
886
887
|
@source inline("useQuery");
|
|
887
888
|
@source inline("useRef");
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { joinURL, resolveRequestData, resolveServerUrl, withBase } from "../utils/url.js";
|
|
4
|
-
import { cn } from "../utils/cn.js";
|
|
5
|
-
import { MethodLabel } from "../ui/components/method-label.js";
|
|
6
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/components/select.js";
|
|
7
|
-
import { encodeRequestData } from "../requests/media/encode.js";
|
|
8
4
|
import { useStorageKey } from "../ui/client/storage-key.js";
|
|
9
5
|
import { useApiContext, useServerContext } from "../ui/contexts/api.js";
|
|
10
6
|
import { getStatusInfo } from "./status-info.js";
|
|
7
|
+
import { cn } from "../utils/cn.js";
|
|
8
|
+
import { MethodLabel } from "../ui/components/method-label.js";
|
|
11
9
|
import { useQuery } from "../utils/use-query.js";
|
|
10
|
+
import { encodeRequestData } from "../requests/media/encode.js";
|
|
12
11
|
import { SchemaProvider, useResolvedSchema } from "./schema.js";
|
|
12
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/components/select.js";
|
|
13
13
|
import { labelVariants } from "../ui/components/input.js";
|
|
14
14
|
import ServerSelect from "./components/server-select.js";
|
|
15
15
|
import { useExampleRequests } from "../ui/operation/usage-tabs/client.js";
|
|
@@ -17,9 +17,9 @@ import { FieldInput, FieldSet, JsonInput, ObjectInput } from "./components/input
|
|
|
17
17
|
import { Fragment, lazy, useEffect, useMemo, useRef, useState } from "react";
|
|
18
18
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
19
19
|
import { ChevronDown, LoaderCircle, X } from "lucide-react";
|
|
20
|
-
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
21
20
|
import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock.core";
|
|
22
21
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "fumadocs-ui/components/ui/collapsible";
|
|
22
|
+
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
23
23
|
import { StfProvider, useDataEngine, useFieldValue, useListener, useStf } from "@fumari/stf";
|
|
24
24
|
import { objectGet, objectSet, stringifyFieldKey } from "@fumari/stf/lib/utils";
|
|
25
25
|
|
|
@@ -83,6 +83,7 @@ function PlaygroundClient({ route, method = "GET", securities, parameters = [],
|
|
|
83
83
|
useEffect(() => {
|
|
84
84
|
if (stf.dataEngine.getData() === defaultValues) return;
|
|
85
85
|
stf.dataEngine.reset(defaultValues);
|
|
86
|
+
stf.dataEngine.clearNamespaces();
|
|
86
87
|
}, [defaultValues]);
|
|
87
88
|
useEffect(() => {
|
|
88
89
|
return initAuthValues(stf);
|
|
@@ -206,7 +207,8 @@ function FormBody({ parameters = [], body }) {
|
|
|
206
207
|
return /* @__PURE__ */ jsx(FieldSet, {
|
|
207
208
|
name: field.name,
|
|
208
209
|
fieldName,
|
|
209
|
-
field: schema
|
|
210
|
+
field: schema,
|
|
211
|
+
isRequired: field.required
|
|
210
212
|
}, stringifyFieldKey(fieldName));
|
|
211
213
|
})
|
|
212
214
|
}, type);
|
|
@@ -221,7 +223,8 @@ function BodyInput({ field: _field }) {
|
|
|
221
223
|
const [isJson, setIsJson] = useState(false);
|
|
222
224
|
if (field.format === "binary") return /* @__PURE__ */ jsx(FieldSet, {
|
|
223
225
|
field,
|
|
224
|
-
fieldName: ["body"]
|
|
226
|
+
fieldName: ["body"],
|
|
227
|
+
isRequired: true
|
|
225
228
|
});
|
|
226
229
|
if (isJson) return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
227
230
|
className: cn(buttonVariants({
|
|
@@ -237,6 +240,7 @@ function BodyInput({ field: _field }) {
|
|
|
237
240
|
field,
|
|
238
241
|
fieldName: ["body"],
|
|
239
242
|
collapsible: false,
|
|
243
|
+
isRequired: true,
|
|
240
244
|
name: /* @__PURE__ */ jsx("button", {
|
|
241
245
|
type: "button",
|
|
242
246
|
className: cn(buttonVariants({
|
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
|
-
import { FormatFlags, schemaToString } from "../../utils/schema-to-string.js";
|
|
5
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../ui/components/select.js";
|
|
6
4
|
import { getDefaultValue } from "../get-default-values.js";
|
|
7
5
|
import { anyFields, useFieldInfo, useResolvedSchema, useSchemaScope } from "../schema.js";
|
|
6
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../ui/components/select.js";
|
|
8
7
|
import { Input, labelVariants } from "../../ui/components/input.js";
|
|
8
|
+
import { FormatFlags, schemaToString } from "../../utils/schema-to-string.js";
|
|
9
9
|
import { useState } from "react";
|
|
10
10
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { ChevronRight, Plus, Trash2, X } from "lucide-react";
|
|
12
|
+
import { cva } from "class-variance-authority";
|
|
12
13
|
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
13
14
|
import { useArray, useDataEngine, useFieldValue, useObject } from "@fumari/stf";
|
|
14
15
|
import { stringifyFieldKey } from "@fumari/stf/lib/utils";
|
|
15
16
|
|
|
16
17
|
//#region src/playground/components/inputs.tsx
|
|
17
|
-
|
|
18
|
-
return /* @__PURE__ */ jsx("label", {
|
|
19
|
-
...props,
|
|
20
|
-
className: cn("w-full inline-flex items-center gap-0.5", props.className),
|
|
21
|
-
children: props.children
|
|
22
|
-
});
|
|
23
|
-
}
|
|
18
|
+
const fieldLabelVariants = cva("w-full inline-flex items-center gap-0.5");
|
|
24
19
|
function FieldLabelType(props) {
|
|
25
20
|
return /* @__PURE__ */ jsx("code", {
|
|
26
21
|
...props,
|
|
@@ -115,23 +110,10 @@ function JsonInput({ fieldName }) {
|
|
|
115
110
|
});
|
|
116
111
|
}
|
|
117
112
|
function FieldInput({ field, fieldName, isRequired, ...props }) {
|
|
118
|
-
const engine = useDataEngine();
|
|
119
113
|
const [value, setValue] = useFieldValue(fieldName);
|
|
120
114
|
const id = stringifyFieldKey(fieldName);
|
|
121
115
|
if (field.type === "null") return;
|
|
122
|
-
|
|
123
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
124
|
-
...props,
|
|
125
|
-
className: cn("flex flex-row gap-2", props.className),
|
|
126
|
-
children: [children, value !== void 0 && !isRequired && /* @__PURE__ */ jsx("button", {
|
|
127
|
-
type: "button",
|
|
128
|
-
onClick: () => engine.delete(fieldName),
|
|
129
|
-
className: "text-fd-muted-foreground",
|
|
130
|
-
children: /* @__PURE__ */ jsx(X, { className: "size-4" })
|
|
131
|
-
})]
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
if (field.type === "string" && field.format === "binary") return renderUnset(/* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("label", {
|
|
116
|
+
if (field.type === "string" && field.format === "binary") return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("label", {
|
|
135
117
|
htmlFor: id,
|
|
136
118
|
className: cn(buttonVariants({
|
|
137
119
|
color: "secondary",
|
|
@@ -156,7 +138,7 @@ function FieldInput({ field, fieldName, isRequired, ...props }) {
|
|
|
156
138
|
setValue(e.target.files.item(0));
|
|
157
139
|
},
|
|
158
140
|
hidden: true
|
|
159
|
-
})] })
|
|
141
|
+
})] });
|
|
160
142
|
if (field.enum && field.enum.length > 0) {
|
|
161
143
|
const idx = field.enum.indexOf(value);
|
|
162
144
|
return /* @__PURE__ */ jsxs(Select, {
|
|
@@ -198,7 +180,7 @@ function FieldInput({ field, fieldName, isRequired, ...props }) {
|
|
|
198
180
|
] })]
|
|
199
181
|
});
|
|
200
182
|
const isNumber = field.type === "integer" || field.type === "number";
|
|
201
|
-
return
|
|
183
|
+
return /* @__PURE__ */ jsx(Input, {
|
|
202
184
|
id,
|
|
203
185
|
placeholder: "Enter value",
|
|
204
186
|
type: isNumber ? "number" : "text",
|
|
@@ -208,18 +190,22 @@ function FieldInput({ field, fieldName, isRequired, ...props }) {
|
|
|
208
190
|
if (isNumber) setValue(Number.isNaN(e.target.valueAsNumber) ? void 0 : e.target.valueAsNumber);
|
|
209
191
|
else if (!isNumber) setValue(e.target.value);
|
|
210
192
|
}
|
|
211
|
-
})
|
|
193
|
+
});
|
|
212
194
|
}
|
|
213
195
|
function FieldSet({ field: _field, fieldName, toolbar, name, isRequired, depth = 0, slotType, collapsible = true, ...props }) {
|
|
214
196
|
const { readOnly, writeOnly } = useSchemaScope();
|
|
215
197
|
const field = useResolvedSchema(_field);
|
|
216
198
|
const [show, setShow] = useState(!collapsible);
|
|
217
|
-
const { info, updateInfo } = useFieldInfo(fieldName, field);
|
|
199
|
+
const { info, updateInfo } = useFieldInfo(fieldName, field, depth);
|
|
218
200
|
const id = stringifyFieldKey(fieldName);
|
|
219
201
|
const dataEngine = useDataEngine();
|
|
202
|
+
const [isDefined] = useFieldValue(fieldName, { compute(currentValue) {
|
|
203
|
+
return currentValue !== void 0;
|
|
204
|
+
} });
|
|
220
205
|
if (_field === false) return;
|
|
221
206
|
if (field.readOnly && !readOnly) return;
|
|
222
207
|
if (field.writeOnly && !writeOnly) return;
|
|
208
|
+
if (collapsible && !isDefined && show) setShow(false);
|
|
223
209
|
function renderLabelTrigger(schema = field) {
|
|
224
210
|
if (!collapsible) return renderLabelName();
|
|
225
211
|
return /* @__PURE__ */ jsxs("button", {
|
|
@@ -248,6 +234,14 @@ function FieldSet({ field: _field, fieldName, toolbar, name, isRequired, depth =
|
|
|
248
234
|
})]
|
|
249
235
|
});
|
|
250
236
|
}
|
|
237
|
+
function renderUnsetButton() {
|
|
238
|
+
return /* @__PURE__ */ jsx("button", {
|
|
239
|
+
type: "button",
|
|
240
|
+
onClick: () => dataEngine.delete(fieldName),
|
|
241
|
+
className: "text-fd-muted-foreground hover:text-fd-accent-foreground",
|
|
242
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
|
|
243
|
+
});
|
|
244
|
+
}
|
|
251
245
|
if (info.unionField && field[info.unionField]) {
|
|
252
246
|
const union = field[info.unionField];
|
|
253
247
|
const showSelect = union.length > 1;
|
|
@@ -259,6 +253,7 @@ function FieldSet({ field: _field, fieldName, toolbar, name, isRequired, depth =
|
|
|
259
253
|
field: union[info.oneOf],
|
|
260
254
|
depth: depth + 1,
|
|
261
255
|
slotType: showSelect ? false : slotType,
|
|
256
|
+
collapsible,
|
|
262
257
|
toolbar: /* @__PURE__ */ jsxs(Fragment$1, { children: [showSelect && /* @__PURE__ */ jsx("select", {
|
|
263
258
|
className: "text-xs font-mono",
|
|
264
259
|
value: info.oneOf,
|
|
@@ -284,6 +279,7 @@ function FieldSet({ field: _field, fieldName, toolbar, name, isRequired, depth =
|
|
|
284
279
|
...field,
|
|
285
280
|
type: info.selectedType
|
|
286
281
|
},
|
|
282
|
+
collapsible,
|
|
287
283
|
depth: depth + 1,
|
|
288
284
|
slotType: showSelect ? false : slotType,
|
|
289
285
|
toolbar: /* @__PURE__ */ jsxs(Fragment$1, { children: [showSelect && /* @__PURE__ */ jsx("select", {
|
|
@@ -305,12 +301,13 @@ function FieldSet({ field: _field, fieldName, toolbar, name, isRequired, depth =
|
|
|
305
301
|
return /* @__PURE__ */ jsxs("fieldset", {
|
|
306
302
|
...props,
|
|
307
303
|
className: cn("flex flex-col gap-1.5 col-span-full @container", props.className),
|
|
308
|
-
children: [/* @__PURE__ */ jsxs(
|
|
309
|
-
|
|
304
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
305
|
+
className: fieldLabelVariants(),
|
|
310
306
|
children: [
|
|
311
307
|
renderLabelTrigger(schema),
|
|
312
308
|
slotType ?? /* @__PURE__ */ jsx(FieldLabelType, { children: schemaToString(field) }),
|
|
313
|
-
toolbar
|
|
309
|
+
toolbar,
|
|
310
|
+
!isRequired && isDefined && renderUnsetButton()
|
|
314
311
|
]
|
|
315
312
|
}), show && /* @__PURE__ */ jsx(ObjectInput, {
|
|
316
313
|
field: schema,
|
|
@@ -322,12 +319,13 @@ function FieldSet({ field: _field, fieldName, toolbar, name, isRequired, depth =
|
|
|
322
319
|
if (field.type === "array") return /* @__PURE__ */ jsxs("fieldset", {
|
|
323
320
|
...props,
|
|
324
321
|
className: cn("flex flex-col gap-1.5 col-span-full", props.className),
|
|
325
|
-
children: [/* @__PURE__ */ jsxs(
|
|
326
|
-
|
|
322
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
323
|
+
className: fieldLabelVariants(),
|
|
327
324
|
children: [
|
|
328
325
|
renderLabelTrigger(),
|
|
329
326
|
slotType ?? /* @__PURE__ */ jsx(FieldLabelType, { children: schemaToString(field) }),
|
|
330
|
-
toolbar
|
|
327
|
+
toolbar,
|
|
328
|
+
!isRequired && isDefined && renderUnsetButton()
|
|
331
329
|
]
|
|
332
330
|
}), show && /* @__PURE__ */ jsx(ArrayInput, {
|
|
333
331
|
fieldName,
|
|
@@ -338,12 +336,14 @@ function FieldSet({ field: _field, fieldName, toolbar, name, isRequired, depth =
|
|
|
338
336
|
return /* @__PURE__ */ jsxs("fieldset", {
|
|
339
337
|
...props,
|
|
340
338
|
className: cn("flex flex-col gap-1.5", props.className),
|
|
341
|
-
children: [/* @__PURE__ */ jsxs(
|
|
339
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
340
|
+
className: fieldLabelVariants(),
|
|
342
341
|
htmlFor: id,
|
|
343
342
|
children: [
|
|
344
343
|
renderLabelName(),
|
|
345
344
|
slotType ?? /* @__PURE__ */ jsx(FieldLabelType, { children: schemaToString(field) }),
|
|
346
|
-
toolbar
|
|
345
|
+
toolbar,
|
|
346
|
+
!isRequired && isDefined && renderUnsetButton()
|
|
347
347
|
]
|
|
348
348
|
}), /* @__PURE__ */ jsx(FieldInput, {
|
|
349
349
|
field,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cn } from "../../utils/cn.js";
|
|
2
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../ui/components/select.js";
|
|
3
2
|
import { useQuery } from "../../utils/use-query.js";
|
|
3
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../ui/components/select.js";
|
|
4
4
|
import { Input, labelVariants } from "../../ui/components/input.js";
|
|
5
5
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "../../ui/components/dialog.js";
|
|
6
6
|
import { useEffect, useState } from "react";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { resolveServerUrl, withBase } from "../../utils/url.js";
|
|
4
|
+
import { useServerContext, useServerSelectContext } from "../../ui/contexts/api.js";
|
|
4
5
|
import { cn } from "../../utils/cn.js";
|
|
5
6
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../ui/components/select.js";
|
|
6
|
-
import { useServerContext, useServerSelectContext } from "../../ui/contexts/api.js";
|
|
7
7
|
import { Input, labelVariants } from "../../ui/components/input.js";
|
|
8
8
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "../../ui/components/dialog.js";
|
|
9
9
|
import { useEffect, useRef, useState } from "react";
|
|
@@ -118,7 +118,8 @@ function Field({ fieldName, variable }) {
|
|
|
118
118
|
return /* @__PURE__ */ jsx(Input, {
|
|
119
119
|
id: fieldName,
|
|
120
120
|
value,
|
|
121
|
-
onChange: (e) => setValue(e.target.value)
|
|
121
|
+
onChange: (e) => setValue(e.target.value),
|
|
122
|
+
placeholder: "Enter Value"
|
|
122
123
|
});
|
|
123
124
|
}
|
|
124
125
|
|
|
@@ -21,6 +21,6 @@ declare function APIPlayground({
|
|
|
21
21
|
path,
|
|
22
22
|
method,
|
|
23
23
|
ctx
|
|
24
|
-
}: APIPlaygroundProps): Promise<string | number | bigint | boolean | Iterable<react.ReactNode> |
|
|
24
|
+
}: APIPlaygroundProps): Promise<string | number | bigint | boolean | react_jsx_runtime0.JSX.Element | Iterable<react.ReactNode> | null | undefined>;
|
|
25
25
|
//#endregion
|
|
26
26
|
export { APIPlayground, APIPlaygroundProps, ParameterField, SecurityEntry };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { mergeAllOf } from "../utils/merge-schema.js";
|
|
2
1
|
import { getDefaultValue } from "./get-default-values.js";
|
|
3
|
-
import {
|
|
2
|
+
import { mergeAllOf } from "../utils/merge-schema.js";
|
|
3
|
+
import { createContext, use, useMemo } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { Ajv2020 } from "ajv/dist/2020";
|
|
6
|
-
import { useDataEngine } from "@fumari/stf";
|
|
6
|
+
import { useDataEngine, useFieldValue, useNamespace } from "@fumari/stf";
|
|
7
|
+
import { stringifyFieldKey } from "@fumari/stf/lib/utils";
|
|
7
8
|
|
|
8
9
|
//#region src/playground/schema.tsx
|
|
9
10
|
const SchemaContext = createContext(void 0);
|
|
@@ -50,41 +51,40 @@ function useSchemaScope() {
|
|
|
50
51
|
* @param schema - The JSON Schema to generate initial values.
|
|
51
52
|
* @param depth - The depth to avoid duplicated field name with same schema (e.g. nested `oneOf`).
|
|
52
53
|
*/
|
|
53
|
-
function useFieldInfo(fieldName, schema) {
|
|
54
|
+
function useFieldInfo(fieldName, schema, depth = 0) {
|
|
54
55
|
const { ajv } = use(SchemaContext);
|
|
55
56
|
const engine = useDataEngine();
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
57
|
+
const [info, setInfo] = useFieldValue([], { stf: useNamespace({
|
|
58
|
+
namespace: `field-info:${depth}:${stringifyFieldKey(fieldName)}`,
|
|
59
|
+
initial() {
|
|
60
|
+
const value = engine.get(fieldName);
|
|
61
|
+
const out = { oneOf: -1 };
|
|
62
|
+
const union = getUnion(schema);
|
|
63
|
+
if (union) {
|
|
64
|
+
const [members, field] = union;
|
|
65
|
+
out.oneOf = members.findIndex((item) => ajv.validate(item, value));
|
|
66
|
+
if (out.oneOf === -1) out.oneOf = 0;
|
|
67
|
+
out.unionField = field;
|
|
68
|
+
}
|
|
69
|
+
if (Array.isArray(schema.type)) {
|
|
70
|
+
const types = schema.type;
|
|
71
|
+
out.selectedType = types.find((type) => {
|
|
72
|
+
return ajv.validate({
|
|
73
|
+
...schema,
|
|
74
|
+
type
|
|
75
|
+
}, value);
|
|
76
|
+
}) ?? types[0];
|
|
77
|
+
}
|
|
78
|
+
if (schema.allOf) {
|
|
79
|
+
const merged = mergeAllOf(schema);
|
|
80
|
+
if (typeof merged !== "boolean") out.intersection = { merged };
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
77
83
|
}
|
|
78
|
-
|
|
79
|
-
const merged = mergeAllOf(schema);
|
|
80
|
-
if (typeof merged !== "boolean") out.intersection = { merged };
|
|
81
|
-
}
|
|
82
|
-
return out;
|
|
83
|
-
});
|
|
84
|
-
attachedData.set(fieldName, info);
|
|
84
|
+
}) });
|
|
85
85
|
return {
|
|
86
86
|
info,
|
|
87
|
-
updateInfo
|
|
87
|
+
updateInfo(value) {
|
|
88
88
|
const updated = {
|
|
89
89
|
...info,
|
|
90
90
|
...value
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
import * as Primitive from "@radix-ui/react-accordion";
|
|
6
5
|
import { ChevronRight } from "lucide-react";
|
|
6
|
+
import * as Primitive from "@radix-ui/react-accordion";
|
|
7
7
|
|
|
8
8
|
//#region src/ui/components/accordion.tsx
|
|
9
9
|
function Accordions(props) {
|
|
@@ -5,8 +5,8 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from ".
|
|
|
5
5
|
import { createContext, use, useMemo, useState } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { Check, Copy } from "lucide-react";
|
|
8
|
-
import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
|
|
9
8
|
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
9
|
+
import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
|
|
10
10
|
|
|
11
11
|
//#region src/ui/operation/client.tsx
|
|
12
12
|
function CopyResponseTypeScript({ code }) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { idToTitle } from "../../utils/id-to-title.js";
|
|
2
2
|
import { createMethod, methodKeys } from "../../utils/schema.js";
|
|
3
|
-
import { cn } from "../../utils/cn.js";
|
|
4
|
-
import { Badge, MethodLabel } from "../components/method-label.js";
|
|
5
3
|
import { isMediaTypeSupported } from "../../requests/media/resolve-adapter.js";
|
|
6
4
|
import "../../requests/media/adapter.js";
|
|
5
|
+
import { cn } from "../../utils/cn.js";
|
|
6
|
+
import { Badge, MethodLabel } from "../components/method-label.js";
|
|
7
|
+
import { APIPlayground } from "../../playground/index.js";
|
|
7
8
|
import { Schema } from "../schema/index.js";
|
|
8
9
|
import { UsageTabsProviderLazy } from "./usage-tabs/lazy.js";
|
|
9
10
|
import { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions } from "../components/accordion.js";
|
|
10
11
|
import { UsageTabs } from "./usage-tabs/index.js";
|
|
11
12
|
import { CopyResponseTypeScript, SelectTab, SelectTabTrigger, SelectTabs } from "./client.js";
|
|
12
|
-
import { APIPlayground } from "../../playground/index.js";
|
|
13
13
|
import { RequestTabs, getExampleRequests } from "./request-tabs.js";
|
|
14
14
|
import { ServerProviderLazy } from "../contexts/api.lazy.js";
|
|
15
15
|
import { Fragment } from "react";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { resolveRequestData } from "../../utils/url.js";
|
|
2
2
|
import { getPreferredType, pickExample } from "../../utils/schema.js";
|
|
3
3
|
import { MethodLabel } from "../components/method-label.js";
|
|
4
|
-
import { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions } from "../components/accordion.js";
|
|
5
4
|
import { encodeRequestData } from "../../requests/media/encode.js";
|
|
5
|
+
import { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions } from "../components/accordion.js";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "fumadocs-ui/components/tabs";
|
|
8
8
|
import { sample } from "openapi-sampler";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { joinURL, resolveRequestData, resolveServerUrl, withBase } from "../../../utils/url.js";
|
|
4
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../components/select.js";
|
|
5
4
|
import { useApiContext, useServerSelectContext } from "../../contexts/api.js";
|
|
5
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../components/select.js";
|
|
6
6
|
import { createContext, use, useEffect, useMemo, useRef, useState } from "react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock.core";
|
package/dist/ui/schema/client.js
CHANGED
|
@@ -4,11 +4,11 @@ import { cn } from "../../utils/cn.js";
|
|
|
4
4
|
import { Badge } from "../components/method-label.js";
|
|
5
5
|
import { Fragment, createContext, use, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { cva } from "class-variance-authority";
|
|
8
7
|
import { ChevronDown } from "lucide-react";
|
|
9
|
-
import {
|
|
10
|
-
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
8
|
+
import { cva } from "class-variance-authority";
|
|
11
9
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "fumadocs-ui/components/ui/collapsible";
|
|
10
|
+
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
11
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "fumadocs-ui/components/tabs";
|
|
12
12
|
import { Popover, PopoverContent, PopoverTrigger } from "fumadocs-ui/components/ui/popover";
|
|
13
13
|
|
|
14
14
|
//#region src/ui/schema/client.tsx
|
package/dist/ui/schema/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FormatFlags, schemaToString } from "../../utils/schema-to-string.js";
|
|
2
1
|
import { mergeAllOf } from "../../utils/merge-schema.js";
|
|
2
|
+
import { FormatFlags, schemaToString } from "../../utils/schema-to-string.js";
|
|
3
3
|
import { SchemaUILazy } from "./lazy.js";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "10.3.
|
|
3
|
+
"version": "10.3.11",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"remark-rehype": "^11.1.2",
|
|
78
78
|
"tailwind-merge": "^3.4.1",
|
|
79
79
|
"xml-js": "^1.6.11",
|
|
80
|
-
"@fumari/stf": "
|
|
80
|
+
"@fumari/stf": "1.0.1"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@scalar/api-client-react": "^1.3.96",
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
"json-schema-typed": "^8.0.2",
|
|
89
89
|
"tailwindcss": "^4.1.18",
|
|
90
90
|
"tsdown": "^0.20.3",
|
|
91
|
-
"@fumadocs/tailwind": "0.0.2",
|
|
92
91
|
"eslint-config-custom": "0.0.0",
|
|
92
|
+
"@fumadocs/tailwind": "0.0.2",
|
|
93
93
|
"fumadocs-core": "16.6.5",
|
|
94
94
|
"fumadocs-ui": "16.6.5",
|
|
95
95
|
"tsconfig": "0.0.0"
|