Skip to content
Merged
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
18 changes: 17 additions & 1 deletion src/Microsoft.OpenApi.Hidi/OpenApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
/// <summary>
/// Implementation of the transform command
/// </summary>
public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILogger logger, CancellationToken cancellationToken = default)

Check warning on line 41 in src/Microsoft.OpenApi.Hidi/OpenApiService.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 19 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)

Check warning on line 41 in src/Microsoft.OpenApi.Hidi/OpenApiService.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 19 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)
{
if (string.IsNullOrEmpty(options.OpenApi) && string.IsNullOrEmpty(options.Csdl) && string.IsNullOrEmpty(options.FilterOptions?.FilterByApiManifest))
{
Expand Down Expand Up @@ -398,6 +398,7 @@
logger.LogTrace("{Timestamp}ms: Completed parsing.", stopwatch.ElapsedMilliseconds);

LogErrors(logger, result);
LogWarnings(logger, result);
stopwatch.Stop();
}

Expand Down Expand Up @@ -652,7 +653,7 @@
private static void LogErrors(ILogger logger, ReadResult result)
{
var context = result.Diagnostic;
if (context is not null && context.Errors.Count != 0)
if (context is { Errors.Count: > 0 })
{
using (logger.BeginScope("Detected errors"))
{
Expand All @@ -664,6 +665,21 @@
}
}

private static void LogWarnings(ILogger logger, ReadResult result)
{
var context = result.Diagnostic;
if (context is { Warnings.Count: > 0 })
{
using (logger.BeginScope("Detected warnings"))
{
foreach (var warning in context.Warnings)
{
logger.LogWarning("Detected warning during parsing: {Warning}", warning.ToString());
}
}
}
}

internal static void WriteTreeDocumentAsMarkdown(string openapiUrl, OpenApiDocument document, StreamWriter writer)
{
var rootNode = OpenApiUrlTreeNode.Create(document, "main");
Expand Down Expand Up @@ -779,9 +795,9 @@
// Create OpenAIPluginManifest from ApiDependency and OpenAPI document
var manifest = new OpenAIPluginManifest(document.Info.Title ?? "Title",
document.Info.Title ?? "Title",
"https://go.microsoft.com/fwlink/?LinkID=288890",

Check warning on line 798 in src/Microsoft.OpenApi.Hidi/OpenApiService.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor your code not to use hardcoded absolute paths or URIs. (https://rules.sonarsource.com/csharp/RSPEC-1075)

Check warning on line 798 in src/Microsoft.OpenApi.Hidi/OpenApiService.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor your code not to use hardcoded absolute paths or URIs. (https://rules.sonarsource.com/csharp/RSPEC-1075)
document.Info?.Contact?.Email ?? "placeholder@contoso.com",
document.Info?.License?.Url?.ToString() ?? "https://placeholderlicenseurl.com")

Check warning on line 800 in src/Microsoft.OpenApi.Hidi/OpenApiService.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor your code not to use hardcoded absolute paths or URIs. (https://rules.sonarsource.com/csharp/RSPEC-1075)

Check warning on line 800 in src/Microsoft.OpenApi.Hidi/OpenApiService.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor your code not to use hardcoded absolute paths or URIs. (https://rules.sonarsource.com/csharp/RSPEC-1075)
{
DescriptionForHuman = document.Info?.Description ?? "Description placeholder",
Api = new("openapi", "./openapi.json"),
Expand Down
Loading