swagger-api/swagger-node

INVALID_TYPE on Date format field

Echeverrya opened this issue · 0 comments

Hello everyone!
I'm using node/express and swagger-codegen.
I've a "birthday" field on the /users endpoint like the following:

- name: birthday
  description: Data de nascimento do usuário
  required: false
  in: query
  type: string
  format: date

No error is shown on the Swagger Editor.
However, when I try send a POST, using Postman, with the following JSON on the body:

{
     "birthday":"1985-04-12"
}

It throws the following error:

{
    "message": "Request validation failed: Parameter (birthday) is not a valid date string: {{birthday}}",
    "code": "INVALID_TYPE",
    "failedValidation": true,
    "path": [
        "paths",
        "/users",
        "post",
        "parameters",
        "4"
    ],
    "paramName": "birthday"
}

I can't understand the reason.
The Date format I'm using is the specified on Swagger's documentation. YYYY-MM-DD
If I remove the "format: date" from swagger.yaml and try again, it works, because it's just a string.

I'd really appreciate any help!

Thank you in advance