Open ShouheiNishi opened 1 year ago
We currently create a fix. But not sure if you need the ability to determine whether a value such as the following is an integer.
value string | is integer? |
---|---|
9223372036854775807 | integer and fit to int64 |
9223372036854775808 | integer |
9223372036854775807.0 | integer and fit to int64 |
9223372036854775808.0 | integer |
9223372036854775808.1 | not-integer |
9.2233720368547758070e+18 | integer and fit to int64 |
9.2233720368547758071e+18 | not-integer |
0.(100000 digits number 1)e+100000 | integer |
0.(100001 digits number 1)e+100000 | not-integer |
Thanks for this high quality bug report!
I'm not sure I understand your question. Do you mean to ask whether this lib intends to support numbers that don't fit in a double
?
I think it is necessary to specify UseNumber() in the JSON decoder during JSON validation so that integer precision is not lost when setting the default value.
However, encoding/json is not able to unmarshal exponential notation to integer types. https://github.com/golang/go/issues/6384 I can’t decide if all numeric notation allowed by the JSON standard must be validate correctly.
PR https://github.com/getkin/kin-openapi/pull/738
Since the numeric value is converted to float64 during JSON validation in body in function `openapi3filter.ValidateRequestBody’, the precision of integer value in updated request body is lost,
Fix only fix this issue.
and the range check is not performed correctly.
Not fix yet.
Since the numeric value is converted to float64 during JSON validation in body in function `openapi3filter.ValidateRequestBody’, the precision of integer value in updated request body is lost, and the range check is not performed correctly.
You can see this issue in the test code below.