Merge pull request #68 from steele123/main

add exclude options
This commit is contained in:
SaltyAom
2024-01-07 14:13:46 +07:00
committed by GitHub
2 changed files with 11 additions and 2 deletions
+6 -2
View File
@@ -27,7 +27,8 @@ export const swagger =
exclude = [],
swaggerOptions = {},
theme = `https://unpkg.com/swagger-ui-dist@${version}/swagger-ui.css`,
autoDarkMode = true
autoDarkMode = true,
excludeMethods = ['OPTIONS']
}: ElysiaSwaggerConfig<Path> = {
provider: 'scalar',
scalarVersion: '1.12.5',
@@ -38,7 +39,8 @@ export const swagger =
path: '/swagger' as Path,
exclude: [],
swaggerOptions: {},
autoDarkMode: true
autoDarkMode: true,
excludeMethods: ['OPTIONS']
}
) =>
(app: Elysia) => {
@@ -96,6 +98,8 @@ export const swagger =
totalRoutes = routes.length
routes.forEach((route: InternalRoute) => {
if (excludeMethods.includes(route.method)) return
registerSchemaPath({
schema,
hook: route.hooks,
+5
View File
@@ -100,4 +100,9 @@ export interface ElysiaSwaggerConfig<Path extends string = '/swagger'> {
* Using poor man dark mode 😭
*/
autoDarkMode?: boolean
/**
* Exclude methods from Swagger
*/
excludeMethods?: string[]
}