File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed
test/Microsoft.OpenApi.Readers.Tests Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 149149 <EmbeddedResource Include =" V3Tests\Samples\OpenApiDocument\petStoreWithTagAndSecurity.yaml" >
150150 <CopyToOutputDirectory >Never</CopyToOutputDirectory >
151151 </EmbeddedResource >
152+ <EmbeddedResource Include =" V3Tests\Samples\OpenApiDocument\documentWithExternalRefs.yaml" >
153+ <CopyToOutputDirectory >Never</CopyToOutputDirectory >
154+ </EmbeddedResource >
152155 <EmbeddedResource Include =" V3Tests\Samples\OpenApiDocument\securedApi.yaml" />
153156 <EmbeddedResource Include =" V3Tests\Samples\OpenApiEncoding\advancedEncoding.yaml" >
154157 <CopyToOutputDirectory >Never</CopyToOutputDirectory >
Original file line number Diff line number Diff line change 66using System . Globalization ;
77using System . IO ;
88using System . Linq ;
9+ using System . Text ;
910using System . Threading ;
1011using FluentAssertions ;
1112using Microsoft . OpenApi . Any ;
@@ -1327,5 +1328,24 @@ public void HeaderParameterShouldAllowExample()
13271328 } ) ;
13281329 }
13291330 }
1331+
1332+ [ Fact ]
1333+ public void DoesNotChangeExternalReferences ( )
1334+ {
1335+ // Arrange
1336+ using var stream = Resources . GetStream ( Path . Combine ( SampleFolderPath , "documentWithExternalRefs.yaml" ) ) ;
1337+
1338+ // Act
1339+ var doc = new OpenApiStreamReader (
1340+ new OpenApiReaderSettings { ReferenceResolution = ReferenceResolutionSetting . DoNotResolveReferences } )
1341+ . Read ( stream , out var diagnostic ) ;
1342+
1343+ var externalRef = doc . Components . Schemas [ "Nested" ] . Properties [ "AnyOf" ] . AnyOf . First ( ) . Reference . ReferenceV3 ;
1344+ var externalRef2 = doc . Components . Schemas [ "Nested" ] . Properties [ "AnyOf" ] . AnyOf . Last ( ) . Reference . ReferenceV3 ;
1345+
1346+ // Assert
1347+ Assert . Equal ( "file:///C:/MySchemas.json#/definitions/ArrayObject" , externalRef ) ;
1348+ Assert . Equal ( "../foo/schemas.yaml#/components/schemas/Number" , externalRef2 ) ;
1349+ }
13301350 }
13311351}
Original file line number Diff line number Diff line change 1+ openapi : 3.0.1
2+ info :
3+ title : anyOf-oneOf
4+ license :
5+ name : MIT
6+ version : 1.0.0
7+ paths : { }
8+ components :
9+ schemas :
10+ Nested :
11+ type : object
12+ properties :
13+ AnyOf :
14+ anyOf :
15+ - $ref : file:///C:/MySchemas.json#/definitions/ArrayObject
16+ - $ref : ../foo/schemas.yaml#/components/schemas/Number
You can’t perform that action at this time.
0 commit comments