jimblackler / jsonschemafriend

A JSON Schema loader and validator, delivered as a Java library.
Apache License 2.0
49 stars 23 forks source link

type: integer does not match specification #39

Closed kool79 closed 9 months ago

kool79 commented 9 months ago

Specifications (since draft-6) say (https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#name-mathematical-integers): For consistency, integer JSON numbers SHOULD NOT be encoded with a fractional part. (should not == not recommended) But both the properties in json below matches to {"type": "integer"}

 { "a": 5,
   "b": 5.0
 }

while the only integer property is the "a" Note thal library works in expected way when I select draft-3 or draft-4 here: https://tryjsonschematypes.appspot.com/#validate

jimblackler commented 9 months ago

The official test is caled "a float with zero fractional part is an integer"

https://github.com/python-jsonschema/jsonschema/blob/b307f310f86b191dd266bfba1de0eea61f0ee194/json/tests/draft2019-09/type.json#L15

This seems to suggest that b: 5.0 should pass.

kool79 commented 9 months ago

Thanks for link. Actually it is not logical from many points of views, but standard is the standard, even if it is not logical.

By the way, with other library I used {type: number, multipleOf: 1.0} for 5.0 and {type: integer} for 5