-
Notifications
You must be signed in to change notification settings - Fork 264
Description
Describe the bug
When using OpenApiStringReader.Read()
to Deserialize a Json Doc,
System.OverflowException: 'Value was either too large or too small for a Decimal.'
is thrown instead of correctly parsing the value.
To Reproduce
Produce a Json Doc from a Definition containing a Property with a specified range of max or min values larger than decimal
's range, such as 1.7976931348623157E+308 . Try deserializing this JSON Doc with OpenApiStringReader.Read()
.
This was My Model class :
public class MyRequestModel : MyBaseModel
{
[Range(0.0, Double.MaxValue)]
public decimal Amount { get; set; }
- - - - - - - - - - - - - - - - - - - - - - - - -
}
Expected behavior
OpenApiStringReader.Read(
) should correctly deserialize and produce an object model from the given JSON/YAML document without failing.
Screenshots/Code Snippets
Line 36 of OpenAPI.NET\src\Microsoft.OpenApi.Readers\V2\OpenApiSchemaDeserializer.cs
"maximum", (o, n) =>
{
o.Maximum = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture);
}
decimal.Parse
is not able to Parse Double.MaxValue
(1.7976931348623157E+308) since this value is greater than decimal
's range.
Additional context
Add any other context about the problem here.