From fee5ef9189324fe905eeccf97de07ad63f79dbd0 Mon Sep 17 00:00:00 2001 From: kaandura Date: Tue, 30 Apr 2024 00:22:45 +0300 Subject: [PATCH 1/2] feature: exclude tags --- src/index.ts | 7 +++++-- src/types.ts | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index ec5d1da..e1e4bbc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,7 +30,8 @@ export const swagger = swaggerOptions = {}, theme = `https://unpkg.com/swagger-ui-dist@${version}/swagger-ui.css`, autoDarkMode = true, - excludeMethods = ['OPTIONS'] + excludeMethods = ['OPTIONS'], + excludeTags = [] }: ElysiaSwaggerConfig = { provider: 'scalar', scalarVersion: 'latest', @@ -43,7 +44,8 @@ export const swagger = exclude: [], swaggerOptions: {}, autoDarkMode: true, - excludeMethods: ['OPTIONS'] + excludeMethods: ['OPTIONS'], + excludeTags: [] } ) => (app: Elysia) => { @@ -136,6 +138,7 @@ export const swagger = openapi: '3.0.3', ...{ ...documentation, + tags: (documentation?.tags as {name: string; description: string}[])?.filter((tag) => !excludeTags?.includes(tag?.name)), info: { title: 'Elysia Documentation', description: 'Development documentation', diff --git a/src/types.ts b/src/types.ts index e2bd09c..1c41e04 100644 --- a/src/types.ts +++ b/src/types.ts @@ -111,4 +111,9 @@ export interface ElysiaSwaggerConfig { * Exclude methods from Swagger */ excludeMethods?: string[] + + /** + * Exclude tags from Swagger or Scalar + */ + excludeTags?: string[] } From 1d63b8522a34446f4501c434cb812814d7c0ec73 Mon Sep 17 00:00:00 2001 From: kaandura Date: Tue, 30 Apr 2024 00:40:07 +0300 Subject: [PATCH 2/2] remove documentation?.tags type --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index e1e4bbc..a247e45 100644 --- a/src/index.ts +++ b/src/index.ts @@ -138,7 +138,7 @@ export const swagger = openapi: '3.0.3', ...{ ...documentation, - tags: (documentation?.tags as {name: string; description: string}[])?.filter((tag) => !excludeTags?.includes(tag?.name)), + tags: documentation.tags?.filter((tag) => !excludeTags?.includes(tag?.name)), info: { title: 'Elysia Documentation', description: 'Development documentation',