Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/Kiota.Builder/Kiota.Builder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
<PackageReference Include="DotNet.Glob" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.2" />
<PackageReference Include="Microsoft.Kiota.Bundle" Version="1.17.1" />
<PackageReference Include="Microsoft.OpenApi" Version="2.0.0-preview9" />
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="2.0.0-preview1" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="2.0.0-preview9" />
<PackageReference Include="Microsoft.DeclarativeAgents.Manifest" Version="2.0.0-rc2" />
<PackageReference Include="Microsoft.OpenApi" Version="2.0.0-preview.12" />
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="2.0.0-preview2" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="2.0.0-preview.12" />
<PackageReference Include="Microsoft.DeclarativeAgents.Manifest" Version="2.0.0-rc4" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.13.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
3 changes: 1 addition & 2 deletions src/Kiota.Builder/OpenApiDocumentDownloadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> localFilesLock = new(o =>
{
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Plugins/PluginsGenerationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
private readonly ILogger<KiotaBuilder> Logger;

public PluginsGenerationService(OpenApiDocument document, OpenApiUrlTreeNode openApiUrlTreeNode,
GenerationConfiguration configuration, string workingDirectory, ILogger<KiotaBuilder> logger)

Check warning on line 33 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Update this logger to use its enclosing type. (https://rules.sonarsource.com/csharp/RSPEC-6672)

Check warning on line 33 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Update this logger to use its enclosing type. (https://rules.sonarsource.com/csharp/RSPEC-6672)
{
ArgumentNullException.ThrowIfNull(document);
ArgumentNullException.ThrowIfNull(openApiUrlTreeNode);
Expand Down Expand Up @@ -88,7 +88,7 @@
pluginDocument.Write(writer);
break;
case PluginType.APIManifest:
var apiManifest = new ApiManifestDocument("application"); //TODO add application name

Check warning on line 91 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)

Check warning on line 91 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
// pass empty config hash so that its not included in this manifest.
apiManifest.ApiDependencies[Configuration.ClientClassName] = Configuration.ToApiDependency(string.Empty, TreeNode?.GetRequestInfo().ToDictionary(static x => x.Key, static x => x.Value) ?? [], WorkingDirectory);
var publisherName = string.IsNullOrEmpty(OAIDocument.Info?.Contact?.Name)
Expand Down Expand Up @@ -205,7 +205,7 @@
}
base.Visit(schema);
}
internal static void CopyRelevantInformation(IOpenApiSchema source, IOpenApiSchema target, bool includeProperties = true, bool includeDiscriminator = true)

Check warning on line 208 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 64 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)
{
if (target is OpenApiSchema openApiSchema)
{
Expand Down Expand Up @@ -280,7 +280,7 @@
if (operation.Responses is null)
return;
var errorResponses = operation.Responses.Where(static x => x.Key.StartsWith('4') || x.Key.StartsWith('5')).ToArray();
foreach (var (key, value) in errorResponses)

Check warning on line 283 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Remove the unused local variable 'value'. (https://rules.sonarsource.com/csharp/RSPEC-1481)
operation.Responses.Remove(key);
base.Visit(operation);
}
Expand Down Expand Up @@ -467,15 +467,15 @@
{
foreach (var operation in pathItem.Operations.Values.Where(static x => !string.IsNullOrEmpty(x.OperationId)))
{
var auth = configAuth;

Check warning on line 470 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this useless assignment to local variable 'auth'. (https://rules.sonarsource.com/csharp/RSPEC-1854)

Check warning on line 470 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this useless assignment to local variable 'auth'. (https://rules.sonarsource.com/csharp/RSPEC-1854)
try
{
auth = configAuth ?? GetAuth(operation.Security ?? document.SecurityRequirements ?? []);
auth = configAuth ?? GetAuth(operation.Security ?? document.Security ?? []);
}
catch (UnsupportedSecuritySchemeException e)
{
auth = new AnonymousAuth();
logger.LogWarning("Authentication warning: {OperationId} - {Message}", operation.OperationId, e.Message);

Check warning on line 478 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Logging in a catch clause should pass the caught exception as a parameter. (https://rules.sonarsource.com/csharp/RSPEC-6667)

Check warning on line 478 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Logging in a catch clause should pass the caught exception as a parameter. (https://rules.sonarsource.com/csharp/RSPEC-6667)
}

runtimes.Add(new OpenApiRuntime
Expand Down
2 changes: 0 additions & 2 deletions src/kiota/kiota.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.2" />
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="2.0.0-preview1" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="2.0.0-preview9" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.13.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -794,7 +798,9 @@ public async Task MergesAllOfRequestBodyAsync(string content, Action<OpenApiDocu
{
// Validate the sliced openapi
using var stream = File.Open(Path.Combine(outputDirectory, OpenApiFileName), FileMode.Open);
var readResult = await OpenApiDocument.LoadAsync(stream);
var settings = new OpenApiReaderSettings();
settings.AddYamlReader();
var readResult = await OpenApiDocument.LoadAsync(stream, "yaml", settings);
assertions(readResult.Document, readResult.Diagnostic);
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ private static async Task<OpenApiDiagnostic> 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;
}
Expand Down
3 changes: 1 addition & 2 deletions tests/Kiota.Builder.Tests/Validation/GetWithBodyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ private static async Task<OpenApiDiagnostic> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ private static async Task<OpenApiDiagnostic> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ private static async Task<OpenApiDiagnostic> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ private static async Task<OpenApiDiagnostic> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ private static async Task<OpenApiDiagnostic> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ private static async Task<OpenApiDiagnostic> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ private static async Task<OpenApiDiagnostic> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ private static async Task<OpenApiDiagnostic> 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;
}
Expand Down
Loading