Skip to content

fix: hidi fails to parse yaml files when fixing references #2291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2025
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
5 changes: 4 additions & 1 deletion src/Microsoft.OpenApi.Hidi/OpenApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
/// <summary>
/// Implementation of the transform command
/// </summary>
public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILogger logger, CancellationToken cancellationToken = default)

Check warning on line 46 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 46 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 @@ -438,7 +438,10 @@
var sb = new StringBuilder();
document.SerializeAsV3(new OpenApiYamlWriter(new StringWriter(sb)));

var doc = OpenApiDocument.Parse(sb.ToString(), format).Document;
var settings = new OpenApiReaderSettings();
settings.AddYamlReader();

var doc = OpenApiDocument.Parse(sb.ToString(), format, settings).Document;

return doc;
}
Expand Down Expand Up @@ -779,9 +782,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 785 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 785 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 787 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 787 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