File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed
test/Microsoft.OpenApi.Readers.Tests Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change 128
128
<EmbeddedResource Include =" V3Tests\Samples\OpenApiDocument\documentWithReusablePaths.yaml" >
129
129
<CopyToOutputDirectory >Never</CopyToOutputDirectory >
130
130
</EmbeddedResource >
131
+ <EmbeddedResource Include =" V3Tests\Samples\OpenApiDocument\documentWithSummaryAndDescriptionInReference.yaml" >
132
+ <CopyToOutputDirectory >Never</CopyToOutputDirectory >
133
+ </EmbeddedResource >
131
134
<EmbeddedResource Include =" V3Tests\Samples\OpenApiDiscriminator\basicDiscriminator.yaml" >
132
135
<CopyToOutputDirectory >Never</CopyToOutputDirectory >
133
136
</EmbeddedResource >
Original file line number Diff line number Diff line change 16
16
using Microsoft . OpenApi . Writers ;
17
17
using Xunit ;
18
18
using Xunit . Abstractions ;
19
+ using Xunit . Sdk ;
20
+ using static System . Net . Mime . MediaTypeNames ;
19
21
20
22
namespace Microsoft . OpenApi . Readers . Tests . V3Tests
21
23
{
@@ -1777,5 +1779,22 @@ public void ParseDocumentsWithReusablePathItemInWebhooksSucceeds()
1777
1779
new OpenApiDiagnostic ( ) { SpecificationVersion = OpenApiSpecVersion . OpenApi3_0 } ) ;
1778
1780
1779
1781
}
1782
+
1783
+ [ Fact ]
1784
+ public void ParseDocumentWithDescriptionInDollarRefsShouldSucceed ( )
1785
+ {
1786
+ // Arrange
1787
+ using var stream = Resources . GetStream ( Path . Combine ( SampleFolderPath , "documentWithSummaryAndDescriptionInReference.yaml" ) ) ;
1788
+
1789
+ // Act
1790
+ var actual = new OpenApiStreamReader ( ) . Read ( stream , out var diagnostic ) ;
1791
+ var schema = actual . Paths [ "/pets" ] . Operations [ OperationType . Get ] . Responses [ "200" ] . Content [ "application/json" ] . Schema ;
1792
+ var header = actual . Components . Responses [ "Test" ] . Headers [ "X-Test" ] ;
1793
+
1794
+ // Assert
1795
+ Assert . True ( header . Description == "A referenced X-Test header" ) ; /*response header #ref's description overrides the header's description*/
1796
+ Assert . True ( schema . UnresolvedReference == false && schema . Type == "object" ) ; /*schema reference is resolved*/
1797
+ Assert . Equal ( "A pet in a petstore" , schema . Description ) ; /*The reference object's description overrides that of the referenced component*/
1798
+ }
1780
1799
}
1781
1800
}
Original file line number Diff line number Diff line change
1
+ openapi : ' 3.1.0'
2
+ info :
3
+ version : ' 1.0.0'
4
+ title : Swagger Petstore (Simple)
5
+ paths :
6
+ /pets :
7
+ get :
8
+ description : Returns all pets from the system that the user has access to
9
+ responses :
10
+ ' 200 ' :
11
+ description : pet response
12
+ content :
13
+ application/json :
14
+ schema :
15
+ " $ref " : ' #/components/schemas/pet'
16
+ summary : A pet
17
+ description : A pet in a petstore
18
+ components :
19
+ headers :
20
+ X-Test :
21
+ description : Test
22
+ schema :
23
+ type : string
24
+ responses :
25
+ Test :
26
+ description : Test Repsonse
27
+ headers :
28
+ X-Test :
29
+ $ref : ' #/components/headers/X-Test'
30
+ summary : X-Test header
31
+ description : A referenced X-Test header
32
+ schemas :
33
+ pet :
34
+ description : A referenced pet in a petstore
35
+ type : object
36
+ required :
37
+ - id
38
+ - name
39
+ properties :
40
+ id :
41
+ type : integer
42
+ format : int64
43
+ name :
44
+ type : string
45
+ tag :
46
+ type : string
You can’t perform that action at this time.
0 commit comments