Skip to content

Commit fb50d00

Browse files
authored
fix: correct typing of exclusive maximums and minimums for draft7 jso… (#188)
1 parent b586dd0 commit fb50d00

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public class JsonSchemaDeserializer
6161
}
6262
},
6363
{
64-
"exclusiveMaximum", (a, n) => { a.ExclusiveMaximum = bool.Parse(n.GetScalarValue()); }
64+
"exclusiveMaximum", (a, n) =>
65+
{
66+
a.ExclusiveMaximum = double.Parse(n.GetScalarValue(), NumberStyles.Float, n.Context.Settings.CultureInfo);
67+
}
6568
},
6669
{
6770
"minimum",
@@ -71,7 +74,10 @@ public class JsonSchemaDeserializer
7174
}
7275
},
7376
{
74-
"exclusiveMinimum", (a, n) => { a.ExclusiveMinimum = bool.Parse(n.GetScalarValue()); }
77+
"exclusiveMinimum", (a, n) =>
78+
{
79+
a.ExclusiveMinimum = double.Parse(n.GetScalarValue(), NumberStyles.Float, n.Context.Settings.CultureInfo);
80+
}
7581
},
7682
{
7783
"maxLength", (a, n) => { a.MaxLength = int.Parse(n.GetScalarValue(), n.Context.Settings.CultureInfo); }

src/LEGO.AsyncAPI/Models/AsyncApiSchema.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class AsyncApiSchema : IAsyncApiReferenceable, IAsyncApiExtensible, IAsyn
4242
/// <summary>
4343
/// follow JSON Schema definition: https://json-schema.org/draft-07/json-schema-release-notes.html.
4444
/// </summary>
45-
public bool? ExclusiveMaximum { get; set; }
45+
public double? ExclusiveMaximum { get; set; }
4646

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

5757
/// <summary>
5858
/// follow JSON Schema definition: https://json-schema.org/draft-07/json-schema-release-notes.html.

test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class AsyncApiSchema_Should : TestBase
2121
Title = "title1",
2222
MultipleOf = 3,
2323
Maximum = 42,
24-
ExclusiveMinimum = true,
24+
ExclusiveMinimum = 42,
2525
Minimum = 10,
2626
Default = new AsyncApiAny(15),
2727
Type = SchemaType.Integer,
@@ -37,7 +37,7 @@ public class AsyncApiSchema_Should : TestBase
3737
Title = "title1",
3838
MultipleOf = 3,
3939
Maximum = double.MaxValue,
40-
ExclusiveMinimum = true,
40+
ExclusiveMinimum = double.MinValue,
4141
Minimum = double.MinValue,
4242
Default = new AsyncApiAny(15),
4343
Type = SchemaType.Integer,
@@ -211,7 +211,7 @@ public class AsyncApiSchema_Should : TestBase
211211
Title = "title1",
212212
MultipleOf = 3,
213213
Maximum = 42,
214-
ExclusiveMinimum = true,
214+
ExclusiveMinimum = 42,
215215
Minimum = 10,
216216
Default = new AsyncApiAny(15),
217217
Type = SchemaType.Integer,
@@ -307,7 +307,7 @@ public void SerializeAsJson_WithAdvancedSchemaNumber_V2Works()
307307
"type": "integer",
308308
"maximum": 42,
309309
"minimum": 10,
310-
"exclusiveMinimum": true,
310+
"exclusiveMinimum": 42,
311311
"multipleOf": 3,
312312
"default": 15,
313313
"nullable": true,
@@ -335,7 +335,7 @@ public void SerializeAsJson_WithAdvancedSchemaBigNumbers_V2Works()
335335
"type": "integer",
336336
"maximum": 1.7976931348623157E+308,
337337
"minimum": -1.7976931348623157E+308,
338-
"exclusiveMinimum": true,
338+
"exclusiveMinimum": -1.7976931348623157E+308,
339339
"multipleOf": 3,
340340
"default": 15,
341341
"nullable": true,

0 commit comments

Comments
 (0)