mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-26 06:31:49 +00:00
OpenAPI: Fix root schema manipulation with TypeScript definition generation
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-openapi': patch
|
||||
---
|
||||
|
||||
Fix root schema manipulation with TypeScript definition generation
|
||||
@@ -125,11 +125,6 @@ function writeReferences(
|
||||
for (const key in output[name]) {
|
||||
output[name][key] = writeReferences(output[name][key], ctx, stack);
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
if (typeof output[name] === 'object' && !Array.isArray(output[name])) {
|
||||
output[name] = { ...output[name] };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,19 +5,12 @@ export async function getTypescriptSchema(
|
||||
schema: object,
|
||||
dereferenceMap: DereferenceMap,
|
||||
): Promise<string | undefined> {
|
||||
return compile(
|
||||
// re-running on the same schema results in error
|
||||
// because it uses `defineProperty` to define internal references
|
||||
// we clone the schema to fix this problem
|
||||
schema,
|
||||
'Response',
|
||||
{
|
||||
$refOptions: false,
|
||||
schemaToId: dereferenceMap,
|
||||
bannerComment: '',
|
||||
additionalProperties: false,
|
||||
format: true,
|
||||
enableConstEnums: false,
|
||||
},
|
||||
);
|
||||
const cloned = structuredClone({ schema, dereferenceMap });
|
||||
return compile(cloned.schema, 'Response', {
|
||||
$refOptions: false,
|
||||
schemaToId: cloned.dereferenceMap,
|
||||
bannerComment: '',
|
||||
additionalProperties: false,
|
||||
enableConstEnums: false,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user