-
Notifications
You must be signed in to change notification settings - Fork 677
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
Swashbuckle assets need compression and minification #467
Comments
I too have this problem, it makes this version of swashbuckle nearly unusable and should be a pretty minor change to use minified version. |
I wrote a middleware that minifies everything what comes from /swagger url but it needs some extra work to function properly - somehow it messes up with api responses in SwaggerUI |
@centur - I was going to suggest a DelegatingHandler (see http://www.asp.net/web-api/overview/advanced/http-message-handlers) for intercepting the swagger request and applying additional customization (authorization, compression etc.). Of course if you're using OWIN, you could achieve the same result with middleware. @daward - For the next release, I'll update the swagger-ui index.html served up by SB to reference the minified version of swagger-ui.js. In the meantime though, you could achieve the same thing by injecting your own version (copied from https://github.com/domaindrivendev/Swashbuckle/blob/v5.2.1/Swashbuckle.Core/SwaggerUi/CustomAssets/index.html) with the modified reference. See the readme for details - https://github.com/domaindrivendev/Swashbuckle#provide-your-own-index-file. On a final note, I switched to extension-less URL's to avoid the need for setting runAllManagedModulesForAllRequests and hence the associated perf. concerns. I hadn't anticipated that browsers would not cache assets as a result and that's an unfortunate side effect. It's worth noting that extensionless URL's will not be used in the next major version (which will be 6.0.0), targeting AspNet 6.0. |
Just in case anyone wants it now - here is the simple gzip middleware that compresses js and css on the fly (OWIN based) |
Using minified swagger-ui in v5.2.2 - now available |
Javascript and css assets, that are part of SwaggerUI need minification and compression (as in Swashbuckle.Core.5.2.1).
E.g.
Downloading 1.5 Mb of javascript everytime when opening Swagger UI is not the best experience.
Also as it is extension-less asset - it not being cached properly by client browsers.
I tried to add GZip compression using Global filter in webapi pipeline, but seems that Swashbuckle somehow ignores global setup.
It'd be nice to enable some way to configure filters for /swagger route so we can protect this UI it with basic auth, add compression and modify some behaviour if needed (main idea is to protect UI with auth and add compression to outputs)
The text was updated successfully, but these errors were encountered: