Skip to content

property described with multipleOf does not pass the validation #817

@jpaliwoda13

Description

@jpaliwoda13

In my openapi file, I have one property that is described as follows:

Quantity:
    type: number
    maximum: 999999999.99
    minimum: -999999999.99
    multipleOf: 0.01

The problem is that not every value provided as Quantity passes validation.

This part of lib code seems to be responsible for random outcome: kin-openapi/openapi3/schema.go#L1508 as the division value/0.01 sometimes gives a rounded value (so it’s Int and it passes validation), but sometimes it gives decimal outcome and the validation returns an error.

Here are some examples of Quantity for which division by 0.01 returns Int, so the validation passes:
8.11
68.15
2130.46
5895083

And here are some examples of Quantity for which division by 0.01 returns non-Int, so the validation fails:
8.1
2.07
19628.87
323.39
40428.2

I believe some adjustments to this validation should be provided.

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