Elysia plugin to add OpenAPI documentation.
bun add @elysia/openapiimport { Elysia, t } from 'elysia'
import { openapi } from '@elysia/openapi'
const app = new Elysia()
.use(openapi())
.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(3000)Then go to http://localhost:3000/openapi.
@default true Enable/Disable the plugin
OpenAPI documentation information
@see https://spec.openapis.org/oas/v3.0.3.html
Configuration to exclude paths or methods from documentation
List of methods to exclude from documentation
List of paths to exclude from documentation
@default true
Exclude static file routes from documentation
List of tags to exclude from documentation
@default '/openapi'
The endpoint to expose OpenAPI documentation frontend
@default 'scalar'
OpenAPI documentation frontend between:
Additional OpenAPI reference for each endpoint
Scalar configuration, refers to Scalar config
@default '/${path}/json'
The endpoint to expose OpenAPI specification in JSON format
Swagger config, refers to Swagger config
See documentation for more details.