File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed
test/Microsoft.OpenApi.Readers.Tests/V31Tests Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -481,5 +481,21 @@ public void ParseDocumentWithPatternPropertiesInSchemaWorks()
481481 actualSchema . Should ( ) . BeEquivalentTo ( expectedSchema ) ;
482482 actualMediaType . MakeLineBreaksEnvironmentNeutral ( ) . Should ( ) . BeEquivalentTo ( expectedMediaType . MakeLineBreaksEnvironmentNeutral ( ) ) ;
483483 }
484+
485+ [ Fact ]
486+ public void ParseDocumentWithReferenceByIdGetsResolved ( )
487+ {
488+ // Arrange and Act
489+ var result = OpenApiDocument . Load ( Path . Combine ( SampleFolderPath , "docWithReferenceById.yaml" ) ) ;
490+
491+ var responseSchema = result . OpenApiDocument . Paths [ "/resource" ] . Operations [ OperationType . Get ] . Responses [ "200" ] . Content [ "application/json" ] . Schema ;
492+ var requestBodySchema = result . OpenApiDocument . Paths [ "/resource" ] . Operations [ OperationType . Post ] . RequestBody . Content [ "application/json" ] . Schema ;
493+ var parameterSchema = result . OpenApiDocument . Paths [ "/resource" ] . Operations [ OperationType . Get ] . Parameters [ 0 ] . Schema ;
494+
495+ // Assert
496+ Assert . Equal ( "object" , responseSchema . Type ) ;
497+ Assert . Equal ( "object" , requestBodySchema . Type ) ;
498+ Assert . Equal ( "string" , parameterSchema . Type ) ;
499+ }
484500 }
485501}
Original file line number Diff line number Diff line change 1+ openapi : 3.1.0
2+ info :
3+ title : ReferenceById
4+ version : 1.0.0
5+ paths :
6+ /resource :
7+ get :
8+ parameters :
9+ - name : id
10+ in : query
11+ required : true
12+ schema :
13+ $ref : ' https://example.com/schemas/id.json'
14+ responses :
15+ ' 200 ' :
16+ description : OK
17+ content :
18+ application/json :
19+ schema :
20+ $ref : ' https://example.com/schemas/resource.json'
21+ post :
22+ requestBody :
23+ required : true
24+ content :
25+ application/json :
26+ schema :
27+ $ref : ' https://example.com/schemas/resource.json'
28+ responses :
29+ ' 200 ' :
30+ description : OK
31+ components :
32+ schemas :
33+ Resource :
34+ $id : ' https://example.com/schemas/resource.json'
35+ type : object
36+ properties :
37+ id :
38+ type : string
39+ name :
40+ type : string
41+ reference :
42+ $ref : ' #/components/schemas/Resource'
43+ Id :
44+ $id : ' https://example.com/schemas/id.json'
45+ type : string
You can’t perform that action at this time.
0 commit comments