Skip to content

Commit

Permalink
Merge pull request #1367 from SimonCropp/elide-some-asyncs
Browse files Browse the repository at this point in the history
elide some asyncs
  • Loading branch information
baywet authored Oct 3, 2023
2 parents 60b72fc + ed51df5 commit 540f02b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
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 @@ -174,25 +174,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 @@ -282,7 +282,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF
}

[Fact]
public async Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty()
public Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty()
{
HidiOptions options = new HidiOptions
{
Expand All @@ -291,9 +291,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 540f02b

Please sign in to comment.