Skip to content
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

Fix message log when generating plugins #4915

Merged
merged 2 commits into from
Jul 2, 2024
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
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
- Implemented partial class model declarations. [4894](https://github.com/microsoft/kiota/issues/4894)

### Added

### Changed

- Implemented partial class model declarations. [4894](https://github.com/microsoft/kiota/issues/4894)
- Fixes bug with model names in Go generated from camel case namespace. [https://github.com/microsoftgraph/msgraph-sdk-go/issues/721]
- Plugins OpenAPI extensions are only added when generating plugins to reduce the risk of parsing errors. [#4834](https://github.com/microsoft/kiota/issues/4834)
- TypeScript imports are now using ES6 imports with the .js extension.
- Remove LINQ usage in generated code.
- Ensures descriptions are not empty in sliced OpenApi file when generating a plugin.
- Plugins do not emit parameters anymore. [#4841](https://github.com/microsoft/kiota/issues/4841)
- References to C# types generated by kiota are prefixed with `global::` to avoid name collisions. [#4796](https://github.com/microsoft/kiota/issues/4796)
- Dropped `client base url set to` message when generating plugins. [#4905](https://github.com/microsoft/kiota/issues/4905)

## [1.15.0] - 2024-06-06

Expand Down
5 changes: 4 additions & 1 deletion src/Kiota.Builder/KiotaBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
#pragma warning restore CA1031
{
if (!skipErrorLog)
logger.LogCritical("error getting the API manifest: {ExceptionMessage}", ex.Message);

Check warning on line 139 in src/Kiota.Builder/KiotaBuilder.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)
return null;
}
}
Expand Down Expand Up @@ -432,7 +432,10 @@
if (openApiDocument is not null && openApiDocument.GetAPIRootUrl(config.OpenAPIFilePath) is string candidateUrl)
{
config.ApiRootUrl = candidateUrl;
logger.LogInformation("Client root URL set to {ApiRootUrl}", candidateUrl);
if (!config.IsPluginConfiguration)
{
logger.LogInformation("Client root URL set to {ApiRootUrl}", candidateUrl);
}
}
else
logger.LogWarning("No server url found in the OpenAPI document. The base url will need to be set when using the client.");
Expand Down Expand Up @@ -692,7 +695,7 @@
methodToAdd.AddParameter(new CodeParameter
{
Name = "rawUrl",
Type = new CodeType { Name = "string", IsExternal = true },

Check warning on line 698 in src/Kiota.Builder/KiotaBuilder.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'string' 19 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
Optional = false,
Documentation = new()
{
Expand Down Expand Up @@ -806,7 +809,7 @@
IsAsync = false,
IsStatic = false,
Documentation = new(new() {
{"TypeName", new CodeType {

Check warning on line 812 in src/Kiota.Builder/KiotaBuilder.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'TypeName' 5 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
IsExternal = false,
TypeDefinition = currentClass,
}
Expand Down Expand Up @@ -1048,7 +1051,7 @@

if (!"string".Equals(parameter.Type.Name, StringComparison.OrdinalIgnoreCase) && config.IncludeBackwardCompatible)
{ // adding a second indexer for the string version of the parameter so we keep backward compatibility
//TODO remove for v2

Check warning on line 1054 in src/Kiota.Builder/KiotaBuilder.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)
var backCompatibleValue = (CodeIndexer)result[0].Clone();
backCompatibleValue.Name += "-string";
backCompatibleValue.IndexParameter.Type = DefaultIndexerParameterType;
Expand Down Expand Up @@ -1122,15 +1125,15 @@
var primitiveTypeName = (typeName?.ToLowerInvariant(), format?.ToLowerInvariant()) switch
{
("string", "base64url") => "base64url",
("file", _) => "binary",

Check warning on line 1128 in src/Kiota.Builder/KiotaBuilder.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'binary' 6 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
("string", "duration") => "TimeSpan",
("string", "time") => "TimeOnly",
("string", "date") => "DateOnly",
("string", "date-time") => "DateTimeOffset",
("string", "uuid") => "Guid",
("string", _) => "string", // covers commonmark and html
("number", "double" or "float" or "decimal") => format.ToLowerInvariant(),

Check warning on line 1135 in src/Kiota.Builder/KiotaBuilder.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'number' 6 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
("number" or "integer", "int8") => "sbyte",

Check warning on line 1136 in src/Kiota.Builder/KiotaBuilder.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'integer' 6 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
("number" or "integer", "uint8") => "byte",
("number" or "integer", "int64") => "int64",
("number", "int32") => "integer",
Expand Down Expand Up @@ -1202,7 +1205,7 @@
var suffix = $"{operationType}Response";
var modelType = CreateModelDeclarations(currentNode, schema, operation, parentClass, suffix);
if (modelType is not null && config.IncludeBackwardCompatible && config.Language is GenerationLanguage.CSharp or GenerationLanguage.Go && modelType.Name.EndsWith(suffix, StringComparison.Ordinal))
{ //TODO remove for v2

Check warning on line 1208 in src/Kiota.Builder/KiotaBuilder.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)
var obsoleteTypeName = modelType.Name[..^suffix.Length] + "Response";
if (modelType is CodeType codeType &&
codeType.TypeDefinition is CodeClass codeClass)
Expand Down Expand Up @@ -1335,7 +1338,7 @@
executorMethod.AddParameter(cancellationParam);// Add cancellation token parameter

if (returnTypes.Item2 is not null && config.IncludeBackwardCompatible)
{ //TODO remove for v2

Check warning on line 1341 in src/Kiota.Builder/KiotaBuilder.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)
var additionalExecutorMethod = (CodeMethod)executorMethod.Clone();
additionalExecutorMethod.ReturnType = returnTypes.Item2;
additionalExecutorMethod.OriginalMethod = executorMethod;
Expand Down Expand Up @@ -2393,7 +2396,7 @@
if (!parameterClass.ContainsPropertyWithWireName(prop.WireName))
{
if (addBackwardCompatibleParameter && config.IncludeBackwardCompatible && config.Language is GenerationLanguage.CSharp or GenerationLanguage.Go)
{ //TODO remove for v2

Check warning on line 2399 in src/Kiota.Builder/KiotaBuilder.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)
var modernProp = (CodeProperty)prop.Clone();
modernProp.Name = $"{prop.Name}As{modernProp.Type.Name.ToFirstCharacterUpperCase()}";
modernProp.SerializationName = prop.WireName;
Expand Down
4 changes: 2 additions & 2 deletions src/kiota/Handlers/BaseKiotaCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ private static string GetSourceArg(string path, string manifest)
}
protected void DisplayUrlInformation(string? apiRootUrl, bool isPlugin = false)
{
if (!string.IsNullOrEmpty(apiRootUrl))
DisplayInfo($"{(isPlugin ? "Plugin" : "Client")} base url set to {apiRootUrl}");
if (!string.IsNullOrEmpty(apiRootUrl) && !isPlugin)
DisplayInfo($"Client base url set to {apiRootUrl}");
}
protected void DisplayGenerateCommandHint()
{
Expand Down
2 changes: 1 addition & 1 deletion src/kiota/Handlers/Plugin/AddHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override async Task<int> InvokeAsync(InvocationContext context)
if (result)
{
DisplaySuccess("Generation completed successfully");
DisplayUrlInformation(Configuration.Generation.ApiRootUrl);
DisplayUrlInformation(Configuration.Generation.ApiRootUrl, true);
}
else if (skipGeneration)
{
Expand Down
2 changes: 1 addition & 1 deletion src/kiota/Handlers/Plugin/EditHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public override async Task<int> InvokeAsync(InvocationContext context)
if (result)
{
DisplaySuccess("Generation completed successfully");
DisplayUrlInformation(Configuration.Generation.ApiRootUrl);
DisplayUrlInformation(Configuration.Generation.ApiRootUrl, true);
}
else if (skipGeneration)
{
Expand Down
Loading