File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
src/Microsoft.OpenApi.Hidi Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 2222using Microsoft . OpenApi . Services ;
2323using Microsoft . OpenApi . Validations ;
2424using Microsoft . OpenApi . Writers ;
25- using static Microsoft . OpenApi . Hidi . OpenApiSpecVersionExtension ;
25+ using static Microsoft . OpenApi . Hidi . OpenApiSpecVersionHelper ;
2626
2727namespace Microsoft . OpenApi . Hidi
2828{
@@ -91,7 +91,7 @@ string filterbycollection
9191 {
9292 // Default to yaml and OpenApiVersion 3 during csdl to OpenApi conversion
9393 openApiFormat = format ?? GetOpenApiFormat ( csdl , logger ) ;
94- openApiVersion = version . TryParseOpenApiSpecVersion ( ) ;
94+ openApiVersion = TryParseOpenApiSpecVersion ( version ) ;
9595
9696 stream = await GetStream ( csdl , logger ) ;
9797 document = await ConvertCsdlToOpenApi ( stream ) ;
Original file line number Diff line number Diff line change 66
77namespace Microsoft . OpenApi . Hidi
88{
9- public static class OpenApiSpecVersionExtension
9+ public static class OpenApiSpecVersionHelper
1010 {
11- public static OpenApiSpecVersion TryParseOpenApiSpecVersion ( this string value )
11+ public static OpenApiSpecVersion TryParseOpenApiSpecVersion ( string value )
1212 {
1313 if ( string . IsNullOrEmpty ( value ) )
1414 {
1515 throw new InvalidOperationException ( "Please provide a version" ) ;
1616 }
1717 var res = value . Split ( '.' , StringSplitOptions . RemoveEmptyEntries ) . FirstOrDefault ( ) ;
18-
18+
1919 if ( int . TryParse ( res , out int result ) )
2020 {
2121
22- if ( result >= 2 || result <= 3 )
22+ if ( result >= 2 && result < 3 )
2323 {
24- return ( OpenApiSpecVersion ) result ;
24+ return OpenApiSpecVersion . OpenApi2_0 ;
2525 }
26- }
26+ }
2727
2828 return OpenApiSpecVersion . OpenApi3_0 ; // default
2929 }
You can’t perform that action at this time.
0 commit comments