diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a237a2e1a..6bb280df03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ruby JSON serialization #429 +### Changed + +- Fixed #428 a bug where inline double defintion would make code dom generation fail + ## [0.0.7] - 2021-08-04 ### Added 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));