Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer field in JSON request body is validated as null instead of its value #54

Closed
yonatane opened this issue Dec 12, 2022 · 1 comment

Comments

@yonatane
Copy link

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
Copy link
Collaborator

afr1ka commented Dec 12, 2022

Hello yonatane,

Thank you for the detailed bug description. Will be fixed in v0.6.10.

@afr1ka afr1ka closed this as completed Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants