Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support parsing schema values exceeding decimal ranges by replacing decimal.Parse with double.Parse #1594

Draft
wants to merge 8 commits into
base: vnext
Choose a base branch
from
35 changes: 0 additions & 35 deletions src/Microsoft.OpenApi.Readers/ParseNodes/ParserHelper.cs

This file was deleted.

6 changes: 3 additions & 3 deletions src/Microsoft.OpenApi.Readers/V2/JsonSchemaDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ internal static partial class OpenApiV2Deserializer
{
"multipleOf", (o, n) =>
{
o.MultipleOf(decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
o.MultipleOf(double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
}
},
{
"maximum", (o, n) =>
{
o.Maximum(decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
o.Maximum(double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
}
},
{
Expand All @@ -48,7 +48,7 @@ internal static partial class OpenApiV2Deserializer
{
"minimum", (o, n) =>
{
o.Minimum(decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
o.Minimum(double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
}
},
{
Expand Down
12 changes: 6 additions & 6 deletions src/Microsoft.OpenApi.Readers/V2/OpenApiHeaderDeserializer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
Expand Down Expand Up @@ -55,25 +55,25 @@ internal static partial class OpenApiV2Deserializer
{
"maximum", (o, n) =>
{
o.Schema = GetOrCreateHeaderSchemaBuilder().Maximum(decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture));
o.Schema = GetOrCreateHeaderSchemaBuilder().Maximum(double.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture));
}
},
{
"exclusiveMaximum", (o, n) =>
{
o.Schema = GetOrCreateHeaderSchemaBuilder().ExclusiveMaximum(decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture));
o.Schema = GetOrCreateHeaderSchemaBuilder().ExclusiveMaximum(bool.Parse(n.GetScalarValue()));
}
},
{
"minimum", (o, n) =>
{
o.Schema = GetOrCreateHeaderSchemaBuilder().Minimum(decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture));
o.Schema = GetOrCreateHeaderSchemaBuilder().Minimum(double.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture));
}
},
{
"exclusiveMinimum", (o, n) =>
{
o.Schema = GetOrCreateHeaderSchemaBuilder().ExclusiveMinimum(decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture));
o.Schema = GetOrCreateHeaderSchemaBuilder().ExclusiveMinimum(bool.Parse(n.GetScalarValue()));
}
},
{
Expand Down Expand Up @@ -115,7 +115,7 @@ internal static partial class OpenApiV2Deserializer
{
"multipleOf", (o, n) =>
{
o.Schema = GetOrCreateHeaderSchemaBuilder().MultipleOf(decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture));
o.Schema = GetOrCreateHeaderSchemaBuilder().MultipleOf(double.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture));
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
Expand Down Expand Up @@ -72,13 +72,13 @@ internal static partial class OpenApiV2Deserializer
{
"minimum", (o, n) =>
{
o.Schema = GetOrCreateParameterSchemaBuilder().Minimum(decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture));
o.Schema = GetOrCreateParameterSchemaBuilder().Minimum(double.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture));
}
},
{
"maximum", (o, n) =>
{
o.Schema = GetOrCreateParameterSchemaBuilder().Maximum(decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture));
o.Schema = GetOrCreateParameterSchemaBuilder().Maximum(double.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture));
}
},
{
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.OpenApi.Readers/V3/JsonSchemaDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ internal static partial class OpenApiV3Deserializer
{
"multipleOf", (o, n) =>
{
o.MultipleOf(decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
o.MultipleOf(double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
}
},
{
"maximum", (o, n) =>
{
o.Maximum(decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
o.Maximum(double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
}
},
{
Expand All @@ -49,7 +49,7 @@ internal static partial class OpenApiV3Deserializer
{
"minimum", (o, n) =>
{
o.Minimum(decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
o.Minimum(double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
}
},
{
Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.OpenApi.Readers/V31/JsonSchemaDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,31 @@ internal static partial class OpenApiV31Deserializer
{
"multipleOf", (o, n) =>
{
o.MultipleOf(decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
o.MultipleOf(double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
}
},
{
"maximum", (o, n) =>
{
o.Maximum(decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
o.Maximum(double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
}
},
{
"exclusiveMaximum", (o, n) =>
{
o.ExclusiveMaximum(decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
o.ExclusiveMaximum(double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
}
},
{
"minimum", (o, n) =>
{
o.Minimum(decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
o.Minimum(double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
}
},
{
"exclusiveMinimum", (o, n) =>
{
o.ExclusiveMinimum(decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
o.ExclusiveMinimum(double.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture));
}
},
{
Expand Down
Loading
Loading