Closed believening closed 2 years ago
This seems to be a mistake in using the standard JSON library. I printed the deserialized test input, and it turns out that the input number have changed.
func main() {
var input map[string]interface{}
var inputJSON = `{
"testIntergerA": 9223372036854775807,
"testIntergerB": 9223372036854775296,
"testIntergerC": 9223372036854775295
}`
_ = json.Unmarshal([]byte(inputJSON), &input)
fmt.Printf("%+v\n", input)
for k, v := range input {
tpe := reflect.TypeOf(v)
kind := tpe.Kind()
fmt.Println(k, ":", kind)
value := reflect.ValueOf(v)
fmt.Println(k, ":", value)
}
}
// output:
// map[testIntergerA:9.223372036854776e+18 testIntergerB:9.223372036854776e+18 testIntergerC:9.223372036854775e+18]
// testIntergerA : float64
// testIntergerA : 9.223372036854776e+18
// testIntergerB : float64
// testIntergerB : 9.223372036854776e+18
// testIntergerC : float64
// testIntergerC : 9.223372036854775e+18
https://github.com/go-openapi/validate/blob/cd349c24ea7afd13ea2935f95dfd92c09031149e/schema_test.go#L30
I added a use case to test the default maximum value of the Integer type, which I expected to be the int64 upper bound, which is 9223372036854775807, but it doesn't look like that.
the result of the unit test function is as follows: