-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Description
Reproduce
import {openapi} from '@elysiajs/openapi'
import {Elysia} from 'elysia'
import {z} from 'zod'
const app = new Elysia().use(openapi()).post('/', ({body}) => body, {
body: z.object({
name: z.literal('Lilith').describe('thing'),
}),
response: {
200: z.object({
name: z.literal('Lilith'),
}),
418: z.object({
error: z.literal("I'm a teapot"),
}),
},
})
console.log(
await app
.handle(new Request('http://localhost/openapi/json'))
.then((res) => res.json().then((spec) => JSON.stringify(spec.paths, null, 2))),
)
The output
{
"openapi": "3.0.3",
"info": {
"title": "Elysia Documentation",
"description": "Development documentation",
"version": "0.0.0"
},
"paths": {
"/": {
"post": {
// "requestBody" is NOT here!
"responses": {}, // <<<--- EMPTY
"operationId": "postIndex"
}
}
},
"components": {
"schemas": {}
}
}
Environment and versions:
Bun v1.2.20
"elysia": "1.4.5"
"@elysiajs/openapi": "1.4.2"
"zod": "4.1.8"
yumartins
Metadata
Metadata
Assignees
Labels
No labels