PaloAltoNetworks / docusaurus-openapi-docs

🦝 OpenAPI plugin for generating API reference docs in Docusaurus v3.
https://docusaurus-openapi.tryingpan.dev
MIT License
636 stars 218 forks source link

Huge swagger.json file is not being processed #884

Open joaorodr84 opened 1 month ago

joaorodr84 commented 1 month ago

I have a swagger.json file with almost 150 000 lines for my API.

I want to generate the documentation (mdx files) with this plugin, but it doesn't run.

yarn docusaurus gen-api-docs myapi

Simply doesn't generate anything and kinda hangs.

Is it because the file is too big?

How do you get around such a problem?

Thanks

sserrata commented 1 month ago

Hi @joaorodr84 have you tried parsing it using other tools, like redoc? If it's in fact too large only strategy that comes to mind would be splitting it up into "micro" specs and/or refactoring it to leverage reusable components as much as possible, which may help reduce the overall size.

hbulens commented 1 month ago

I am having a similar issue. I merely have 10K lines in my swagger.json file, but I get:

Loading of api failed for "\swagger.json" [ERROR] RangeError: Invalid string length at JSON.stringify () at loadAndResolveSpec (\docusaurus-plugin-openapi-docs\lib\openapi\utils\loadAndResolveSpec.js:140:29) at async readOpenapiFiles (\docusaurus-plugin-openapi-docs\lib\openapi\openapi.js:451:19) at async generateApiDocs (\docusaurus-plugin-openapi-docs\lib\index.js:94:28) at async \docusaurus-plugin-openapi-docs\lib\index.js:439:15

Docusaurus 3.4.0 and docusaurus-plugin-openapi-docs 3.0.1.

sserrata commented 1 month ago

Hi @hbulens, I given where the error is occurring, it's possible that circular references could be the root cause. Does your spec parse properly with other OpenAPI tools?

hbulens commented 1 month ago

Hi @hbulens, I given where the error is occurring, it's possible that circular references could be the root cause. Does your spec parse properly with other OpenAPI tools?

That must be it. Our OpenAPI spec does work using Swashbuckle but not with other parsers.