From e778f7e74c5a80fa31ac49d9bbc5ff3810e8ace8 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 12 Aug 2021 09:32:41 -0400 Subject: [PATCH] - fixes #428 a bug where inline double defintion would make dom generation fail --- CHANGELOG.md | 1 + src/Kiota.Builder/KiotaBuilder.cs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5353e2ded5..a6d39bbb91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Fixed a bug where raw collections requests would not be supported #467 +- Fixed #428 a bug where inline double defintion would make code dom generation fail ## [0.0.7] - 2021-08-04 diff --git a/src/Kiota.Builder/KiotaBuilder.cs b/src/Kiota.Builder/KiotaBuilder.cs index 19f1b1e642..02c1ccb0ab 100644 --- a/src/Kiota.Builder/KiotaBuilder.cs +++ b/src/Kiota.Builder/KiotaBuilder.cs @@ -456,6 +456,8 @@ private CodeProperty CreateProperty(string childIdentifier, string childType, Co private static HashSet typeNamesToSkip = new() {"object", "array"}; private static CodeType GetPrimitiveType(CodeElement parent, OpenApiSchema typeSchema, string childType) { var typeNames = new List{typeSchema?.Items?.Type, childType, typeSchema?.Type}; + if(typeSchema?.AnyOf?.Any() ?? false) + typeNames.AddRange(typeSchema.AnyOf.Select(x => x.Type)); // double is sometimes an anyof string, number and enum // first value that's not null, and not "object" for primitive collections, the items type matters var typeName = typeNames.FirstOrDefault(x => !string.IsNullOrEmpty(x) && !typeNamesToSkip.Contains(x));