diff --git a/.changeset/beige-snails-cover.md b/.changeset/beige-snails-cover.md new file mode 100644 index 00000000..86b96d93 --- /dev/null +++ b/.changeset/beige-snails-cover.md @@ -0,0 +1,5 @@ +--- +'@hono/swagger-ui': patch +--- + +perf: use jsdelivr instead of unpkg to serve swagger-ui assets diff --git a/packages/swagger-ui/src/swagger/resource.ts b/packages/swagger-ui/src/swagger/resource.ts index 26cfc45f..dc456a59 100644 --- a/packages/swagger-ui/src/swagger/resource.ts +++ b/packages/swagger-ui/src/swagger/resource.ts @@ -8,7 +8,9 @@ type ResourceConfig = { } export const remoteAssets = ({ version }: ResourceConfig): AssetURLs => { - const url = `https://unpkg.com/swagger-ui-dist${version !== undefined ? `@${version}` : ''}` + const url = `https://cdn.jsdelivr.net/npm/swagger-ui-dist${ + version !== undefined ? `@${version}` : '' + }` return { css: [`${url}/swagger-ui.css`], diff --git a/packages/swagger-ui/test/index.test.ts b/packages/swagger-ui/test/index.test.ts index c65be060..0549b0aa 100644 --- a/packages/swagger-ui/test/index.test.ts +++ b/packages/swagger-ui/test/index.test.ts @@ -8,8 +8,8 @@ describe('SwaggerUI Rendering', () => { expect(SwaggerUI({ url }).toString()).toEqual(`