From 56e1ba35613188474b26f010d82097ecf7388caa Mon Sep 17 00:00:00 2001 From: jimmy-guzman Date: Sun, 13 Oct 2024 00:58:34 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20prevent=20failed=20to=20f?= =?UTF-8?q?etch=20spec=20from=20URL=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 2a1a284..c205c72 100644 --- a/src/index.ts +++ b/src/index.ts @@ -62,11 +62,13 @@ export const swagger = async ( const relativePath = path.startsWith('/') ? path.slice(1) : path + const openAPISpecUrl = relativePath === '' ? `/json` : `/${relativePath}/json` + const app = new Elysia({ name: '@elysiajs/swagger' }) app.get(path, function documentation() { const combinedSwaggerOptions = { - url: `/${relativePath}/json`, + url: openAPISpecUrl, dom_id: '#swagger-ui', ...swaggerOptions } @@ -83,7 +85,7 @@ export const swagger = async ( const scalarConfiguration: ReferenceConfiguration = { spec: { ...scalarConfig.spec, - url: `/${relativePath}/json` + url: openAPISpecUrl }, ...scalarConfig }