@@ -36,7 +36,7 @@ public static void GetOperationWithoutRequestBodyIsValid()
3636            } 
3737        } ) ; 
3838
39-         document . Paths . Add ( "people" ,  new  OpenApiPathItem 
39+         document . Paths . Add ( "/ people" ,  new  OpenApiPathItem 
4040        { 
4141            Operations  =  new  Dictionary < HttpMethod ,  OpenApiOperation > ( ) 
4242            { 
@@ -92,13 +92,13 @@ public static void GetOperationWithoutRequestBodyIsValid()
9292        ruleSet . Add ( typeof ( OpenApiPaths ) ,  OpenApiRecommendedRules . GetOperationShouldNotHaveRequestBody ) ; 
9393
9494        // Act 
95-         var  errors  =  document . Validate ( ruleSet ) ; 
96-         var  result  =  ! errors . Any ( ) ; 
95+         var  warnings  =  document . Validate ( ruleSet ) ; 
96+         var  result  =  ! warnings . Any ( ) ; 
9797
9898        // Assert 
9999        Assert . True ( result ) ; 
100-         Assert . NotNull ( errors ) ; 
101-         Assert . Empty ( errors ) ; 
100+         Assert . NotNull ( warnings ) ; 
101+         Assert . Empty ( warnings ) ; 
102102    } 
103103
104104    [ Fact ] 
@@ -127,7 +127,7 @@ public static void GetOperationWithRequestBodyIsInvalid()
127127            } 
128128        } ) ; 
129129
130-         document . Paths . Add ( "people" ,  new  OpenApiPathItem 
130+         document . Paths . Add ( "/ people" ,  new  OpenApiPathItem 
131131        { 
132132            Operations  =  new  Dictionary < HttpMethod ,  OpenApiOperation > ( ) 
133133            { 
@@ -200,6 +200,105 @@ public static void GetOperationWithRequestBodyIsInvalid()
200200        Assert . NotNull ( warnings ) ; 
201201        var  warning  =  Assert . Single ( warnings ) ; 
202202        Assert . Equal ( "GET operations should not have a request body." ,  warning . Message ) ; 
203-         Assert . Equal ( "#/paths/people/get/requestbody" ,  warning . Pointer ) ; 
203+         Assert . Equal ( "#/paths//people/get/requestBody" ,  warning . Pointer ) ; 
204+     } 
205+ 
206+     [ Fact ] 
207+     public  static   void  GetOperationWithRequestBodyIsValidUsingDefaultRuleSet ( ) 
208+     { 
209+         // Arrange 
210+         var  document  =  new  OpenApiDocument 
211+         { 
212+             Components  =  new  OpenApiComponents ( ) , 
213+             Info  =  new  OpenApiInfo 
214+             { 
215+                 Title  =  "People Document" , 
216+                 Version  =  "1.0.0" 
217+             } , 
218+             Paths  =  [ ] , 
219+             Workspace  =  new ( ) 
220+         } ; 
221+ 
222+         document . AddComponent ( "Person" ,  new  OpenApiSchema 
223+         { 
224+             Type  =  JsonSchemaType . Object , 
225+             Properties  =  new  Dictionary < string ,  IOpenApiSchema > ( ) 
226+             { 
227+                 [ "name" ]  =  new  OpenApiSchema  {  Type  =  JsonSchemaType . String  } , 
228+                 [ "email" ]  =  new  OpenApiSchema  {  Type  =  JsonSchemaType . String ,  Format  =  "email"  } 
229+             } 
230+         } ) ; 
231+ 
232+         document . Paths . Add ( "/people" ,  new  OpenApiPathItem 
233+         { 
234+             Operations  =  new  Dictionary < HttpMethod ,  OpenApiOperation > ( ) 
235+             { 
236+                 [ HttpMethod . Get ]  =  new  OpenApiOperation 
237+                 { 
238+                     RequestBody  =  new  OpenApiRequestBody 
239+                     { 
240+                         Content  =  new  Dictionary < string ,  OpenApiMediaType > ( ) 
241+                         { 
242+                             [ "application/json" ]  =  new  OpenApiMediaType 
243+                             { 
244+                                 Schema  =  new  OpenApiSchemaReference ( "Person" ,  document ) , 
245+                             } 
246+                         } 
247+                     } , 
248+                     Responses  =  new ( ) 
249+                     { 
250+                         [ "200" ]  =  new  OpenApiResponse 
251+                         { 
252+                             Description  =  "OK" , 
253+                             Content  =  new  Dictionary < string ,  OpenApiMediaType > ( ) 
254+                             { 
255+                                 [ "application/json" ]  =  new  OpenApiMediaType 
256+                                 { 
257+                                     Schema  =  new  OpenApiSchemaReference ( "Person" ,  document ) , 
258+                                 } 
259+                             } 
260+                         } 
261+                     } 
262+                 } , 
263+                 [ HttpMethod . Post ]  =  new  OpenApiOperation 
264+                 { 
265+                     RequestBody  =  new  OpenApiRequestBody 
266+                     { 
267+                         Content  =  new  Dictionary < string ,  OpenApiMediaType > ( ) 
268+                         { 
269+                             [ "application/json" ]  =  new  OpenApiMediaType 
270+                             { 
271+                                 Schema  =  new  OpenApiSchemaReference ( "Person" ,  document ) , 
272+                             } 
273+                         } 
274+                     } , 
275+                     Responses  =  new ( ) 
276+                     { 
277+                         [ "200" ]  =  new  OpenApiResponse 
278+                         { 
279+                             Description  =  "OK" , 
280+                             Content  =  new  Dictionary < string ,  OpenApiMediaType > ( ) 
281+                             { 
282+                                 [ "application/json" ]  =  new  OpenApiMediaType 
283+                                 { 
284+                                     Schema  =  new  OpenApiSchemaReference ( "Person" ,  document ) , 
285+                                 } 
286+                             } 
287+                         } 
288+                     } 
289+                 } 
290+             } 
291+         } ) ; 
292+ 
293+         var  ruleSet  =  ValidationRuleSet . GetDefaultRuleSet ( ) ; 
294+ 
295+         // Act 
296+         var  warnings  =  document . Validate ( ruleSet ) ; 
297+         var  result  =  ! warnings . Any ( ) ; 
298+ 
299+         // Assert 
300+         Assert . True ( result ) ; 
301+         Assert . NotNull ( warnings ) ; 
302+         Assert . Empty ( warnings ) ; 
204303    } 
205304} 
0 commit comments