Skip to content

Numbers with zero fractional should be considered valid for integer #533

@wezleytsai

Description

@wezleytsai

According to the spec, a JSON number with zero fractional part, such as 5.0, is considered compliant to the schema type integer. See https://json-schema.org/understanding-json-schema/reference/numeric. JSON-java maps any number with a fractional, even if 0, to BigDecimal, but this library requires an Integer and throws expected type: Integer, found: BigDecimal based on the type alone. IMO this library should evaluate any Number and validate based on whether it is an integer.

Here is a minimal repo that reproduces the validation exception:
https://github.com/wezleytsai/json-schema/blob/master/src/main/java/Main.java

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions