docusaurus-openapi-docs icon indicating copy to clipboard operation
docusaurus-openapi-docs copied to clipboard

Huge swagger.json file is not being processed

Open joaorodr84 opened this issue 1 year ago • 4 comments

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

joaorodr84 avatar Jul 10 '24 00:07 joaorodr84

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.

sserrata avatar Jul 10 '24 00:07 sserrata

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.

hbulens avatar Jul 29 '24 13:07 hbulens

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?

sserrata avatar Jul 29 '24 14:07 sserrata

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.

hbulens avatar Aug 01 '24 15:08 hbulens