Skip to content

Commit 299ef2a

Browse files
Additional test
1 parent f8bd774 commit 299ef2a

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public void CreatesCollectionResponseSchema(bool enablePagination, bool enableCo
5656
var schemas = context.CreateSchemas();
5757

5858
var stringCollectionResponse = schemas["StringCollectionResponse"];
59-
var flightCollectionResponse = schemas["Microsoft.OData.Service.Sample.TrippinInMemory.Models.FlightCollectionResponse"];
60-
59+
var flightCollectionResponse = schemas["Microsoft.OData.Service.Sample.TrippinInMemory.Models.FlightCollectionResponse"];
60+
6161
if (enablePagination || enableCount)
6262
{
6363
Assert.Collection(stringCollectionResponse.AllOf,
@@ -79,7 +79,7 @@ public void CreatesCollectionResponseSchema(bool enablePagination, bool enableCo
7979
Assert.Equal("array", stringCollectionResponse.Properties["value"].Type);
8080
Assert.Equal("array", flightCollectionResponse.Properties["value"].Type);
8181
Assert.Equal("Microsoft.OData.Service.Sample.TrippinInMemory.Models.Flight", flightCollectionResponse.Properties["value"].Items.Reference.Id);
82-
}
82+
}
8383
}
8484

8585
[Fact]
@@ -903,7 +903,7 @@ public void CreatePropertySchemaForNullableEnumPropertyReturnSchema(OpenApiSpecV
903903
Assert.NotNull(schema);
904904
string json = schema.SerializeAsJson(specVersion);
905905
_output.WriteLine(json);
906-
906+
907907
// Assert
908908
if (specVersion == OpenApiSpecVersion.OpenApi2_0)
909909
{
@@ -956,7 +956,7 @@ public void CreatePropertySchemaWithComputedAnnotationReturnsCorrectSchema(OpenA
956956
""pattern"": ""^-?P([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+([.][0-9]+)?S)?)?$"",
957957
""type"": ""string"",
958958
""readOnly"": true
959-
}".ChangeLineBreaks(), json);
959+
}".ChangeLineBreaks(), json);
960960
}
961961
else
962962
{
@@ -1117,5 +1117,26 @@ public void NonNullableDoublePropertyWithDefaultStringWorks()
11171117
""default"": ""3.1415926535897931""
11181118
}".ChangeLineBreaks(), json);
11191119
}
1120+
1121+
1122+
[Fact]
1123+
public void NonNullableUntypedPropertyWorks()
1124+
{
1125+
ODataContext context = new ODataContext(EdmModelHelper.BasicEdmModel);
1126+
EdmEntityType entitType = new EdmEntityType("NS", "Entity");
1127+
IEdmStructuralProperty property = new EdmStructuralProperty(
1128+
entitType, "UntypedProperty", EdmCoreModel.Instance.GetUntyped());
1129+
1130+
// Act
1131+
var schema = context.CreatePropertySchema(property);
1132+
1133+
// Assert
1134+
Assert.NotNull(schema);
1135+
Assert.Null(schema.Type);
1136+
1137+
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);
1138+
1139+
Assert.Equal("{ }", json);
1140+
}
11201141
}
11211142
}

0 commit comments

Comments
 (0)