multipleOf validation fails when the value is fractional
See original GitHub issueDescribe the bug
Given an openAPI spec that contains validation of multipleOf: 0.1
for a double
type, there are several valid values for which the validation fails, and therefor the API request is not sent.
To Reproduce
Steps to reproduce the behavior:
- Use autorest to generate a typescript client with the following type contained
- Attempt to call the API with a value of 2.0
- Observe that the validation fails and the command is not sent
fractionalValue:
type: number
format: double
minimum: 0
maximum: 100
multipleOf: 0.1
example: 0.1
Expected behavior
For a multipleOf value of 0.1, all of the following values (and others) should be valid:
- 0.1
- 0.2
- 1
- 2
Additional context
I believe this may be resolved by changing line 57 of https://github.com/Azure/ms-rest-js/blob/45f89c90414db812e4950185ffe7f9f6becb5664/lib/serializer.ts to use an epsilon value of MultipleOf
when the type is double.
This may include false positives that I have not considered. However, for client-side validation false positives are expected, since the client does not have full context, and will rely on server validation in other scenarios.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (7 by maintainers)
I have sent a note to the Autorest crew abount these validations and based on their input, I will decide on removing the constraints.
Removed the constraints check. Closing this issue