Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Microsoft.OpenApi/Models/OpenApiPathItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,12 @@ internal virtual void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersio

var standardMethodsNames = version switch
{
OpenApiSpecVersion.OpenApi2_0 => _standardHttp2MethodsNames,
OpenApiSpecVersion.OpenApi3_0 => _standardHttp30MethodsNames,
OpenApiSpecVersion.OpenApi3_2 => _standardHttp32MethodsNames,
OpenApiSpecVersion.OpenApi3_1 => _standardHttp31MethodsNames,
OpenApiSpecVersion.OpenApi3_2 or _ => _standardHttp32MethodsNames,
OpenApiSpecVersion.OpenApi3_0 => _standardHttp30MethodsNames,
// OpenAPI 2.0 supports the fewest methods, so it's the safest default in case of an unknown version.
// This way the library will emit additional methods as extensions instead of producing a potentially invalid spec.
_ => _standardHttp2MethodsNames,
};

// operations
Expand Down
9 changes: 3 additions & 6 deletions src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,11 @@
{
var list = n.CreateSimpleList((n2, p) => n2.GetScalarValue(), doc);
JsonSchemaType combinedType = 0;
foreach(var type in list)
foreach(var type in list.Where(static t => t is not null))
{
if (type is not null)
{
var schemaType = type.ToJsonSchemaType();
combinedType |= schemaType;
}
var schemaType = type.ToJsonSchemaType();
combinedType |= schemaType;
}

Check notice on line 204 in src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs

View check run for this annotation

GitHub Advanced Security / CodeQL

Missed opportunity to use Select

This foreach loop immediately [maps its iteration variable to another variable](1) - consider mapping the sequence explicitly using '.Select(...)'.
o.Type = combinedType;
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/Microsoft.OpenApi/Reader/V32/OpenApiSchemaDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,11 @@
{
var list = n.CreateSimpleList((n2, p) => n2.GetScalarValue(), doc);
JsonSchemaType combinedType = 0;
foreach(var type in list)
foreach(var type in list.Where(static t => t is not null))
{
if (type is not null)
{
var schemaType = type.ToJsonSchemaType();
combinedType |= schemaType;
}
var schemaType = type.ToJsonSchemaType();
combinedType |= schemaType;
}

Check notice on line 204 in src/Microsoft.OpenApi/Reader/V32/OpenApiSchemaDeserializer.cs

View check run for this annotation

GitHub Advanced Security / CodeQL

Missed opportunity to use Select

This foreach loop immediately [maps its iteration variable to another variable](1) - consider mapping the sequence explicitly using '.Select(...)'.
o.Type = combinedType;
}
}
Expand Down