Skip to content

Commit 7b7d4a6

Browse files
committed
chore: uses file stream information in priority as its the most accurate one
Signed-off-by: Vincent Biret <[email protected]>
1 parent 17779b2 commit 7b7d4a6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ private static async Task<ReadResult> InternalLoadAsync(Stream input, string for
242242
settings ??= DefaultReaderSettings.Value;
243243
var reader = settings.GetReader(format);
244244
var location =
245-
settings.BaseUrl ??
246245
(input is FileStream fileStream ? new Uri(fileStream.Name) : null) ??
246+
settings.BaseUrl ??
247247
new Uri(OpenApiConstants.BaseRegistryUri);
248248

249249
var readResult = await reader.ReadAsync(input, location, settings, cancellationToken).ConfigureAwait(false);

test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@ public async Task ParseDocumentWithReferenceByIdGetsResolved()
514514
public async Task ExternalDocumentDereferenceToOpenApiDocumentUsingJsonPointerWorks()
515515
{
516516
// Arrange
517-
var path = Path.Combine(Directory.GetCurrentDirectory(), SampleFolderPath);
517+
var documentName = "externalRefByJsonPointer.yaml";
518+
var path = Path.Combine(Directory.GetCurrentDirectory(), SampleFolderPath, documentName);
518519

519520
var settings = new OpenApiReaderSettings
520521
{
@@ -524,7 +525,7 @@ public async Task ExternalDocumentDereferenceToOpenApiDocumentUsingJsonPointerWo
524525
settings.AddYamlReader();
525526

526527
// Act
527-
var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "externalRefByJsonPointer.yaml"), settings);
528+
var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, documentName), settings);
528529
var responseSchema = result.Document.Paths["/resource"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
529530

530531
// Assert

0 commit comments

Comments
 (0)