mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
OpenAPI: Fix self-referencing schema types
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-openapi': patch
|
||||
---
|
||||
|
||||
Fix self-referencing schema types
|
||||
@@ -24,4 +24,5 @@ export const { getPage, getPages, pageTree } = loader({
|
||||
|
||||
export const openapi = createOpenAPI({
|
||||
documentOrPath: path.resolve('./unkey.json'),
|
||||
generateTypeScriptSchema: false,
|
||||
});
|
||||
|
||||
@@ -89,7 +89,6 @@ export function Operation({
|
||||
required: body.required ?? false,
|
||||
render: ctx,
|
||||
allowFile: type === 'multipart/form-data',
|
||||
stack: [],
|
||||
}}
|
||||
/>
|
||||
</Fragment>,
|
||||
@@ -130,8 +129,6 @@ export function Operation({
|
||||
writeOnly: method.method !== 'GET',
|
||||
required: param.required ?? false,
|
||||
render: ctx,
|
||||
allowFile: false,
|
||||
stack: [],
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
|
||||
@@ -28,10 +28,12 @@ interface Context {
|
||||
|
||||
/**
|
||||
* Parse binary format string to be files
|
||||
*
|
||||
* @defaultValue false
|
||||
*/
|
||||
allowFile: boolean;
|
||||
allowFile?: boolean;
|
||||
|
||||
stack: OpenAPI.SchemaObject[];
|
||||
stack?: OpenAPI.SchemaObject[];
|
||||
|
||||
render: RenderContext;
|
||||
}
|
||||
@@ -58,6 +60,9 @@ export function Schema({
|
||||
(schema.writeOnly === true && !ctx.writeOnly)
|
||||
)
|
||||
return null;
|
||||
ctx.allowFile ??= true;
|
||||
const stack = ctx.stack ?? [];
|
||||
|
||||
const { renderer } = ctx.render;
|
||||
const child: ReactNode[] = [];
|
||||
|
||||
@@ -169,9 +174,7 @@ export function Schema({
|
||||
...(schema.type === 'array' ? [schema.items] : []),
|
||||
]
|
||||
.map(noRef)
|
||||
.filter((s) => isComplexType(s) && !ctx.stack.includes(s));
|
||||
|
||||
ctx.stack.push(schema);
|
||||
.filter((s) => isComplexType(s) && !stack.includes(s));
|
||||
|
||||
const renderedMentionedTypes = mentionedObjectTypes.map((s, idx) => {
|
||||
return (
|
||||
@@ -184,6 +187,7 @@ export function Schema({
|
||||
schema={noRef(s)}
|
||||
ctx={{
|
||||
...ctx,
|
||||
stack: [schema, ...stack],
|
||||
parseObject: true,
|
||||
required: false,
|
||||
}}
|
||||
@@ -193,7 +197,6 @@ export function Schema({
|
||||
});
|
||||
|
||||
child.push(...renderedMentionedTypes);
|
||||
ctx.stack.pop();
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user