Skip to content

Commit

Permalink
chore: additional tasks linting
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Biret <[email protected]>
  • Loading branch information
baywet committed Aug 28, 2024
1 parent f607d60 commit 8c753d6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions OpenAPIService.Test/OpenAPIServiceShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.OpenApi;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Models;
Expand Down Expand Up @@ -584,7 +585,7 @@ public void SetByRefPostfixForRefOperationIds()
}

[Fact]
public void GetOpenApiTreeNode()
public async Task GetOpenApiTreeNodeAsync()
{
// Arrange
var sources = new ConcurrentDictionary<string, OpenApiDocument>();
Expand All @@ -593,7 +594,7 @@ public void GetOpenApiTreeNode()
// Act
var rootNode = _openApiService.CreateOpenApiUrlTreeNode(sources);
using MemoryStream stream = new();
ConvertOpenApiUrlTreeNodeToJson(rootNode, stream);
await ConvertOpenApiUrlTreeNodeToJsonAsync(rootNode, stream);

// Assert
var jsonPayload = Encoding.ASCII.GetString(stream.ToArray());
Expand Down Expand Up @@ -720,10 +721,10 @@ public void ConvertOpenApiUrlTreeNodeToJsonRendersExternalDocs()
Assert.Contains("\"children\":[{\"segment\":\"{user-id}\",\"labels\":[{\"name\":\"mock\",\"methods\":[{\"name\":\"Get\",\"documentationUrl\":\"https://docs.microsoft.com/foobar\"}", output);
}

private void ConvertOpenApiUrlTreeNodeToJson(OpenApiUrlTreeNode node, Stream stream)
private async Task ConvertOpenApiUrlTreeNodeToJsonAsync(OpenApiUrlTreeNode node, Stream stream)
{
Assert.NotNull(node);
_openApiService.ConvertOpenApiUrlTreeNodeToJson(node, stream);
await _openApiService.ConvertOpenApiUrlTreeNodeToJsonAsync(node, stream);
Assert.True(stream.Length > 0);
}
}
Expand Down
2 changes: 1 addition & 1 deletion OpenAPIService/Interfaces/IOpenApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Func<OpenApiOperation, bool> CreatePredicate(string operationIds, string tags, s

OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(ConcurrentDictionary<string, OpenApiDocument> sources);

void ConvertOpenApiUrlTreeNodeToJson(OpenApiUrlTreeNode rootNode, Stream stream);
Task ConvertOpenApiUrlTreeNodeToJsonAsync(OpenApiUrlTreeNode rootNode, Stream stream);

OpenApiDocument ApplyStyle(OpenApiStyle style, OpenApiDocument subsetOpenApiDocument, bool includeRequestBody = false, bool singularizeOperationIds = false);

Expand Down
4 changes: 2 additions & 2 deletions OpenAPIService/OpenApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,11 @@ private OpenApiOperation[] GetOpenApiOperations(OpenApiUrlTreeNode rootNode, str
/// </summary>
/// <param name="rootNode">The target <see cref="OpenApiUrlTreeNode"/> root node.</param>
/// <param name="stream">The destination for writing the JSON text to.</param>
public void ConvertOpenApiUrlTreeNodeToJson(OpenApiUrlTreeNode rootNode, Stream stream)
public async Task ConvertOpenApiUrlTreeNodeToJsonAsync(OpenApiUrlTreeNode rootNode, Stream stream)
{
using Utf8JsonWriter writer = new Utf8JsonWriter(stream);
ConvertOpenApiUrlTreeNodeToJson(writer, rootNode);
writer.FlushAsync();
await writer.FlushAsync();
}

/// <summary>
Expand Down

0 comments on commit 8c753d6

Please sign in to comment.