Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

OverflowException when Deserializing Json Doc with Double.MaxValue #1106

Copy link
Copy link
@Afsalmc

Description

@Afsalmc
Issue body actions

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.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugA broken experienceA broken experience

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.