From e33534b13fc1a96643136786341de70a358590d5 Mon Sep 17 00:00:00 2001 From: Matias Kiviniemi Date: Tue, 31 Oct 2023 13:52:59 +0200 Subject: [PATCH 1/3] Fixed missin JavaScriptTypeBuilder import --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b2ac94..d131bc4 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ bun add @elysiajs/swagger ## Example ```typescript -import { Elysia } from 'elysia' +import { Elysia, t } from 'elysia' import { swagger } from '@elysiajs/swagger' const app = new Elysia() From 26a040013faff8f87f43afac0eec835f6d9bf961 Mon Sep 17 00:00:00 2001 From: steele123 Date: Tue, 14 Nov 2023 13:48:54 -0500 Subject: [PATCH 2/3] add exclude options --- src/index.ts | 8 ++++++-- src/types.ts | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index ed15ce1..e2ed72a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,7 +21,8 @@ export const swagger = exclude = [], swaggerOptions = {}, theme = `https://unpkg.com/swagger-ui-dist@${version}/swagger-ui.css`, - autoDarkMode = true + autoDarkMode = true, + excludeOptions = true }: ElysiaSwaggerConfig = { documentation: {}, version: '5.9.0', @@ -29,7 +30,8 @@ export const swagger = path: '/swagger' as Path, exclude: [], swaggerOptions: {}, - autoDarkMode: true + autoDarkMode: true, + excludeOptions: true } ) => (app: Elysia) => { @@ -130,6 +132,8 @@ export const swagger = totalRoutes = routes.length routes.forEach((route: InternalRoute) => { + if (excludeOptions && route.method === 'OPTIONS') return + registerSchemaPath({ schema, hook: route.hooks, diff --git a/src/types.ts b/src/types.ts index ab38959..63812b1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -71,4 +71,9 @@ export interface ElysiaSwaggerConfig { * Using poor man dark mode 😭 */ autoDarkMode?: boolean + + /** + * Exclude OPTIONS method from Swagger + */ + excludeOptions?: boolean } From 970d87001ebd7f695d04cfd63006ec960e86a8d3 Mon Sep 17 00:00:00 2001 From: steele123 Date: Wed, 29 Nov 2023 07:58:56 -0500 Subject: [PATCH 3/3] use excludeMethods instead of excludeOptions --- src/index.ts | 6 +++--- src/types.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index e2ed72a..5ff6076 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,7 +22,7 @@ export const swagger = swaggerOptions = {}, theme = `https://unpkg.com/swagger-ui-dist@${version}/swagger-ui.css`, autoDarkMode = true, - excludeOptions = true + excludeMethods = ['OPTIONS'] }: ElysiaSwaggerConfig = { documentation: {}, version: '5.9.0', @@ -31,7 +31,7 @@ export const swagger = exclude: [], swaggerOptions: {}, autoDarkMode: true, - excludeOptions: true + excludeMethods: ['OPTIONS'] } ) => (app: Elysia) => { @@ -132,7 +132,7 @@ export const swagger = totalRoutes = routes.length routes.forEach((route: InternalRoute) => { - if (excludeOptions && route.method === 'OPTIONS') return + if (excludeMethods.includes(route.method)) return registerSchemaPath({ schema, diff --git a/src/types.ts b/src/types.ts index 63812b1..0cb342d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -73,7 +73,7 @@ export interface ElysiaSwaggerConfig { autoDarkMode?: boolean /** - * Exclude OPTIONS method from Swagger + * Exclude methods from Swagger */ - excludeOptions?: boolean + excludeMethods?: string[] }