Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Documentation using Openapi #1967

Open
atulraj85 opened this issue Jan 18, 2025 · 3 comments
Open

API Documentation using Openapi #1967

atulraj85 opened this issue Jan 18, 2025 · 3 comments

Comments

@atulraj85
Copy link

I am using zenstack with nextjs 15. I created a zmodel file and added the plugin to generate documentation for API.

plugin openapi { provider = '@zenstackhq/openapi' output = './openapi.yaml' title = 'My awesome API' version = '0.5.0' summary = 'Created with ZenStack' description = 'My awesome API created with ZenStack' prefix = '/api' }

Then I generated the file, it is about 1.4mb. I tried rendering that file to UI it is taking too much of RAM and crashes the site. Then I uploaded that file to online openapi viewer, it crashed that site too.

I am unaware of how to fix / use it. please help.

There are about 15 (mode) tables in my schema.

@ymc9
Copy link
Member

ymc9 commented Jan 24, 2025

Hi @atulraj85 , by default the openapi plugin emits a schema for each type PrismaClient generates. you can use the "omitInputDetails" to reduce the fidelity of the output and get a smaller result:

https://zenstack.dev/docs/reference/plugins/openapi#options

@atulraj85
Copy link
Author

Thank you for replying @ymc9 . The thing is I am using RESTful API and in options it has mentioned, "Only valid for "rpc" flavor." So this is issue I'm facing.

@ymc9
Copy link
Member

ymc9 commented Jan 29, 2025

Oh, got it, then the "omitInputDetails" option is irrelevant. Swagger UI is known to be inefficient when loading large docs, and I'm not aware of a way to work around.

Do you need all models in the generated doc? If not, you can use the "@@openapi.ignore" attribute to exclude those you don't need. Alternatively, you can also write a post-generation script to process the output file and prune non-essential information (either with JSON directly or with an OAPI parser).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants