Skip to content

Commit 384702c

Browse files
author
Andrew Omondi
committed
chore: refactor test for latest update
1 parent 40f7c29 commit 384702c

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiEdmTypeSchemaGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public static IOpenApiSchema CreateSchema(this ODataContext context, IEdmPrimiti
150150

151151
// Nullable properties are marked with the keyword nullable and a value of true.
152152
// nullable cannot be true when type is empty, often common in anyof/allOf since individual entries are nullable
153-
if (!string.IsNullOrEmpty(schema.Type.ToIdentifier()) && primitiveType.IsNullable)
153+
if (schema.Type.ToIdentifiers() is { Length: > 0 } && primitiveType.IsNullable)
154154
{
155155
openApiSchema.Type |= JsonSchemaType.Null;
156156
}

src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSchemaGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ private static JsonNode GetTypeNameForPrimitive(ODataContext context, IEdmTypeRe
659659
}
660660
else
661661
{
662-
return schema.Type.ToIdentifier() ??
662+
return (schema.Type & ~JsonSchemaType.Null)?.ToIdentifiers()[0] ??
663663
(schema.AnyOf ?? Enumerable.Empty<IOpenApiSchema>())
664664
.Union(schema.AllOf ?? Enumerable.Empty<IOpenApiSchema>())
665665
.Union(schema.OneOf ?? Enumerable.Empty<IOpenApiSchema>())

src/OoasGui/OoasGui.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>net8.0-windows</TargetFramework>
44
<OutputType>WinExe</OutputType>
@@ -17,7 +17,7 @@
1717
<ItemGroup>
1818
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
1919
<PackageReference Include="Microsoft.OData.Edm" Version="8.2.3" />
20-
<PackageReference Include="Microsoft.OpenApi" Version="2.0.0-preview8" />
20+
<PackageReference Include="Microsoft.OpenApi" Version="2.0.0-preview9" />
2121
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
2222
</ItemGroup>
2323
</Project>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ public async Task CreateComplexTypeWithBaseSchemaReturnCorrectSchema()
512512

513513
// Assert
514514
Assert.NotNull(schema);
515-
Assert.True(String.IsNullOrEmpty(schema.Type.ToIdentifier()));
515+
Assert.Null(schema.Type.ToIdentifiers());
516516

517517
Assert.NotNull(schema.AllOf);
518518
Assert.Null(schema.AnyOf);
@@ -660,7 +660,7 @@ public async Task CreateEntityTypeWithBaseSchemaReturnCorrectSchema()
660660

661661
// Assert
662662
Assert.NotNull(schema);
663-
Assert.True(String.IsNullOrEmpty(schema.Type.ToIdentifier()));
663+
Assert.Null(schema.Type.ToIdentifiers());
664664

665665
Assert.NotNull(schema.AllOf);
666666
Assert.Null(schema.AnyOf);
@@ -735,7 +735,7 @@ public void CreateEntityTypeWithCrossReferenceBaseSchemaReturnCorrectSchema()
735735

736736
// Assert
737737
Assert.NotNull(schema);
738-
Assert.True(string.IsNullOrEmpty(schema.Type.ToIdentifier()));
738+
Assert.Null(schema.Type.ToIdentifiers());
739739

740740
Assert.NotNull(schema.AllOf);
741741
Assert.Null(schema.AnyOf);

0 commit comments

Comments
 (0)