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 22
22
using Microsoft . OpenApi . Services ;
23
23
using Microsoft . OpenApi . Validations ;
24
24
using Microsoft . OpenApi . Writers ;
25
- using static Microsoft . OpenApi . Hidi . OpenApiSpecVersionExtension ;
25
+ using static Microsoft . OpenApi . Hidi . OpenApiSpecVersionHelper ;
26
26
27
27
namespace Microsoft . OpenApi . Hidi
28
28
{
@@ -91,7 +91,7 @@ string filterbycollection
91
91
{
92
92
// Default to yaml and OpenApiVersion 3 during csdl to OpenApi conversion
93
93
openApiFormat = format ?? GetOpenApiFormat ( csdl , logger ) ;
94
- openApiVersion = version . TryParseOpenApiSpecVersion ( ) ;
94
+ openApiVersion = TryParseOpenApiSpecVersion ( version ) ;
95
95
96
96
stream = await GetStream ( csdl , logger ) ;
97
97
document = await ConvertCsdlToOpenApi ( stream ) ;
Original file line number Diff line number Diff line change 6
6
7
7
namespace Microsoft . OpenApi . Hidi
8
8
{
9
- public static class OpenApiSpecVersionExtension
9
+ public static class OpenApiSpecVersionHelper
10
10
{
11
- public static OpenApiSpecVersion TryParseOpenApiSpecVersion ( this string value )
11
+ public static OpenApiSpecVersion TryParseOpenApiSpecVersion ( string value )
12
12
{
13
13
if ( string . IsNullOrEmpty ( value ) )
14
14
{
15
15
throw new InvalidOperationException ( "Please provide a version" ) ;
16
16
}
17
17
var res = value . Split ( '.' , StringSplitOptions . RemoveEmptyEntries ) . FirstOrDefault ( ) ;
18
-
18
+
19
19
if ( int . TryParse ( res , out int result ) )
20
20
{
21
21
22
- if ( result >= 2 || result <= 3 )
22
+ if ( result >= 2 && result < 3 )
23
23
{
24
- return ( OpenApiSpecVersion ) result ;
24
+ return OpenApiSpecVersion . OpenApi2_0 ;
25
25
}
26
- }
26
+ }
27
27
28
28
return OpenApiSpecVersion . OpenApi3_0 ; // default
29
29
}
You can’t perform that action at this time.
0 commit comments