Skip to content

Commit

Permalink
fix: correct typing of exclusive maximums and minimums for draft7 jso… (
Browse files Browse the repository at this point in the history
  • Loading branch information
dpwdec authored Jul 9, 2024
1 parent b586dd0 commit fb50d00
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
10 changes: 8 additions & 2 deletions src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ public class JsonSchemaDeserializer
}
},
{
"exclusiveMaximum", (a, n) => { a.ExclusiveMaximum = bool.Parse(n.GetScalarValue()); }
"exclusiveMaximum", (a, n) =>
{
a.ExclusiveMaximum = double.Parse(n.GetScalarValue(), NumberStyles.Float, n.Context.Settings.CultureInfo);
}
},
{
"minimum",
Expand All @@ -71,7 +74,10 @@ public class JsonSchemaDeserializer
}
},
{
"exclusiveMinimum", (a, n) => { a.ExclusiveMinimum = bool.Parse(n.GetScalarValue()); }
"exclusiveMinimum", (a, n) =>
{
a.ExclusiveMinimum = double.Parse(n.GetScalarValue(), NumberStyles.Float, n.Context.Settings.CultureInfo);
}
},
{
"maxLength", (a, n) => { a.MaxLength = int.Parse(n.GetScalarValue(), n.Context.Settings.CultureInfo); }
Expand Down
4 changes: 2 additions & 2 deletions src/LEGO.AsyncAPI/Models/AsyncApiSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class AsyncApiSchema : IAsyncApiReferenceable, IAsyncApiExtensible, IAsyn
/// <summary>
/// follow JSON Schema definition: https://json-schema.org/draft-07/json-schema-release-notes.html.
/// </summary>
public bool? ExclusiveMaximum { get; set; }
public double? ExclusiveMaximum { get; set; }

/// <summary>
/// follow JSON Schema definition: https://json-schema.org/draft-07/json-schema-release-notes.html.
Expand All @@ -52,7 +52,7 @@ public class AsyncApiSchema : IAsyncApiReferenceable, IAsyncApiExtensible, IAsyn
/// <summary>
/// follow JSON Schema definition: https://json-schema.org/draft-07/json-schema-release-notes.html.
/// </summary>
public bool? ExclusiveMinimum { get; set; }
public double? ExclusiveMinimum { get; set; }

/// <summary>
/// follow JSON Schema definition: https://json-schema.org/draft-07/json-schema-release-notes.html.
Expand Down
10 changes: 5 additions & 5 deletions test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class AsyncApiSchema_Should : TestBase
Title = "title1",
MultipleOf = 3,
Maximum = 42,
ExclusiveMinimum = true,
ExclusiveMinimum = 42,
Minimum = 10,
Default = new AsyncApiAny(15),
Type = SchemaType.Integer,
Expand All @@ -37,7 +37,7 @@ public class AsyncApiSchema_Should : TestBase
Title = "title1",
MultipleOf = 3,
Maximum = double.MaxValue,
ExclusiveMinimum = true,
ExclusiveMinimum = double.MinValue,
Minimum = double.MinValue,
Default = new AsyncApiAny(15),
Type = SchemaType.Integer,
Expand Down Expand Up @@ -211,7 +211,7 @@ public class AsyncApiSchema_Should : TestBase
Title = "title1",
MultipleOf = 3,
Maximum = 42,
ExclusiveMinimum = true,
ExclusiveMinimum = 42,
Minimum = 10,
Default = new AsyncApiAny(15),
Type = SchemaType.Integer,
Expand Down Expand Up @@ -307,7 +307,7 @@ public void SerializeAsJson_WithAdvancedSchemaNumber_V2Works()
"type": "integer",
"maximum": 42,
"minimum": 10,
"exclusiveMinimum": true,
"exclusiveMinimum": 42,
"multipleOf": 3,
"default": 15,
"nullable": true,
Expand Down Expand Up @@ -335,7 +335,7 @@ public void SerializeAsJson_WithAdvancedSchemaBigNumbers_V2Works()
"type": "integer",
"maximum": 1.7976931348623157E+308,
"minimum": -1.7976931348623157E+308,
"exclusiveMinimum": true,
"exclusiveMinimum": -1.7976931348623157E+308,
"multipleOf": 3,
"default": 15,
"nullable": true,
Expand Down

0 comments on commit fb50d00

Please sign in to comment.