Skip to content

Commit 0805d89

Browse files
committed
chore: add check for both null and empty strings
1 parent 6116afe commit 0805d89

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private static IOpenApiReferenceable ResolveReferenceOnHeaderElement(
5959
JsonPointer pointer)
6060
{
6161
if (OpenApiConstants.Examples.Equals(propertyName, StringComparison.Ordinal) &&
62-
mapKey is not null &&
62+
!string.IsNullOrEmpty(mapKey) && mapKey is not null &&
6363
headerElement?.Examples != null &&
6464
headerElement.Examples.TryGetValue(mapKey, out var exampleElement) &&
6565
exampleElement is IOpenApiReferenceable referenceable)
@@ -76,7 +76,7 @@ private static IOpenApiReferenceable ResolveReferenceOnParameterElement(
7676
JsonPointer pointer)
7777
{
7878
if (OpenApiConstants.Examples.Equals(propertyName, StringComparison.Ordinal) &&
79-
mapKey is not null &&
79+
!string.IsNullOrEmpty(mapKey) && mapKey is not null &&
8080
parameterElement?.Examples != null &&
8181
parameterElement.Examples.TryGetValue(mapKey, out var exampleElement) &&
8282
exampleElement is IOpenApiReferenceable referenceable)
@@ -92,7 +92,7 @@ private static IOpenApiReferenceable ResolveReferenceOnResponseElement(
9292
string? mapKey,
9393
JsonPointer pointer)
9494
{
95-
if (mapKey is not null)
95+
if (!string.IsNullOrEmpty(mapKey) && mapKey is not null)
9696
{
9797
if (OpenApiConstants.Headers.Equals(propertyName, StringComparison.Ordinal) &&
9898
responseElement?.Headers != null &&

0 commit comments

Comments
 (0)