Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Oct 2, 2023
1 parent 861b555 commit ed51df5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ public async Task<ReadResult> ReadAsync(YamlDocument input, CancellationToken ca
};
}

private async Task<OpenApiDiagnostic> LoadExternalRefs(OpenApiDocument document, CancellationToken cancellationToken = default)
private Task<OpenApiDiagnostic> LoadExternalRefs(OpenApiDocument document, CancellationToken cancellationToken = default)
{
// Create workspace for all documents to live in.
var openApiWorkSpace = new OpenApiWorkspace();

// Load this root document into the workspace
var streamLoader = new DefaultStreamLoader(_settings.BaseUrl);
var workspaceLoader = new OpenApiWorkspaceLoader(openApiWorkSpace, _settings.CustomExternalLoader ?? streamLoader, _settings);
return await workspaceLoader.LoadAsync(new OpenApiReference { ExternalResource = "/" }, document, null, cancellationToken);
return workspaceLoader.LoadAsync(new OpenApiReference { ExternalResource = "/" }, document, null, cancellationToken);
}

private void ResolveReferences(OpenApiDiagnostic diagnostic, OpenApiDocument document)
Expand Down
25 changes: 12 additions & 13 deletions test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,25 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiag
}

[Fact]
public async Task ThrowIfOpenApiUrlIsNotProvidedWhenValidating()
public Task ThrowIfOpenApiUrlIsNotProvidedWhenValidating()
{
await Assert.ThrowsAsync<ArgumentNullException>(async () =>
await OpenApiService.ValidateOpenApiDocument("", _logger));
return Assert.ThrowsAsync<ArgumentNullException>(() =>
OpenApiService.ValidateOpenApiDocument("", _logger));
}


[Fact]
public async Task ThrowIfURLIsNotResolvableWhenValidating()
public Task ThrowIfURLIsNotResolvableWhenValidating()
{
await Assert.ThrowsAsync<InvalidOperationException>(async () =>
await OpenApiService.ValidateOpenApiDocument("https://example.org/itdoesnmatter", _logger));
return Assert.ThrowsAsync<InvalidOperationException>(() =>
OpenApiService.ValidateOpenApiDocument("https://example.org/itdoesnmatter", _logger));
}

[Fact]
public async Task ThrowIfFileDoesNotExistWhenValidating()
public Task ThrowIfFileDoesNotExistWhenValidating()
{
await Assert.ThrowsAsync<InvalidOperationException>(async () =>
await OpenApiService.ValidateOpenApiDocument("aFileThatBetterNotExist.fake", _logger));
return Assert.ThrowsAsync<InvalidOperationException>(() =>
OpenApiService.ValidateOpenApiDocument("aFileThatBetterNotExist.fake", _logger));
}

[Fact]
Expand Down Expand Up @@ -284,7 +284,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF
}

[Fact]
public async Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty()
public Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty()
{
HidiOptions options = new HidiOptions
{
Expand All @@ -293,9 +293,8 @@ public async Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty()
InlineLocal = false,
InlineExternal = false,
};
await Assert.ThrowsAsync<ArgumentException>(async () =>
await OpenApiService.TransformOpenApiDocument(options, _logger));

return Assert.ThrowsAsync<ArgumentException>(() =>
OpenApiService.TransformOpenApiDocument(options, _logger));
}

[Fact]
Expand Down

0 comments on commit ed51df5

Please sign in to comment.