This commit is contained in:
saltyaom
2024-01-07 14:14:17 +07:00
3 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -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()
+6 -2
View File
@@ -28,7 +28,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',
@@ -39,7 +40,8 @@ export const swagger =
path: '/swagger' as Path,
exclude: [],
swaggerOptions: {},
autoDarkMode: true
autoDarkMode: true,
excludeMethods: ['OPTIONS']
}
) =>
(app: Elysia) => {
@@ -105,6 +107,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[]
}