Open lenertovalucie opened 5 years ago
@apiaryio/adt Could you please verify what is the problem? 5
is a valid int64
number and 0
is a valid int32
number, right? 🤔
Thank you for your quick answer. Yes, exactly. Both values (5 and 0) are valid integers, so where is the problem?
The value 5
is valid in the following schema tested by some validators I have tried:
{
"type": "integer",
"format": "int64"
}
It seems that the validator in Dredd thinks that 5 is not a valid int64. Here is minimal example to reproduce:
$ dredd test.apib https://httpbin.org
fail: body: The json,message property must be an int64 (current value is 5)
HOST: https://httpbin.org
# API Name
## POST /post
+ Request (application/json)
+ Attributes
+ message: 5 (number)
+ Response 200 (application/json)
+ Schema
{
"type": "object",
"properties": {
"json": {
"type": "object",
"properties": {
"message": {
"type": "integer",
"format": "int64"
}
}
}
}
}
Actually, since "int64" is an extension to JSON Schema. It isn't designed the same everywhere. The "int64" format is for the string type in some (https://developers.google.com/discovery/v1/type-format) specs and implementations and I suspect that the validator is treating int64 as a string type whcih here it is a number. NOTE, the Swagger spec says it should be an integer which contradicts other definitions for the int64 format.
I think the best behaviour would be the validator in Dredd using type
to know if it should be an integer or a string which should cover both cases.
int64
properly.
Describe your problem
Dredd returns warning: The id property must be an int64 (current value is 5). The userStatus property must be an int32 (current value is 0).
api-description.yml looks like this:
What's your
dredd --version
output?