Skip to content

Commit e6da67f

Browse files
authored
Merge pull request #50 from BinkyLabs/chore/pr-automated-feedback
Chore/pr-automated-feedback
2 parents 0d124c2 + 53face2 commit e6da67f

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

src/Microsoft.OpenApi/Models/OpenApiPathItem.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,12 @@ internal virtual void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersio
170170

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

179181
// operations

src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,10 @@ internal static partial class OpenApiV31Deserializer
197197
{
198198
var list = n.CreateSimpleList((n2, p) => n2.GetScalarValue(), doc);
199199
JsonSchemaType combinedType = 0;
200-
foreach(var type in list)
200+
foreach(var type in list.Where(static t => t is not null))
201201
{
202-
if (type is not null)
203-
{
204-
var schemaType = type.ToJsonSchemaType();
205-
combinedType |= schemaType;
206-
}
202+
var schemaType = type.ToJsonSchemaType();
203+
combinedType |= schemaType;
207204
}
208205
o.Type = combinedType;
209206
}

src/Microsoft.OpenApi/Reader/V32/OpenApiSchemaDeserializer.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,10 @@ internal static partial class OpenApiV32Deserializer
197197
{
198198
var list = n.CreateSimpleList((n2, p) => n2.GetScalarValue(), doc);
199199
JsonSchemaType combinedType = 0;
200-
foreach(var type in list)
200+
foreach(var type in list.Where(static t => t is not null))
201201
{
202-
if (type is not null)
203-
{
204-
var schemaType = type.ToJsonSchemaType();
205-
combinedType |= schemaType;
206-
}
202+
var schemaType = type.ToJsonSchemaType();
203+
combinedType |= schemaType;
207204
}
208205
o.Type = combinedType;
209206
}

0 commit comments

Comments
 (0)