Skip to content

Commit 06fb78f

Browse files
chore: further linting to reduce looping
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent cba3dda commit 06fb78f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Microsoft.OpenApi/Models/JsonSchemaReference.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,12 @@ protected override void SetAdditional31MetadataFromMapNode(JsonObject jsonObject
157157

158158
// Extensions (properties starting with "x-")
159159
foreach (var property in jsonObject
160-
.Where(static p => p.Key.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase)))
160+
.Where(static p => p.Key.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase))
161+
.Where(static p => p.Value is JsonNode))
161162
{
162-
if (property.Value is JsonNode extensionValue)
163-
{
164-
Extensions ??= new Dictionary<string, IOpenApiExtension>(StringComparer.OrdinalIgnoreCase);
165-
Extensions[property.Key] = new JsonNodeExtension(extensionValue.DeepClone());
166-
}
163+
var extensionValue = (JsonNode)property.Value!;
164+
Extensions ??= new Dictionary<string, IOpenApiExtension>(StringComparer.OrdinalIgnoreCase);
165+
Extensions[property.Key] = new JsonNodeExtension(extensionValue.DeepClone());
167166
}
168167
}
169168
}

0 commit comments

Comments
 (0)