Skip to content
Draft
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Fixed a bug where TypeScript deserialization of oneOf types with inheritance would incorrectly place derived type properties in additionalProperties. [#6896](https://github.com/microsoft/kiota/issues/6896)
- Fixed a bug where Go model interfaces would redundantly include GetBackingStore method when backing store was enabled, even though it's already defined in the composed BackedModel interface.

## [1.29.0] - 2025-10-23

Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ private static CodeInterface CopyClassAsInterface(CodeClass modelClass, Func<Cod
.Where(x => x.IsOfKind(CodeMethodKind.Getter,
CodeMethodKind.Setter,
CodeMethodKind.Factory) &&
!(x.AccessedProperty?.IsOfKind(CodePropertyKind.AdditionalData) ?? false)))
!(x.AccessedProperty?.IsOfKind(CodePropertyKind.AdditionalData, CodePropertyKind.BackingStore) ?? false)))
{
if (method.ReturnType is CodeType methodReturnType &&
!methodReturnType.IsExternal)
Expand Down
44 changes: 44 additions & 0 deletions tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1388,5 +1388,49 @@ public async Task EscapesReservedKeywordsInMethodParametersAsync()
Assert.DoesNotContain(method.Parameters, p => p.Name == "type");
Assert.DoesNotContain(method.Parameters, p => p.Name == "select");
}
[Fact]
public async Task DoesNotIncludeBackingStoreMethodsInInterfacesAsync()
{
var model = root.AddClass(new CodeClass
{
Name = "somemodel",
Kind = CodeClassKind.Model,
}).First();

// The GoRefiner will automatically add getter/setter methods for properties
var backingStoreProperty = model.AddProperty(new CodeProperty
{
Name = "backingStore",
Kind = CodePropertyKind.BackingStore,
Type = new CodeType
{
Name = "BackingStore",
IsExternal = true,
},
}).First();

var customProperty = model.AddProperty(new CodeProperty
{
Name = "customProp",
Kind = CodePropertyKind.Custom,
Type = new CodeType
{
Name = "string",
IsExternal = true,
},
}).First();

await ILanguageRefiner.RefineAsync(new GenerationConfiguration { Language = GenerationLanguage.Go, UsesBackingStore = true }, root);

var codeFile = root.GetChildElements(true).OfType<CodeFile>().First();
var inter = codeFile.GetChildElements(true).OfType<CodeInterface>().First();

// The interface should have getter and setter for the custom property, but not for the backing store
Assert.DoesNotContain(inter.Methods, m => m.Name == "GetBackingStore");
Assert.DoesNotContain(inter.Methods, m => m.Name == "SetBackingStore");
Assert.Contains(inter.Methods, m => m.Name == "GetCustomProp");
Assert.Contains(inter.Methods, m => m.Name == "SetCustomProp");
Assert.Equal(2, inter.Methods.Count());
}
#endregion
}