Skip to content

Commit 38bd152

Browse files
committed
Fix codeQL warnings
1 parent cc1439e commit 38bd152

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

src/Microsoft.OpenApi/Models/OpenApiComponents.cs

-3
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,6 @@ private void RenderComponents(IOpenApiWriter writer, Action<IOpenApiWriter, IOpe
339339
writer.WriteStartObject();
340340
if (loops.TryGetValue(typeof(OpenApiSchema), out List<object> schemas))
341341
{
342-
var openApiSchemas = schemas.Cast<OpenApiSchema>().Distinct().ToList()
343-
.ToDictionary(k => k.Reference.Id);
344-
345342
writer.WriteOptionalMap(OpenApiConstants.Schemas, Schemas, callback);
346343
}
347344
writer.WriteEndObject();

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -667,12 +667,9 @@ public override void Visit(IOpenApiReferenceable referenceable)
667667
public override void Visit(OpenApiSchema schema)
668668
{
669669
// This is needed to handle schemas used in Responses in components
670-
if (schema.Reference != null)
670+
if (schema.Reference != null && !Schemas.ContainsKey(schema.Reference.Id))
671671
{
672-
if (!Schemas.ContainsKey(schema.Reference.Id))
673-
{
674-
Schemas.Add(schema.Reference.Id, schema);
675-
}
672+
Schemas.Add(schema.Reference.Id, schema);
676673
}
677674
base.Visit(schema);
678675
}

src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,9 @@ public static void ValidateDataTypeMismatch(
6161

6262
// Before checking the type, check first if the schema allows null.
6363
// If so and the data given is also null, this is allowed for any type.
64-
if (nullable)
64+
if (nullable && jsonElement.ValueKind is JsonValueKind.Null)
6565
{
66-
if (jsonElement.ValueKind is JsonValueKind.Null)
67-
{
68-
return;
69-
}
66+
return;
7067
}
7168

7269
if (type == "object")

0 commit comments

Comments
 (0)