Skip to content

Commit

Permalink
Merge pull request #3598 from microsoft/python/bugfix-custom-property…
Browse files Browse the repository at this point in the history
…-names

Python/bugfix custom property names
  • Loading branch information
samwelkanda authored Oct 30, 2023
2 parents cc1c376 + 3f8dd16 commit 0f1d34e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/Kiota.Builder/Refiners/PythonRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ private static void CorrectCommonNames(CodeElement currentElement)
{
param.Name = param.Name.ToFirstCharacterLowerCase().ToSnakeCase();
}
if (parentClassM.IsOfKind(CodeClassKind.Model))
{
foreach (var prop in parentClassM.Properties)
{
if (string.IsNullOrEmpty(prop.SerializationName))
{
prop.SerializationName = prop.Name;
}

parentClassM.RenameChildElement(prop.Name, prop.Name.ToFirstCharacterLowerCase().ToSnakeCase());
}
}
}
else if (currentElement is CodeClass c)
{
Expand All @@ -191,7 +203,6 @@ private static void CorrectCommonNames(CodeElement currentElement)
(p.IsOfKind(CodePropertyKind.RequestAdapter) ||
p.IsOfKind(CodePropertyKind.PathParameters) ||
p.IsOfKind(CodePropertyKind.QueryParameters) ||
p.IsOfKind(CodePropertyKind.Custom) ||
p.IsOfKind(CodePropertyKind.UrlTemplate)) &&
currentElement.Parent is CodeClass parentClassP)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public async Task CorrectsCoreType()
var model = root.AddClass(new CodeClass
{
Name = "model",
Kind = CodeClassKind.Model
Kind = CodeClassKind.RequestBuilder
}).First();
model.AddProperty(new CodeProperty
{
Expand Down

0 comments on commit 0f1d34e

Please sign in to comment.