deepkit-framework
deepkit-framework copied to clipboard
Array does not work with HttpBody
@http.POST('')
async stuff(body: HttpBody<string[]>) {
Debugger shows: This route has no body defined.
Sending data results in a Validation error:
{
"message": "Validation error:\n(type): Not an array",
"errors": [
{
"path": "",
"code": "type",
"message": "Not an array"
}
]
}
If it's not intended to use arrays with HttpBody a remark in the docs might be good.
What's the request's body and header?
I stumbled across this problem again and found my own bugreport :-)
@http.POST('/example')
async example(exampleDtoList: HttpBody<ExampleDto[]>) {
HttpBody validation fails:
{
"message": "Validation error:\n(type): Not an array",
"errors": [
{
"path": "",
"code": "type",
"message": "Not an array"
}
]
}
I checked and it is clearly a json array transported with Content-Type: application/json
Workaround:
@http.POST('/example')
async example(request: HttpRequest) {
const body = await request.readBodyText()
const exampleDtoList = deserialize<ExampleDto[]>(JSON.parse(body));
version 1.0.1-alpha.97