Skip to content

Commit

Permalink
fix primitive intersection bug
Browse files Browse the repository at this point in the history
  • Loading branch information
koros committed May 30, 2024
1 parent 615b3fa commit ae857c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Kiota.Builder/Refiners/TypeScriptRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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<ILogger<KiotaBuilder>>();
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);
Expand Down Expand Up @@ -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<ILogger<KiotaBuilder>>();
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);
Expand Down

0 comments on commit ae857c5

Please sign in to comment.