diff --git a/src/index.ts b/src/index.ts index 2a1a284..6a7bb87 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ import { Elysia, type InternalRoute } from 'elysia' +import { resolve } from 'node:path'; import { SwaggerUIRender } from './swagger' import { ScalarRender } from './scalar' @@ -64,9 +65,9 @@ export const swagger = async ( const app = new Elysia({ name: '@elysiajs/swagger' }) - app.get(path, function documentation() { + app.get(path, function documentation({ path: reqPath }) { const combinedSwaggerOptions = { - url: `/${relativePath}/json`, + url: resolve(reqPath, '/json'), dom_id: '#swagger-ui', ...swaggerOptions } @@ -83,7 +84,7 @@ export const swagger = async ( const scalarConfiguration: ReferenceConfiguration = { spec: { ...scalarConfig.spec, - url: `/${relativePath}/json` + url: resolve(reqPath, '/json') }, ...scalarConfig }