diff --git a/src/Kiota.Builder/Kiota.Builder.csproj b/src/Kiota.Builder/Kiota.Builder.csproj index c2ced0a263..0f4636c5fd 100644 --- a/src/Kiota.Builder/Kiota.Builder.csproj +++ b/src/Kiota.Builder/Kiota.Builder.csproj @@ -39,10 +39,10 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Kiota.Builder/OpenApiDocumentDownloadService.cs b/src/Kiota.Builder/OpenApiDocumentDownloadService.cs index 1739f502b5..d5c6908b80 100644 --- a/src/Kiota.Builder/OpenApiDocumentDownloadService.cs +++ b/src/Kiota.Builder/OpenApiDocumentDownloadService.cs @@ -31,8 +31,6 @@ public OpenApiDocumentDownloadService(HttpClient httpClient, ILogger logger) ArgumentNullException.ThrowIfNull(logger); HttpClient = httpClient; Logger = logger; - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader()); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yml, new OpenApiYamlReader()); } private static readonly AsyncKeyedLocker localFilesLock = new(o => { @@ -118,6 +116,7 @@ ex is SecurityException || // Add all extensions for generation settings.AddGenerationExtensions(); + settings.AddYamlReader(); if (config.IsPluginConfiguration) settings.AddPluginsExtensions();// Add all extensions for plugins diff --git a/src/Kiota.Builder/Plugins/PluginsGenerationService.cs b/src/Kiota.Builder/Plugins/PluginsGenerationService.cs index 63d858edd8..32b566a07b 100644 --- a/src/Kiota.Builder/Plugins/PluginsGenerationService.cs +++ b/src/Kiota.Builder/Plugins/PluginsGenerationService.cs @@ -470,7 +470,7 @@ private static (OpenApiRuntime[], Function[], ConversationStarter[]) GetRuntimes var auth = configAuth; try { - auth = configAuth ?? GetAuth(operation.Security ?? document.SecurityRequirements ?? []); + auth = configAuth ?? GetAuth(operation.Security ?? document.Security ?? []); } catch (UnsupportedSecuritySchemeException e) { diff --git a/src/kiota/kiota.csproj b/src/kiota/kiota.csproj index dd5bc4049b..ae125b7317 100644 --- a/src/kiota/kiota.csproj +++ b/src/kiota/kiota.csproj @@ -51,8 +51,6 @@ - - runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs b/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs index 180f7b4d4c..9ec63d9e78 100644 --- a/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs +++ b/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs @@ -51,6 +51,8 @@ public async Task GeneratesManifestAsync(string inputPluginName, string expected paths: /test: get: + tags: + - test summary: summary for test path description: description for test path responses: @@ -261,7 +263,9 @@ public async Task GeneratesManifestAndCleansUpInputDescriptionAsync() // Validate the original file. using var originalOpenApiFile = File.OpenRead(simpleDescriptionPath); - var originalResult = await OpenApiDocument.LoadAsync(originalOpenApiFile, "yaml"); + var settings = new OpenApiReaderSettings(); + settings.AddYamlReader(); + var originalResult = await OpenApiDocument.LoadAsync(originalOpenApiFile, "yaml", settings); var originalDocument = originalResult.Document; Assert.Empty(originalResult.Diagnostic.Errors); @@ -279,7 +283,7 @@ public async Task GeneratesManifestAndCleansUpInputDescriptionAsync() // Validate the output open api file using var resultOpenApiFile = File.OpenRead(Path.Combine(outputDirectory, OpenApiFileName)); - var resultResult = await OpenApiDocument.LoadAsync(resultOpenApiFile, "yaml"); + var resultResult = await OpenApiDocument.LoadAsync(resultOpenApiFile, "yaml", settings); var resultDocument = resultResult.Document; Assert.Empty(resultResult.Diagnostic.Errors); @@ -794,7 +798,9 @@ public async Task MergesAllOfRequestBodyAsync(string content, Action GetDiagnosticFromDocumentAsync(stri using var stream = new MemoryStream(Encoding.UTF8.GetBytes(document)); var settings = new OpenApiReaderSettings(); settings.RuleSet.Add(typeof(OpenApiOperation), [rule]); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader()); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yml, new OpenApiYamlReader()); + settings.AddYamlReader(); var result = await OpenApiDocument.LoadAsync(stream, "yaml", settings); return result.Diagnostic; } diff --git a/tests/Kiota.Builder.Tests/Validation/GetWithBodyTests.cs b/tests/Kiota.Builder.Tests/Validation/GetWithBodyTests.cs index 2289b89101..6fdea0ea6d 100644 --- a/tests/Kiota.Builder.Tests/Validation/GetWithBodyTests.cs +++ b/tests/Kiota.Builder.Tests/Validation/GetWithBodyTests.cs @@ -86,8 +86,7 @@ private static async Task GetDiagnosticFromDocumentAsync(stri using var stream = new MemoryStream(Encoding.UTF8.GetBytes(document)); var settings = new OpenApiReaderSettings(); settings.RuleSet.Add(typeof(IOpenApiPathItem), [rule]); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader()); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yml, new OpenApiYamlReader()); + settings.AddYamlReader(); var result = await OpenApiDocument.LoadAsync(stream, "yaml", settings); return result.Diagnostic; } diff --git a/tests/Kiota.Builder.Tests/Validation/InconsistentTypeFormatPairTests.cs b/tests/Kiota.Builder.Tests/Validation/InconsistentTypeFormatPairTests.cs index bb2e4d7dea..5c4c2a39e8 100644 --- a/tests/Kiota.Builder.Tests/Validation/InconsistentTypeFormatPairTests.cs +++ b/tests/Kiota.Builder.Tests/Validation/InconsistentTypeFormatPairTests.cs @@ -83,8 +83,7 @@ private static async Task GetDiagnosticFromDocumentAsync(stri using var stream = new MemoryStream(Encoding.UTF8.GetBytes(document)); var settings = new OpenApiReaderSettings(); settings.RuleSet.Add(typeof(IOpenApiSchema), [rule]); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader()); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yml, new OpenApiYamlReader()); + settings.AddYamlReader(); var result = await OpenApiDocument.LoadAsync(stream, "yaml", settings); return result.Diagnostic; } diff --git a/tests/Kiota.Builder.Tests/Validation/KnownAndNotSupportedFormatsTests.cs b/tests/Kiota.Builder.Tests/Validation/KnownAndNotSupportedFormatsTests.cs index 81ee36bba5..5235c3202b 100644 --- a/tests/Kiota.Builder.Tests/Validation/KnownAndNotSupportedFormatsTests.cs +++ b/tests/Kiota.Builder.Tests/Validation/KnownAndNotSupportedFormatsTests.cs @@ -83,8 +83,7 @@ private static async Task GetDiagnosticFromDocumentAsync(stri using var stream = new MemoryStream(Encoding.UTF8.GetBytes(document)); var settings = new OpenApiReaderSettings(); settings.RuleSet.Add(typeof(IOpenApiSchema), [rule]); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader()); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yml, new OpenApiYamlReader()); + settings.AddYamlReader(); var result = await OpenApiDocument.LoadAsync(stream, "yaml", settings); return result.Diagnostic; } diff --git a/tests/Kiota.Builder.Tests/Validation/MissingDiscriminatorTests.cs b/tests/Kiota.Builder.Tests/Validation/MissingDiscriminatorTests.cs index efd89a1c2b..9a81d3f224 100644 --- a/tests/Kiota.Builder.Tests/Validation/MissingDiscriminatorTests.cs +++ b/tests/Kiota.Builder.Tests/Validation/MissingDiscriminatorTests.cs @@ -176,8 +176,7 @@ private static async Task GetDiagnosticFromDocumentAsync(stri using var stream = new MemoryStream(Encoding.UTF8.GetBytes(document)); var settings = new OpenApiReaderSettings(); settings.RuleSet.Add(typeof(OpenApiDocument), [rule]); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader()); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yml, new OpenApiYamlReader()); + settings.AddYamlReader(); var result = await OpenApiDocument.LoadAsync(stream, "yaml", settings); return result.Diagnostic; } diff --git a/tests/Kiota.Builder.Tests/Validation/MultipleServerEntriesTests.cs b/tests/Kiota.Builder.Tests/Validation/MultipleServerEntriesTests.cs index d6585196e9..920af7fff5 100644 --- a/tests/Kiota.Builder.Tests/Validation/MultipleServerEntriesTests.cs +++ b/tests/Kiota.Builder.Tests/Validation/MultipleServerEntriesTests.cs @@ -60,8 +60,7 @@ private static async Task GetDiagnosticFromDocumentAsync(stri using var stream = new MemoryStream(Encoding.UTF8.GetBytes(document)); var settings = new OpenApiReaderSettings(); settings.RuleSet.Add(typeof(OpenApiDocument), [rule]); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader()); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yml, new OpenApiYamlReader()); + settings.AddYamlReader(); var result = await OpenApiDocument.LoadAsync(stream, "yaml", settings); return result.Diagnostic; } diff --git a/tests/Kiota.Builder.Tests/Validation/NoContentWithBodyTests.cs b/tests/Kiota.Builder.Tests/Validation/NoContentWithBodyTests.cs index ce59591fff..99a60a9902 100644 --- a/tests/Kiota.Builder.Tests/Validation/NoContentWithBodyTests.cs +++ b/tests/Kiota.Builder.Tests/Validation/NoContentWithBodyTests.cs @@ -78,8 +78,7 @@ private static async Task GetDiagnosticFromDocumentAsync(stri using var stream = new MemoryStream(Encoding.UTF8.GetBytes(document)); var settings = new OpenApiReaderSettings(); settings.RuleSet.Add(typeof(OpenApiOperation), [rule]); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader()); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yml, new OpenApiYamlReader()); + settings.AddYamlReader(); var result = await OpenApiDocument.LoadAsync(stream, "yaml", settings); return result.Diagnostic; } diff --git a/tests/Kiota.Builder.Tests/Validation/NoServerEntryTests.cs b/tests/Kiota.Builder.Tests/Validation/NoServerEntryTests.cs index cc488df6db..ee1f09d583 100644 --- a/tests/Kiota.Builder.Tests/Validation/NoServerEntryTests.cs +++ b/tests/Kiota.Builder.Tests/Validation/NoServerEntryTests.cs @@ -55,8 +55,7 @@ private static async Task GetDiagnosticFromDocumentAsync(stri using var stream = new MemoryStream(Encoding.UTF8.GetBytes(document)); var settings = new OpenApiReaderSettings(); settings.RuleSet.Add(typeof(OpenApiDocument), [rule]); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader()); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yml, new OpenApiYamlReader()); + settings.AddYamlReader(); var result = await OpenApiDocument.LoadAsync(stream, "yaml", settings); return result.Diagnostic; } diff --git a/tests/Kiota.Builder.Tests/Validation/UrlFormEncodedComplexTests.cs b/tests/Kiota.Builder.Tests/Validation/UrlFormEncodedComplexTests.cs index 3482735a3e..74fd60c19a 100644 --- a/tests/Kiota.Builder.Tests/Validation/UrlFormEncodedComplexTests.cs +++ b/tests/Kiota.Builder.Tests/Validation/UrlFormEncodedComplexTests.cs @@ -207,8 +207,7 @@ private static async Task GetDiagnosticFromDocumentAsync(stri using var stream = new MemoryStream(Encoding.UTF8.GetBytes(document)); var settings = new OpenApiReaderSettings(); settings.RuleSet.Add(typeof(OpenApiOperation), [rule]); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader()); - OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yml, new OpenApiYamlReader()); + settings.AddYamlReader(); var result = await OpenApiDocument.LoadAsync(stream, "yaml", settings); return result.Diagnostic; }