elysiajs / elysia-swagger

A plugin for Elysia to auto-generate Swagger page
MIT License
84 stars 45 forks source link

Scalar CDN Option #95

Closed jmcudd closed 8 months ago

jmcudd commented 8 months ago

Currently the URL to the scalar bundle is hardcoded to the jsdeliver.net CDN. This PR added an additional option (scalarCDN) so the URL to the scalar bundle can be explicitly set. This is useful if a user wishes to host the scalar bundle themselves. When the scalarCDN option is set, the scalarVersion is ignored.

This change maintains backwards compatibility, and users who have scalarVersion set, will still get the scalar bundle from the default jsdelivr.net CDN.

Example usage:

const server = new Elysia().use(html).use(
  swagger({
    provider: "scalar",
    scalarCDN: "https://unpkg.com/@scalar/api-reference@1.13.10/dist/browser/standalone.js"
    //scalarCDN: "/public/standalone.min.js" //Served locally
  })
);