Adds middleware to your express app to serve the Swagger UI bound to your Swagger document. This acts as living documentation for your API hosted from within your app.
MIT License
1.43k
stars
229
forks
source link
Performance Improvment: Only import required function / file of swagger-ui-dist #352
This PR updates the import of swagger-ui-dist to only load the individual file used to get the path for the static assets, not the code of the static assets themself.
Before the entire dist lib was loaded which contains the entire code, a huge bundle.
I've noticed that in the project I'm working on (https://github.com/juice-shop/juice-shop/) the server takes about 150ms on startup loading the swagger-ui-dist packge.
Chaning his import drastically reduces the amount of code which needs to be loaded on the server side.
For us this means that swagger-ui becomes fast enough to be nearly unmeasurable, improving our total cpu load on start and total server start time by ~10% (~1.2s -> ~1.1s)
I've check briefly, from what I saw this should also work nicely with swagger-ui-dist v5.
Thank you for all the work you do here, much appreciated 🙌
This PR updates the import of
swagger-ui-dist
to only load the individual file used to get the path for the static assets, not the code of the static assets themself. Before the entire dist lib was loaded which contains the entire code, a huge bundle.I've noticed that in the project I'm working on (https://github.com/juice-shop/juice-shop/) the server takes about 150ms on startup loading the swagger-ui-dist packge.
Chaning his import drastically reduces the amount of code which needs to be loaded on the server side. For us this means that swagger-ui becomes fast enough to be nearly unmeasurable, improving our total cpu load on start and total server start time by ~10% (
~1.2s -> ~1.1s
)I've check briefly, from what I saw this should also work nicely with swagger-ui-dist v5.
Thank you for all the work you do here, much appreciated 🙌