-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Description
Just add a debugging log to the official example at https://elysiajs.com/patterns/openapi#openapi-from-types:
import { Elysia, t } from 'elysia'
import { openapi } from '@elysiajs/openapi'
import { fromTypes } from '@elysiajs/openapi/gen'
export const app = new Elysia()
.use(
openapi({
references: fromTypes('src/index.ts')
})
)
.get('/', { test: 'hello' as const })
.post('/json', ({ body, status }) => body, {
body: t.Object({
hello: t.String()
})
})
.listen(3000)
+ console.log(JSON.stringify(fromTypes('src/index.ts')(), null, 2))
And you don't see '200'
under ['/json'].post.responses
alongside ['/json'].post.responses['422']
:
{
"/": {
"get": {
"body": {},
"params": {
"type": "object",
"properties": {}
},
"query": {},
"headers": {},
"response": {
"200": {
"type": "object",
"properties": {
"test": {
"const": "hello",
"type": "string"
}
},
"required": [
"test"
]
}
}
}
},
"/json": {
"post": {
"body": {
"type": "object",
"properties": {
"hello": {
"type": "string"
}
},
"required": [
"hello"
]
},
"params": {
"type": "object",
"properties": {}
},
"query": {},
"headers": {},
"response": {
"422": {
"type": "object",
"properties": {
"type": {
"const": "validation",
"type": "string"
},
"on": {
"type": "string"
},
"summary": {
"type": "string"
},
"message": {
"type": "string"
},
"found": {},
"property": {
"type": "string"
},
"expected": {
"type": "string"
}
},
"required": [
"type",
"on"
]
}
}
}
}
}
Environment and versions:
Bun v1.2.20
"elysia": "1.4.5"
"@elysiajs/openapi": "1.4.2"
"typescript": "5.9.2"
Metadata
Metadata
Assignees
Labels
No labels