fumadocs-openapi 10.0.1 → 10.0.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.
|
@@ -109,7 +109,7 @@ export default function PlaygroundClient({ route, method = 'GET', securities, pa
|
|
|
109
109
|
const onSubmit = form.handleSubmit((value) => {
|
|
110
110
|
testQuery.start(mapInputs(value));
|
|
111
111
|
});
|
|
112
|
-
return (_jsx(FormProvider, { ...form, children: _jsx(SchemaProvider, { fieldInfoMap: fieldInfoMap, references: references, children: _jsxs("form", { ...rest, className: cn('not-prose flex flex-col rounded-xl border shadow-md overflow-hidden bg-fd-card text-fd-card-foreground', rest.className), onSubmit: onSubmit, children: [_jsx(ServerSelect, {}), _jsxs("div", { className: "flex flex-row items-center gap-2 text-sm p-3 not-last:pb-0", children: [_jsx(MethodLabel, { children: method }), _jsx(Route, { route: route, className: "flex-1" }), _jsx("button", { type: "submit", className: cn(buttonVariants({ color: 'primary', size: 'sm' }), '
|
|
112
|
+
return (_jsx(FormProvider, { ...form, children: _jsx(SchemaProvider, { fieldInfoMap: fieldInfoMap, references: references, children: _jsxs("form", { ...rest, className: cn('not-prose flex flex-col rounded-xl border shadow-md overflow-hidden bg-fd-card text-fd-card-foreground', rest.className), onSubmit: onSubmit, children: [_jsx(ServerSelect, {}), _jsxs("div", { className: "flex flex-row items-center gap-2 text-sm p-3 not-last:pb-0", children: [_jsx(MethodLabel, { children: method }), _jsx(Route, { route: route, className: "flex-1" }), _jsx("button", { type: "submit", className: cn(buttonVariants({ color: 'primary', size: 'sm' }), 'w-14 py-1.5'), disabled: testQuery.isLoading, children: testQuery.isLoading ? (_jsx(LoaderCircle, { className: "size-4 animate-spin" })) : ('Send') })] }), securities.length > 0 && (_jsx(SecurityTabs, { securities: securities, securityId: securityId, setSecurityId: setSecurityId, children: inputs.map((input) => (_jsx(Fragment, { children: input.children }, input.fieldName))) })), _jsx(FormBody, { body: body, parameters: parameters }), testQuery.data ? _jsx(ResultDisplay, { data: testQuery.data }) : null] }) }) }));
|
|
113
113
|
}
|
|
114
114
|
function SecurityTabs({ securities, setSecurityId, securityId, children, }) {
|
|
115
115
|
const [open, setOpen] = useState(false);
|
|
@@ -265,7 +265,7 @@ function useAuthInputs(securities, transform) {
|
|
|
265
265
|
for (const item of inputs) {
|
|
266
266
|
if (!item.mapOutput)
|
|
267
267
|
continue;
|
|
268
|
-
set(cloned, item.fieldName, item.mapOutput(get(
|
|
268
|
+
set(cloned, item.fieldName, item.mapOutput(get(cloned, item.fieldName)));
|
|
269
269
|
}
|
|
270
270
|
return cloned;
|
|
271
271
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../../src/playground/components/inputs.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../../src/playground/components/inputs.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAkDxD,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EAAE,MAAM,EACb,SAAS,EACT,GAAG,KAAK,EACT,EAAE;IACD,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACvC,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,cAAc,CAAC,KAAK,CAAC,uDAwCxB;AAED,wBAAgB,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,2CA8B7D;AA6FD,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,SAAS,EACT,UAAU,EACV,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG;IAC/B,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,uDA2GA;AAED,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EAAE,MAAM,EACb,SAAS,EACT,OAAO,EACP,IAAI,EACJ,UAAU,EACV,KAAS,EACT,QAAQ,EACR,WAAkB,EAClB,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,kDA4KA"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo, useState, } from 'react';
|
|
4
4
|
import { ChevronDown, Plus, Trash2, X } from '../../icons.js';
|
|
5
|
-
import {
|
|
5
|
+
import { useController, useFieldArray, useFormContext } from 'react-hook-form';
|
|
6
6
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../../ui/components/select.js';
|
|
7
7
|
import { Input, labelVariants } from '../../ui/components/input.js';
|
|
8
8
|
import { getDefaultValue } from '../get-default-values.js';
|
|
@@ -94,10 +94,12 @@ function DynamicProperties({ fieldName, filterKey = () => true, getType = () =>
|
|
|
94
94
|
}
|
|
95
95
|
export function FieldInput({ field, fieldName, isRequired, ...props }) {
|
|
96
96
|
const form = useFormContext();
|
|
97
|
-
const { field: { value, onChange, ...restField }, } = useController({
|
|
97
|
+
const { field: { value, onChange, ...restField }, fieldState, } = useController({
|
|
98
98
|
control: form.control,
|
|
99
99
|
name: fieldName,
|
|
100
100
|
});
|
|
101
|
+
if (field.type === 'null')
|
|
102
|
+
return;
|
|
101
103
|
if (field.type === 'string' && field.format === 'binary') {
|
|
102
104
|
return (_jsxs("div", { ...props, children: [_jsx("label", { htmlFor: fieldName, className: cn(buttonVariants({
|
|
103
105
|
color: 'secondary',
|
|
@@ -109,17 +111,22 @@ export function FieldInput({ field, fieldName, isRequired, ...props }) {
|
|
|
109
111
|
}, hidden: true, ...restField })] }));
|
|
110
112
|
}
|
|
111
113
|
if (field.type === 'boolean') {
|
|
112
|
-
return (_jsxs(Select, { value: String(value), onValueChange: (value) => onChange(value === '
|
|
114
|
+
return (_jsxs(Select, { value: String(value), onValueChange: (value) => onChange(value === 'undefined' ? undefined : value === 'true'), disabled: restField.disabled, children: [_jsx(SelectTrigger, { id: fieldName, className: props.className, ...restField, children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "true", children: "True" }), _jsx(SelectItem, { value: "false", children: "False" }), !isRequired && _jsx(SelectItem, { value: "undefined", children: "Unset" })] })] }));
|
|
113
115
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
},
|
|
116
|
+
const isNumber = field.type === 'integer' || field.type === 'number';
|
|
117
|
+
return (_jsxs("div", { ...props, className: cn('flex flex-row gap-2', props.className), children: [_jsx(Input, { id: fieldName, placeholder: "Enter value", type: isNumber ? 'number' : 'text', step: field.type === 'integer' ? 1 : undefined, value: value ?? '', onChange: (e) => {
|
|
118
|
+
if (isNumber && !Number.isNaN(e.target.valueAsNumber)) {
|
|
119
|
+
onChange(e.target.valueAsNumber);
|
|
120
|
+
}
|
|
121
|
+
else if (!isNumber) {
|
|
122
|
+
onChange(e.target.value);
|
|
123
|
+
}
|
|
124
|
+
}, ...restField }), fieldState.isDirty && (_jsx("button", { type: "button",
|
|
125
|
+
// TODO: `react-hook-form` doesn't support setting a value to `undefined` (aka remove the value), if there's a default value defined.
|
|
126
|
+
// the default value is kept by `react-hook-form` internally, we cannot manipulate it.
|
|
127
|
+
// hence, we can only support resetting to the default value.
|
|
128
|
+
// perhaps when we migrate to Tanstack Form, we can reconsider this.
|
|
129
|
+
onClick: () => form.resetField(fieldName), className: "text-fd-muted-foreground", children: _jsx(X, { className: "size-4" }) }))] }));
|
|
123
130
|
}
|
|
124
131
|
export function FieldSet({ field: _field, fieldName, toolbar, name, isRequired, depth = 0, slotType, collapsible = true, ...props }) {
|
|
125
132
|
const field = useResolvedSchema(_field);
|
|
@@ -165,7 +172,7 @@ function ArrayInput({ fieldName, items, ...props }) {
|
|
|
165
172
|
const { fields, append, remove } = useFieldArray({
|
|
166
173
|
name: fieldName,
|
|
167
174
|
});
|
|
168
|
-
return (_jsxs("div", { ...props, className: cn('flex flex-col gap-2', props.className), children: [fields.map((item, index) => (_jsx(FieldSet, { name: _jsxs("span", { className: "text-fd-muted-foreground", children: [name, "[", index, "]"] }), field: items, fieldName: `${fieldName}.${index}`, toolbar: _jsx("button", { type: "button", "aria-label": "Remove Item", className: cn(buttonVariants({
|
|
175
|
+
return (_jsxs("div", { ...props, className: cn('flex flex-col gap-2', props.className), children: [fields.map((item, index) => (_jsx(FieldSet, { name: _jsxs("span", { className: "text-fd-muted-foreground", children: [name, "[", index, "]"] }), field: items, isRequired: true, fieldName: `${fieldName}.${index}`, toolbar: _jsx("button", { type: "button", "aria-label": "Remove Item", className: cn(buttonVariants({
|
|
169
176
|
color: 'outline',
|
|
170
177
|
size: 'icon-xs',
|
|
171
178
|
})), onClick: () => remove(index), children: _jsx(Trash2, {}) }) }, item.id))), _jsxs("button", { type: "button", className: cn(buttonVariants({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.3",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"remark-rehype": "^11.1.2",
|
|
70
70
|
"tinyglobby": "^0.2.15",
|
|
71
71
|
"xml-js": "^1.6.11",
|
|
72
|
-
"fumadocs-
|
|
73
|
-
"fumadocs-
|
|
72
|
+
"fumadocs-core": "16.0.9",
|
|
73
|
+
"fumadocs-ui": "16.0.9"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@scalar/api-client-react": "^1.3.48",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"openapi-types": "^12.1.3",
|
|
83
83
|
"tailwindcss": "^4.1.16",
|
|
84
84
|
"tsc-alias": "^1.8.16",
|
|
85
|
-
"
|
|
86
|
-
"
|
|
85
|
+
"eslint-config-custom": "0.0.0",
|
|
86
|
+
"tsconfig": "0.0.0"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
89
|
"@scalar/api-client-react": "*",
|