From 5158fb8f55c0217c852a5a5d2769e7f6c5d9723f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Asaf=20Karasu?= <69322449+omerasaf01@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:25:53 +0000 Subject: [PATCH 1/3] #157 --- src/index.ts | 12 ++++++------ src/types.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index 2a1a284..3a745f8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,8 +15,8 @@ import type { ElysiaSwaggerConfig } from './types' * * @see https://github.com/elysiajs/elysia-swagger */ -export const swagger = async ( - { +export const swagger = async ({ + slug = "/", //api/ provider = 'scalar', scalarVersion = 'latest', scalarCDN = '', @@ -24,7 +24,7 @@ export const swagger = async ( documentation = {}, version = '5.9.0', excludeStaticFile = true, - path = '/swagger' as Path, + path = slug + 'swagger' as Path, exclude = [], swaggerOptions = {}, theme = `https://unpkg.com/swagger-ui-dist@${version}/swagger-ui.css`, @@ -32,6 +32,7 @@ export const swagger = async ( excludeMethods = ['OPTIONS'], excludeTags = [] }: ElysiaSwaggerConfig = { + slug: "/", // api/ -> Forexample provider: 'scalar', scalarVersion: 'latest', scalarCDN: '', @@ -39,7 +40,7 @@ export const swagger = async ( documentation: {}, version: '5.9.0', excludeStaticFile: true, - path: '/swagger' as Path, + path: 'swagger' as Path, exclude: [], swaggerOptions: {}, autoDarkMode: true, @@ -59,8 +60,7 @@ export const swagger = async ( version: '0.0.0', ...documentation.info } - - const relativePath = path.startsWith('/') ? path.slice(1) : path + const relativePath = (slug + path).startsWith('/') ? path.slice(1) : path const app = new Elysia({ name: '@elysiajs/swagger' }) diff --git a/src/types.ts b/src/types.ts index 5370e38..cfe2952 100644 --- a/src/types.ts +++ b/src/types.ts @@ -21,6 +21,14 @@ export interface ElysiaSwaggerConfig { * @see https://github.com/swagger-api/swagger-ui */ provider?: 'scalar' | 'swagger-ui' + /** + * Choose your provider, Scalar or Swagger UI + * + * @default 'scalar' + * @see https://github.com/scalar/scalar + * @see https://github.com/swagger-api/swagger-ui + */ + slug?: string /** * Version to use for Scalar cdn bundle * From baa3b8d71848c9e4c98adfd568a0011f38fc9e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Asaf=20Karasu?= <69322449+omerasaf01@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:31:51 +0000 Subject: [PATCH 2/3] Path parameter bug was fixed --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 3a745f8..684c9a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,7 +24,7 @@ export const swagger = async ({ documentation = {}, version = '5.9.0', excludeStaticFile = true, - path = slug + 'swagger' as Path, + path = 'swagger' as Path, exclude = [], swaggerOptions = {}, theme = `https://unpkg.com/swagger-ui-dist@${version}/swagger-ui.css`, From 48553596b29461d20c7354aedec9b09d64b0a46b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Asaf=20Karasu?= <69322449+omerasaf01@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:38:32 +0000 Subject: [PATCH 3/3] Comment line was edited --- src/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types.ts b/src/types.ts index cfe2952..c20657f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -22,9 +22,9 @@ export interface ElysiaSwaggerConfig { */ provider?: 'scalar' | 'swagger-ui' /** - * Choose your provider, Scalar or Swagger UI + * Base route for framework integrations * - * @default 'scalar' + * @default '/' * @see https://github.com/scalar/scalar * @see https://github.com/swagger-api/swagger-ui */