From da65154595ffb2bd72b8432915a422506a89eae5 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:02:29 +0300 Subject: [PATCH 1/6] Fixes Go snippet generation --- CHANGELOG.md | 2 ++ src/Kiota.Builder/Refiners/GoRefiner.cs | 2 +- tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d354665a1f..90839f499f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Fixes bug with model names in Go generated from camel case namespace. [https://github.com/microsoftgraph/msgraph-sdk-go/issues/721] + ## [1.15.0] - 2024-06-06 ### Added diff --git a/src/Kiota.Builder/Refiners/GoRefiner.cs b/src/Kiota.Builder/Refiners/GoRefiner.cs index 113d1399c7..89926604c6 100644 --- a/src/Kiota.Builder/Refiners/GoRefiner.cs +++ b/src/Kiota.Builder/Refiners/GoRefiner.cs @@ -19,7 +19,6 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance { cancellationToken.ThrowIfCancellationRequested(); DeduplicateErrorMappings(generatedCode); - NormalizeNamespaceNames(generatedCode); MoveRequestBuilderPropertiesToBaseType(generatedCode, new CodeUsing { @@ -207,6 +206,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance "Error", () => new CodeType { Name = "string", IsNullable = false, IsExternal = true } ); + NormalizeNamespaceNames(generatedCode); GenerateCodeFiles(generatedCode); }, cancellationToken); } diff --git a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs index 59f73cde09..6a0d0a370b 100644 --- a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs @@ -1189,9 +1189,12 @@ public async Task NormalizeNamespaceName() root.Name = "github.com/OrgName/RepoName"; var models = root.AddNamespace("ApiSdk.models"); var submodels = models.AddNamespace("ApiSdk.models.submodels"); + var camelCaseModel = submodels.AddNamespace("ApiSdk.models.submodels.camelCase"); await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.Go, ClientNamespaceName = "github.com/OrgName/RepoName" }, root); Assert.Equal("github.com/OrgName/RepoName.apisdk.models.submodels", submodels.Name); Assert.Equal("github.com/OrgName/RepoName.apisdk.models", models.Name); + Assert.Equal("github.com/OrgName/RepoName.apisdk.models.submodels.camelcase", camelCaseModel.Name); } + #endregion } From bc9bdc0726649ae10de77c9606a44139b62a6336 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:27:13 +0300 Subject: [PATCH 2/6] Format code --- tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs index 6a0d0a370b..4d2e36bdae 100644 --- a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs @@ -1195,6 +1195,6 @@ public async Task NormalizeNamespaceName() Assert.Equal("github.com/OrgName/RepoName.apisdk.models", models.Name); Assert.Equal("github.com/OrgName/RepoName.apisdk.models.submodels.camelcase", camelCaseModel.Name); } - + #endregion } From a18085d73edc93198d296bb9611725d5beb0b50e Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:02:29 +0300 Subject: [PATCH 3/6] Fixes Go snippet generation --- CHANGELOG.md | 2 ++ src/Kiota.Builder/Refiners/GoRefiner.cs | 2 +- tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d354665a1f..90839f499f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Fixes bug with model names in Go generated from camel case namespace. [https://github.com/microsoftgraph/msgraph-sdk-go/issues/721] + ## [1.15.0] - 2024-06-06 ### Added diff --git a/src/Kiota.Builder/Refiners/GoRefiner.cs b/src/Kiota.Builder/Refiners/GoRefiner.cs index 113d1399c7..89926604c6 100644 --- a/src/Kiota.Builder/Refiners/GoRefiner.cs +++ b/src/Kiota.Builder/Refiners/GoRefiner.cs @@ -19,7 +19,6 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance { cancellationToken.ThrowIfCancellationRequested(); DeduplicateErrorMappings(generatedCode); - NormalizeNamespaceNames(generatedCode); MoveRequestBuilderPropertiesToBaseType(generatedCode, new CodeUsing { @@ -207,6 +206,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance "Error", () => new CodeType { Name = "string", IsNullable = false, IsExternal = true } ); + NormalizeNamespaceNames(generatedCode); GenerateCodeFiles(generatedCode); }, cancellationToken); } diff --git a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs index 59f73cde09..6a0d0a370b 100644 --- a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs @@ -1189,9 +1189,12 @@ public async Task NormalizeNamespaceName() root.Name = "github.com/OrgName/RepoName"; var models = root.AddNamespace("ApiSdk.models"); var submodels = models.AddNamespace("ApiSdk.models.submodels"); + var camelCaseModel = submodels.AddNamespace("ApiSdk.models.submodels.camelCase"); await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.Go, ClientNamespaceName = "github.com/OrgName/RepoName" }, root); Assert.Equal("github.com/OrgName/RepoName.apisdk.models.submodels", submodels.Name); Assert.Equal("github.com/OrgName/RepoName.apisdk.models", models.Name); + Assert.Equal("github.com/OrgName/RepoName.apisdk.models.submodels.camelcase", camelCaseModel.Name); } + #endregion } From cf0b65405d3075bcdc9a9dca289f9d22098556e4 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:27:13 +0300 Subject: [PATCH 4/6] Format code --- tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs index 6a0d0a370b..4d2e36bdae 100644 --- a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs @@ -1195,6 +1195,6 @@ public async Task NormalizeNamespaceName() Assert.Equal("github.com/OrgName/RepoName.apisdk.models", models.Name); Assert.Equal("github.com/OrgName/RepoName.apisdk.models.submodels.camelcase", camelCaseModel.Name); } - + #endregion } From dc4ec45bcaceb4dfd662999cd3d059eb9412e4f8 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Tue, 18 Jun 2024 11:29:32 +0300 Subject: [PATCH 5/6] Fix build --- src/Kiota.Builder/Refiners/GoRefiner.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kiota.Builder/Refiners/GoRefiner.cs b/src/Kiota.Builder/Refiners/GoRefiner.cs index 89926604c6..555f28350d 100644 --- a/src/Kiota.Builder/Refiners/GoRefiner.cs +++ b/src/Kiota.Builder/Refiners/GoRefiner.cs @@ -39,6 +39,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance FlattenNestedHierarchy(generatedCode); FlattenGoParamsFileNames(generatedCode); FlattenGoFileNames(generatedCode); + NormalizeNamespaceNames(generatedCode); AddInnerClasses( generatedCode, true, @@ -206,7 +207,6 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance "Error", () => new CodeType { Name = "string", IsNullable = false, IsExternal = true } ); - NormalizeNamespaceNames(generatedCode); GenerateCodeFiles(generatedCode); }, cancellationToken); } From 7163c58f214c0174a7b198b609e5f16701aac3d2 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Mon, 1 Jul 2024 10:59:12 +0300 Subject: [PATCH 6/6] fix missing version --- src/Kiota.Builder/Refiners/GoRefiner.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Kiota.Builder/Refiners/GoRefiner.cs b/src/Kiota.Builder/Refiners/GoRefiner.cs index 1a3ef32680..555f28350d 100644 --- a/src/Kiota.Builder/Refiners/GoRefiner.cs +++ b/src/Kiota.Builder/Refiners/GoRefiner.cs @@ -207,7 +207,6 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance "Error", () => new CodeType { Name = "string", IsNullable = false, IsExternal = true } ); - NormalizeNamespaceNames(generatedCode); GenerateCodeFiles(generatedCode); }, cancellationToken); }