diff --git a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs index 2596bc096b..69b98f6a71 100644 --- a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs +++ b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs @@ -345,8 +345,8 @@ private static void ReplaceDeserializerMethodForComposedType(CodeInterface codeI if (deserializerMethod is null) return; - // For code union Deserializer is not required, however its needed fo Intersection types - if (composedType is CodeIntersectionType) + // For code union Deserializer is not required, however its needed for Object Intersection types + if (composedType is CodeIntersectionType && !ConventionServiceInstance.IsComposedOfPrimitives(composedType)) { var method = CreateDeserializerMethodForComposedType(codeInterface, deserializerMethod); var deserializerFunction = new CodeFunction(method) { Name = method.Name }; diff --git a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeFunctionWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeFunctionWriterTests.cs index 860afa0bdb..cc12d53909 100644 --- a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeFunctionWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeFunctionWriterTests.cs @@ -1159,8 +1159,6 @@ public async Task Writes_UnionOfPrimitiveValues_FactoryFunction() Assert.NotNull(modelCodeFile); /* - * - * \/** * Creates a new instance of the appropriate class based on discriminator value * @returns {ValidationError_errors_value} @@ -1200,7 +1198,7 @@ public async Task Writes_UnionOfPrimitiveValues_SerializerFunction() var tempFilePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); await File.WriteAllTextAsync(tempFilePath, GithubRepos.OpenApiYaml); var mockLogger = new Mock>(); - var builder = new KiotaBuilder(mockLogger.Object, new GenerationConfiguration { ClientClassName = "Github", OpenAPIFilePath = "https://api.apis.guru/v2/specs/github.com/api.github.com/1.1.4/openapi.json", Serializers = ["none"], Deserializers = ["none"] }, _httpClient); + var builder = new KiotaBuilder(mockLogger.Object, new GenerationConfiguration { ClientClassName = "Github", OpenAPIFilePath = "https://api.example.com/v1", Serializers = ["none"], Deserializers = ["none"] }, _httpClient); await using var fs = new FileStream(tempFilePath, FileMode.Open); var document = await builder.CreateOpenApiDocumentAsync(fs); var node = builder.CreateUriSpace(document); @@ -1241,7 +1239,7 @@ public async Task Writes_UnionOfObjects_SerializerFunctions() var tempFilePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); await File.WriteAllTextAsync(tempFilePath, PetsUnion.OpenApiYaml); var mockLogger = new Mock>(); - var builder = new KiotaBuilder(mockLogger.Object, new GenerationConfiguration { ClientClassName = "Pets", OpenAPIFilePath = "https://api.apis.guru/v2/specs/github.com/api.github.com/1.1.4/openapi.json", Serializers = ["none"], Deserializers = ["none"] }, _httpClient); + var builder = new KiotaBuilder(mockLogger.Object, new GenerationConfiguration { ClientClassName = "Pets", OpenAPIFilePath = "https://api.example.com/v1", Serializers = ["none"], Deserializers = ["none"] }, _httpClient); await using var fs = new FileStream(tempFilePath, FileMode.Open); var document = await builder.CreateOpenApiDocumentAsync(fs); var node = builder.CreateUriSpace(document);