Integer field in JSON request body is validated as null instead of its value
yonatane opened this issue · 1 comments
yonatane commented
When configuring request body schema with an integer type field and sending a valid request, it produces a validation error with the value considered as null.
Minimal example built by adjusting the docker-compose demo in this repo:
int-example.json
instead of httpbin.json
:
{
"openapi": "3.0.1",
"info": {
"title": "Minimal integer field example",
"version": "0.0.1"
},
"paths": {
"/integer-field": {
"post": {
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"count": {
"type": "integer"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Success"
}
}
}
}
}
}
Add these env vars to the original docker-compose demo:
APIFW_API_SPECS: "/opt/resources/int-example.json"
APIFW_LOG_LEVEL: "DEBUG"
APIFW_ADD_VALIDATION_STATUS_HEADER: "true"
Request (curl):
curl -X POST http://localhost:8080/integer-field \
-H 'Content-Type: application/json' \
-d '{"count":1}'
Error in log:
time=2022-12-12T11:51:11Z level=error msg=request validation error error=request body has an error: doesn't match the schema: Error at "/count": Value is not nullable
Schema:
{
"type": "integer"
}
Value:
null
request_id=#0000000400000001
afr1ka commented
Hello yonatane,
Thank you for the detailed bug description. Will be fixed in v0.6.10.