Skip to content

Commit

Permalink
enable None key for inherited models
Browse files Browse the repository at this point in the history
  • Loading branch information
shemogumbe committed Nov 7, 2024
1 parent a0a3b84 commit 78e472c
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -647,20 +647,12 @@ private void WriteSerializerBodyForInheritedModel(bool inherits, CodeClass paren
if (inherits)
writer.WriteLine("super().serialize(writer)");
foreach (var otherProp in parentClass
.GetPropertiesOfKind(CodePropertyKind.Custom)
.Where(static x => !x.ExistsInBaseType && !x.ReadOnly)
.OrderBy(static x => x.Name))
.GetPropertiesOfKind(CodePropertyKind.Custom)
.Where(static x => !x.ExistsInBaseType && !x.ReadOnly)
.OrderBy(static x => x.Name))
{
var serializationMethodName = GetSerializationMethodName(otherProp.Type);
var propertyName = otherProp.Name;
writer.WriteLine($"if self.{propertyName} is not None:");
writer.IncreaseIndent();
writer.WriteLine($"writer.{serializationMethodName}(\"{otherProp.WireName}\", self.{propertyName})");
writer.DecreaseIndent();
writer.WriteLine("else:");
writer.IncreaseIndent();
writer.WriteLine($"writer.{serializationMethodName}(\"{otherProp.WireName}\", None)");
writer.DecreaseIndent();
writer.WriteLine($"writer.{serializationMethodName}(\"{NoneKeyword}\", self.{otherProp.Name})");
}
}
private void WriteSerializerBodyForUnionModel(CodeClass parentClass, LanguageWriter writer)
Expand Down

0 comments on commit 78e472c

Please sign in to comment.