Skip to content

Commit 0f77d61

Browse files
committed
Add nullable operator for nullable types
1 parent c074339 commit 0f77d61

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ public static Type MapOpenApiPrimitiveTypeToSimpleType(this OpenApiSchema schema
115115
("string", "uri", false) => typeof(Uri),
116116
("integer", "int32", true) => typeof(int?),
117117
("integer", "int64", true) => typeof(long?),
118-
("integer", null, true) => typeof(int),
118+
("integer", null, true) => typeof(int?),
119119
("number", "float", true) => typeof(float?),
120120
("number", "double", true) => typeof(double?),
121-
("number", null, true) => typeof(double),
121+
("number", null, true) => typeof(double?),
122122
("number", "decimal", true) => typeof(decimal?),
123123
("string", "byte", true) => typeof(byte?),
124124
("string", "date-time", true) => typeof(DateTimeOffset?),

test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class OpenApiTypeMapperTests
2525
{
2626
new object[] { new OpenApiSchema { Type = "integer", Format = "int32"}, typeof(int) },
2727
new object[] { new OpenApiSchema { Type = "integer", Format = null, Nullable = false}, typeof(int) },
28-
new object[] { new OpenApiSchema { Type = "integer", Format = null, Nullable = true}, typeof(int) },
28+
new object[] { new OpenApiSchema { Type = "integer", Format = null, Nullable = true}, typeof(int?) },
2929
new object[] { new OpenApiSchema { Type = "string" }, typeof(string) },
3030
new object[] { new OpenApiSchema { Type = "number", Format = "double" }, typeof(double) },
3131
new object[] { new OpenApiSchema { Type = "number", Format = "float", Nullable = true }, typeof(float?) },

0 commit comments

Comments
 (0)