fuma-nama / fumadocs

The beautiful docs framework for Next.js. Alternative to Nextra
https://fumadocs.vercel.app
MIT License
1.36k stars 78 forks source link

OpenAPI: Circular Dependency Error #847

Open shunkakinoki opened 1 week ago

shunkakinoki commented 1 week ago

To Reproduce

Put this as one of OpenAPI's generated mdx files

---
title: Returns a list of assets
full: true
_openapi:
  method: GET
  route: /asset_change/list
  toc: []
  structuredData:
    headings: []
    contents: []
---

<APIPage document={"https://api.light.so/api-docs/openapi.json"} operations={[{"path":"/asset_change/list","method":"get"}]} hasHead={false} />

Which has a circular dependency in the OpenAPI (AssetChange schema includes Token)

leads to an error as below:

Error occurred prerendering page "/asset_change/v1_asset_change_list_handler". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'properties' -> object with constructor 'Object'
    |     property 'group' -> object with constructor 'Object'
    |     ...
    |     property 'tokens' -> object with constructor 'Object'
    --- property 'items' closes the circle
    at JSON.stringify (<anonymous>)

Current vs. Expected behavior

Should not error

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10

Which area(s) are affected? (Select all that apply)

Integrations (e.g OpenAPI, Typescript DocsGen)

Additional context

No response

shunkakinoki commented 1 week ago

Thank you for the awesome repo - just want to flag this and potentially help here 🙇‍♂️

fuma-nama commented 6 days ago

Minimal reproduction required