-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Is your feature request related to a problem?
For the endpoints with the empty response body I should explicitly define return statement with empty object, otherwise it will be reported as typescript error.
Example:
openapi: '3.0.3'
info:
title: Node App API
version: '0.0.1'
paths:
/api/v1/deleteSomething:
delete:
operationId: deleteSomething
summary: Delete somethig
responses:
'204':
description: Deletedexport const someController = ctrl.createRestController({
deleteSomething: async ctx => {
await someService.delete(ctx)
return {} // Without this statement it will show the TS error
}
})What feature would you like to see?
Improve controller types.
The response should be strictly defined by OpenAPI spec. When it's empty - no explicit return statement needed. When it's not empty - it should show type error about missing properties.
export const someController = ctrl.createRestController({
deleteSomething: async ctx => {
await someService.delete(ctx)
// OK
}
})AND
openapi: '3.0.3'
info:
title: Node App API
version: '0.0.1'
paths:
/api/v1/deleteSomething:
delete:
operationId: deleteSomething
summary: Delete somethig
responses:
'204':
description: Deleted
content:
application/json:
schema:
$ref: '#/components/schemas/SomeSchema'export const someController = ctrl.createRestController({
deleteSomething: async ctx => { // It will show error that there are missing some props from the response from spec
await someService.delete(ctx)
}
})What alternatives have you considered?
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working