feTS
feTS copied to clipboard
Inferred responses are not included in the openapi spec
Describe the bug
The TypeBox example mentions
Response type will be automatically inferred from the handler's return type
But the OpenAPI spec that gets generated doesn't have the inferred responses
"responses": { "default": { "description": "" } }
To Reproduce Steps to reproduce the behavior:
import { createRouter, Response, Type } from 'fets'
const router = createRouter().route({
path: '/user/:id',
method: 'POST',
schemas: {
request: {
headers: Type.Object({
authorization: Type.String()
}),
params: Type.Object({
id: Type.String({
format: 'uuid'
})
})
}
},
// Response type will be automatically inferred from the handler's return type
handler: request => {
if (request.params.id !== EXPECTED_UUID) {
return Response.json(
{
message: 'User not found'
},
{
status: 404
}
)
}
return Response.json({
id: request.params.id,
name: 'John Doe'
})
}
})
Expected behavior
The generate openapi.json has well typed responses
Environment:
- OS:
-
package-name...: - NodeJS:
Additional context
Responses are not inferred automatically in typescript. You have to define them explicitly.