Closed ndom91 closed 15 hours ago
Didn't have much time to work on the fork, I will look into that later.
Also if you don't mind, you can disable it as a temporary fix:
export const openapi = createOpenAPI({
generateTypeScriptSchema: false,
});
As the linked issue said
I cannot seem to reproduce the problem, make sure to upgrade to 5.7.4
and provide more details (e.g. the OpenAPI schema or a GitHub repo)
Note it could also be a problem when sampling an example response.
For example, if you made parent_project
a required field, it will be forced to create parent_project
for every new sampled parent_project
, causing a similar problem. In this case, it has to be optional.
I've bumped to 5.7.5
and I'm still seeing the same error (maximum call stack size exceeded
).
Unfortunately the parent_project
field doesn't seem to be listed as required either. For example, the whole Butler_API_Entities_Project
schema:
{
type: 'object',
properties: {
slug: { type: 'string' },
owner: { type: 'string' },
parent_project: { '$ref': '#/components/schemas/Butler_API_Entities_Project' },
name: { type: 'string', description: 'Project Name' },
description: { type: 'string', description: 'Project Description' },
repository_id: { type: 'string', description: 'Repository' },
code_repository_id: { type: 'string', description: 'Code Repository ID' },
created_at: { type: 'string' },
updated_at: { type: 'string' }
},
description: 'Butler_API_Entities_Project model'
}
Could you provide a reproduction?
It's not a minimal reproduciton, but it's relatively small and easy to reproduce :pray:
git clone https://github.com/gitbutlerapp/gitbutler-docs
ndom91/fumadocs-openapi-fix
branchpnpm build
Relevant PR: https://github.com/gitbutlerapp/gitbutler-docs/pull/53
thanks for the info! I think I've found the problem now, json-schema-to-typescript
relies on $ref
property but Fumadocs OpenAPI always use a dereferenced schema for everything, need some refactoring but will fix that soon
Awesome, thanks a lot :pray:
To fix it, you can add title
to the schemas, which will work better as the latest fix will infer it from ref id, resulting a type name like interface Butler_API_Entities_Project
.
What do you mean by "add title
to the schemas" exactly?
{
type: 'object',
title: 'Project',
properties: {
slug: { type: 'string' },
owner: { type: 'string' },
parent_project: { '$ref': '#/components/schemas/Butler_API_Entities_Project' },
name: { type: 'string', description: 'Project Name' },
description: { type: 'string', description: 'Project Description' },
repository_id: { type: 'string', description: 'Repository' },
code_repository_id: { type: 'string', description: 'Code Repository ID' },
created_at: { type: 'string' },
updated_at: { type: 'string' }
},
description: 'Butler_API_Entities_Project model'
}
Ahh okay gotcha. Not sure why exactly that works, but it did the trick haha
Because title
is used as an id to detect cyclic references when the schema is dereferenced, I am going to release the fix together with OpenAPI 3.1 support this month.
To Reproduce
Since issues are disabled on
fuma-nama/json-schema-to-typescript
, I'll post this here.I'm having a similar issues to here with
fumadocs-openapi@5.5.10
.The resulting OpenAPI JSON fails to be parsed and results in a
maximum call stack size exceeded
error when there are cyclic references like the one below:As you can see the
parent_project
property doesn't have any other fields, but the cyclic reference still rbeaks the build with the "max call stack size exceeded" error :thinking:I'm using:
There is a simliar issue in the parent repository to your fork that yuo might be aware of here.
Current vs. Expected behavior
Parse openapi spec JSON successfully
Provide environment information
I've worked around it so far by just dropping self-referencing properties in the effected entities before passing the json file to
fumadocs-openapi
'sgenerateFiles
asinput
.Which area(s) are affected? (Select all that apply)
Integrations (e.g OpenAPI, Typescript DocsGen)
Additional context
No response