fumadocs-openapi 10.0.2 → 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;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,
|
|
1
|
+
{"version":3,"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WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,kDA4KA"}
|
|
@@ -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',
|
|
@@ -111,9 +113,20 @@ export function FieldInput({ field, fieldName, isRequired, ...props }) {
|
|
|
111
113
|
if (field.type === 'boolean') {
|
|
112
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
|
-
|
|
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" }) }))] }));
|
|
117
130
|
}
|
|
118
131
|
export function FieldSet({ field: _field, fieldName, toolbar, name, isRequired, depth = 0, slotType, collapsible = true, ...props }) {
|
|
119
132
|
const field = useResolvedSchema(_field);
|
|
@@ -159,7 +172,7 @@ function ArrayInput({ fieldName, items, ...props }) {
|
|
|
159
172
|
const { fields, append, remove } = useFieldArray({
|
|
160
173
|
name: fieldName,
|
|
161
174
|
});
|
|
162
|
-
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({
|
|
163
176
|
color: 'outline',
|
|
164
177
|
size: 'icon-xs',
|
|
165
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-core": "16.0.
|
|
73
|
-
"fumadocs-ui": "16.0.
|
|
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",
|