Improve rendering time for API docs #2443

Closed
opened 2025-12-29 18:18:55 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Mar 7, 2019).

This issue was split off from #2665.

Environment

  • Python version: 3.5.2
  • NetBox version: 2.5.7

Steps to Reproduce

  1. View the API documentation at /api/docs/.

Expected Behavior

The documentation should be rendered within an acceptable amount of time.

Observed Behavior

The page takes a noticeably long time to load, even to the point of prompting the user to kill the script running to render the docs.

Per @axnsan12 on #2665:

This is a real issue, with a two-sided cause:

  • due to some unfortunate design choices, drf-yasg is quite slow; on my machine the XHR request for the swagger document takes around 10 seconds, and there's not really much that can be done to improve this
  • drf-yasg configures swagger-ui with a default defaultModelsExpandDepth of 3, which means the models section at the bottom is fully expanded; this is the main cause of the initial stuttering

You could mitigate the first point by either

a. caching the generated schema
b. pre-rendering the schema during packaging, deployment or app startup

Originally created by @jeremystretch on GitHub (Mar 7, 2019). This issue was split off from #2665. ### Environment * Python version: 3.5.2 * NetBox version: 2.5.7 ### Steps to Reproduce 1. View the API documentation at `/api/docs/`. ### Expected Behavior The documentation should be rendered within an acceptable amount of time. ### Observed Behavior The page takes a noticeably long time to load, even to the point of prompting the user to kill the script running to render the docs. Per @axnsan12 on #2665: > This is a real issue, with a two-sided cause: > > - due to some unfortunate design choices, drf-yasg is quite slow; on my machine the XHR request for the swagger document takes around 10 seconds, and there's not really much that can be done to improve this > - drf-yasg configures swagger-ui with a default `defaultModelsExpandDepth` of 3, which means the models section at the bottom is fully expanded; this is the main cause of the initial stuttering > > You could mitigate the first point by either > > a. caching the generated schema > b. pre-rendering the schema during packaging, deployment or app startup
adam added the type: bugstatus: accepted labels 2025-12-29 18:18:55 +01:00
adam closed this issue 2025-12-29 18:18:55 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2443