Skip to content

Commit 53face2

Browse files
committed
chore: reworks enum version switch
Signed-off-by: Vincent Biret <[email protected]>
1 parent 79b8df9 commit 53face2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
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

0 commit comments

Comments
 (0)