middleware
middleware copied to clipboard
[@hono/swagger-ui] Is it possible to ship swagger-ui-dist assets ?
Hello all!
I am working in a very secure environment. I cannot afford to use links to internet resources, like swagger-ui assets.
Is there any way I can bundle them with my server app and tell hono-swagger-ui to use this local assets ?
Thank you.
Hi @TitoVince35
Thanks for the issue.
@sor4chi @naporin0624 Can you handle this issue?
Hi, @TitoVince35
It would certainly be possible to include that as a feature. I am just concerned about the dependency increasing it would create on the file system, bundlers, etc.
If you want to achieve that with the current hono-stack, how about just simply exporting the openapi json from @hono/zod-openapi and delivering the static assets after bundling using serveStatic?
hii, @TitoVince35
If you are concerned about non origin requests in the environment where swagger-ui is run, why not fetch resources from unpkg in advance on the server and embed the results in script or style?
The swagger-ui has an option to get a specific swagger-ui-dist version, so you can fix the output js and css.
This is a technique like cloudflare font optimized.
<link rel="stylesheet" href="https://unpkg.com/[email protected]/swagger-ui.css" />
<script src="https://unpkg.com/[email protected]/swagger-ui-bundle.js" crossorigin></script>
We investigated to see if these were reading additional assets and found that they were not, so we can simply fetch and expand the text.
But doing this makes the html very huge ....
@sor4chi how does one export the openapi json as a static file? Can you provide a snippet?
Hi, @platform-kit It’s simply setting up a Hono server with OpenAPI, making requests to the endpoint where OpenAPI is served, and saving the results as JSON. https://github.com/sor4chi/hono-openapi-export-sample