mirror of
https://github.com/zoriya/elysia-swagger.git
synced 2025-12-06 00:36:10 +00:00
db9a910c4bde6f56ec8a74e833e59dcc059364a0
Bumps [bun-types](https://github.com/oven-sh/bun) from 0.7.3 to 1.0.19. - [Release notes](https://github.com/oven-sh/bun/releases) - [Commits](https://github.com/oven-sh/bun/compare/bun-v0.7.3...bun-v1.0.19) --- updated-dependencies: - dependency-name: bun-types dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
@elysiajs/swagger
Plugin for elysia to auto-generate Swagger page.
Installation
bun add @elysiajs/swagger
Example
import { Elysia } from 'elysia'
import { swagger } from '@elysiajs/swagger'
const app = new Elysia()
.use(swagger())
.get('/', () => 'hi', { response: t.String({ description: 'sample description' }) })
.post(
'/json/:id',
({ body, params: { id }, query: { name } }) => ({
...body,
id,
name
}),
{
params: t.Object({
id: t.String()
}),
query: t.Object({
name: t.String()
}),
body: t.Object({
username: t.String(),
password: t.String()
}),
response: t.Object({
username: t.String(),
password: t.String(),
id: t.String(),
name: t.String()
}, { description: 'sample description' })
}
)
.listen(8080);
Then go to http://localhost:8080/swagger.
config
swagger
Customize Swagger config, refers to Swagger 2.0 config
path
@default '/swagger'
The endpoint to expose Swagger
excludeStaticFile
@default true
Determine if Swagger should exclude static files.
exclude
@default []
Paths to exclude from the Swagger endpoint
Languages
TypeScript
98.9%
JavaScript
1.1%