From bac834f095acbf36bac9e5413c84b9ea8fac1cb0 Mon Sep 17 00:00:00 2001 From: koros Date: Thu, 14 Nov 2024 14:15:39 +0300 Subject: [PATCH] write all properties including ones in the base class --- .../HTTP/CodeClassDeclarationWriter.cs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Kiota.Builder/Writers/HTTP/CodeClassDeclarationWriter.cs b/src/Kiota.Builder/Writers/HTTP/CodeClassDeclarationWriter.cs index b18a052af2..1aee645f9f 100644 --- a/src/Kiota.Builder/Writers/HTTP/CodeClassDeclarationWriter.cs +++ b/src/Kiota.Builder/Writers/HTTP/CodeClassDeclarationWriter.cs @@ -125,15 +125,27 @@ private static void WriteRequestBody(CodeMethod method, LanguageWriter writer) { writer.WriteLine("{"); writer.IncreaseIndent(); - foreach (var prop in requestBodyClass.Properties.Where(prop => prop.IsOfKind(CodePropertyKind.Custom))) - { - writer.WriteLine($"{prop.Name}: {GetDefaultValueForProperty(prop)}"); - } + WriteProperties(requestBodyClass, writer); writer.DecreaseIndent(); writer.WriteLine("}"); } } + private static void WriteProperties(CodeClass codeClass, LanguageWriter writer) + { + // Write properties of the current class + foreach (var prop in codeClass.Properties.Where(prop => prop.IsOfKind(CodePropertyKind.Custom))) + { + writer.WriteLine($"{prop.Name}: {GetDefaultValueForProperty(prop)}"); + } + + // If the class extends another class, write properties of the base class + if (codeClass.StartBlock.Inherits?.TypeDefinition is CodeClass baseClass) + { + WriteProperties(baseClass, writer); + } + } + private static string GetDefaultValueForProperty(CodeProperty prop) { return prop.Type.Name switch