@@ -59,14 +59,14 @@ internal OpenApiDocument Parse(YamlDocument yamlDocument)
59
59
60
60
switch ( inputVersion )
61
61
{
62
- case string version when version == "2.0" :
62
+ case string version when version . is2_0 ( ) :
63
63
VersionService = new OpenApiV2VersionService ( Diagnostic ) ;
64
64
doc = VersionService . LoadDocument ( RootNode ) ;
65
65
this . Diagnostic . SpecificationVersion = OpenApiSpecVersion . OpenApi2_0 ;
66
66
ValidateRequiredFields ( doc , version ) ;
67
67
break ;
68
68
69
- case string version when version . StartsWith ( "3.0" ) || version . StartsWith ( "3.1" ) :
69
+ case string version when version . is3_0 ( ) || version . is3_1 ( ) :
70
70
VersionService = new OpenApiV3VersionService ( Diagnostic ) ;
71
71
doc = VersionService . LoadDocument ( RootNode ) ;
72
72
this . Diagnostic . SpecificationVersion = OpenApiSpecVersion . OpenApi3_0 ;
@@ -248,12 +248,12 @@ public void PopLoop(string loopid)
248
248
249
249
private void ValidateRequiredFields ( OpenApiDocument doc , string version )
250
250
{
251
- if ( ( version == "2.0" || version . StartsWith ( "3.0" ) ) && ( doc . Paths == null || ! doc . Paths . Any ( ) ) )
251
+ if ( ( version . is2_0 ( ) || version . is3_0 ( ) ) && ( doc . Paths == null || ! doc . Paths . Any ( ) ) )
252
252
{
253
253
// paths is a required field in OpenAPI 3.0 but optional in 3.1
254
254
RootNode . Context . Diagnostic . Errors . Add ( new OpenApiError ( "" , $ "Paths is a REQUIRED field at { RootNode . Context . GetLocation ( ) } ") ) ;
255
255
}
256
- else if ( version . StartsWith ( "3.1" ) && ( doc . Paths == null || ! doc . Paths . Any ( ) ) && ( doc . Webhooks == null || ! doc . Webhooks . Any ( ) ) )
256
+ else if ( version . is3_1 ( ) && ( doc . Paths == null || ! doc . Paths . Any ( ) ) && ( doc . Webhooks == null || ! doc . Webhooks . Any ( ) ) )
257
257
{
258
258
RootNode . Context . Diagnostic . Errors . Add ( new OpenApiError (
259
259
"" , $ "The document MUST contain either a Paths or Webhooks field at { RootNode . Context . GetLocation ( ) } ") ) ;
0 commit comments