Skip to content

Commit

Permalink
initial fixes for oneOf in python
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed May 20, 2024
1 parent 6e82963 commit 7f0d4c1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ private void WriteDeserializerBodyForUnionModel(CodeMethod method, CodeClass par
.ThenBy(static x => x.Name)
.Select(static x => x.Name))
{
writer.StartBlock($"if self.{otherPropName}:");
writer.StartBlock($"if hasattr(self, \"{otherPropName}\"):");
writer.WriteLine($"return self.{otherPropName}.{method.Name}()");
writer.DecreaseIndent();
}
Expand Down Expand Up @@ -659,7 +659,7 @@ private void WriteSerializerBodyForUnionModel(CodeClass parentClass, LanguageWri
.OrderBy(static x => x, CodePropertyTypeForwardComparer)
.ThenBy(static x => x.Name))
{
writer.StartBlock($"{(includeElse ? "el" : string.Empty)}if self.{otherProp.Name}:");
writer.StartBlock($"{(includeElse ? "el" : string.Empty)}if hasattr(self, \"{otherProp.Name}\"):");
writer.WriteLine($"writer.{GetSerializationMethodName(otherProp.Type)}(None, self.{otherProp.Name})");
writer.DecreaseIndent();
if (!includeElse)
Expand All @@ -676,7 +676,7 @@ private void WriteSerializerBodyForIntersectionModel(CodeClass parentClass, Lang
.OrderBy(static x => x, CodePropertyTypeBackwardComparer)
.ThenBy(static x => x.Name))
{
writer.StartBlock($"{(includeElse ? "el" : string.Empty)}if self.{otherProp.Name}:");
writer.StartBlock($"{(includeElse ? "el" : string.Empty)}if hasattr(self, \"{otherProp.Name}\"):");
writer.WriteLine($"writer.{GetSerializationMethodName(otherProp.Type)}(None, self.{otherProp.Name})");
writer.DecreaseIndent();
if (!includeElse)
Expand Down

0 comments on commit 7f0d4c1

Please sign in to comment.