Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi.Hidi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace Microsoft.OpenApi.Hidi
{
static class Program
{
static async Task<int> Main(string[] args)
static Task<int> Main(string[] args)
{
var rootCommand = CreateRootCommand();

// Parse the incoming args and invoke the handler
return await rootCommand.InvokeAsync(args).ConfigureAwait(false);
return rootCommand.InvokeAsync(args);
}

internal static RootCommand CreateRootCommand()
Expand Down
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