Skip to content

Commit b3a645b

Browse files
authored
Merge pull request #715 from microsoft/fix/empty-enums
fix: a bug where empty enums would make the conversion fail
2 parents 39bbbc2 + 1abcf49 commit b3a645b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,9 @@ EdmTypeKind.Primitive when GetTypeNameForPrimitive(context, edmTypeReference, do
693693
},
694694
EdmTypeKind.Enum when edmTypeReference.Definition is IEdmEnumType edmEnumType && edmEnumType.Members.FirstOrDefault()?.Name is string firstMemberName =>
695695
JsonValue.Create(firstMemberName),
696+
// in case the enum members are empty which often happens due to hidden members on Microsoft Graph
697+
EdmTypeKind.Enum when edmTypeReference.Definition is IEdmEnumType edmEnumType && edmEnumType.Members.FirstOrDefault()?.Name is null =>
698+
JsonValue.Create(edmTypeReference.FullName()),
696699
EdmTypeKind.Collection => new JsonArray(GetTypeNameForExample(context, edmTypeReference.AsCollection().ElementType(), document)),
697700
EdmTypeKind.TypeDefinition => GetTypeNameForExample(context, new EdmPrimitiveTypeReference(edmTypeReference.AsTypeDefinition().TypeDefinition().UnderlyingType, edmTypeReference.IsNullable), document),
698701
EdmTypeKind.Untyped => new JsonObject(),

0 commit comments

Comments
 (0)