Skip to content
New issue

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

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

Already on GitHub? # to your account

Speeding up schema generation #1372

Open
bluesurfer opened this issue Jan 30, 2025 · 1 comment
Open

Speeding up schema generation #1372

bluesurfer opened this issue Jan 30, 2025 · 1 comment

Comments

@bluesurfer
Copy link

bluesurfer commented Jan 30, 2025

I have a project with a large number of API endpoints (40 viewsets - approximately 120 endpoints). I am using spectacular for the docs, I fixed all the warnings but still the schema generation takes quite a lot. By running:

python -m cProfile ./manage.py spectacular --format openapi-json --file schema.json

I get this:

14257450 function calls (13330353 primitive calls) in 12.067

The use of extend_schema and extend_schema_view is just for specifying tags and operation_id. Everything else is autogenerated.

So, I understand that spectacular needs to inspect all the code but are there any best practices which I am missing and that may help reduce the generation time?

Is this ticket going to have any impact #1371?

@nijel
Copy link

nijel commented Feb 16, 2025

#1371 reduces time on Weblate OpenAPI by about 30%. You can try applying the patch locally and see how big an impact it has in your case. I guess it will vary a lot, that's why I didn't mention any numbers in the pull request.

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

No branches or pull requests

2 participants