From 89c3e3c9780a58fe046412dbced3a7a9fa08fe57 Mon Sep 17 00:00:00 2001 From: HavenDV Date: Fri, 4 Oct 2024 00:03:38 +0400 Subject: [PATCH] fix: Fixed small issues with weaviate spec. --- src/libs/AutoSDK/Extensions/OpenApiExtensions.cs | 1 + src/libs/AutoSDK/Models/TypeData.cs | 4 +++- src/libs/AutoSDK/Sources/Sources.Models.cs | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libs/AutoSDK/Extensions/OpenApiExtensions.cs b/src/libs/AutoSDK/Extensions/OpenApiExtensions.cs index a94fd35ff7..2ce75d7078 100644 --- a/src/libs/AutoSDK/Extensions/OpenApiExtensions.cs +++ b/src/libs/AutoSDK/Extensions/OpenApiExtensions.cs @@ -519,6 +519,7 @@ public static PropertyData ToEnumValue( .UseWordSeparator('_', '-', ' ', '.') .Replace("+", "Plus") .Replace("*", "Any") + .Replace("[]", "Array") .Replace("'", string.Empty) .Replace(".", string.Empty) .Replace("[", string.Empty) diff --git a/src/libs/AutoSDK/Models/TypeData.cs b/src/libs/AutoSDK/Models/TypeData.cs index 8d4c864b00..d8e0fa8c45 100644 --- a/src/libs/AutoSDK/Models/TypeData.cs +++ b/src/libs/AutoSDK/Models/TypeData.cs @@ -231,7 +231,7 @@ public static string GetCSharpType(SchemaContext context) // !context.Schema.ResolveIfRequired().AdditionalPropertiesAllowed) => // $"global::{context.Settings.Namespace}.{context.Id}", - ("object", _) when context.Schema.Reference == null => + ("object", _) or (null, "object") when context.Schema.Reference == null => $"global::{context.Settings.Namespace}.{context.Id}", // ("object", _) when @@ -249,6 +249,7 @@ public static string GetCSharpType(SchemaContext context) $"global::{context.Settings.Namespace}.{context.Id}", ("boolean", _) => "bool", + (null, "boolean") => "bool", ("integer", "int32") => "int", ("integer", "int64") => "long", ("number", "float") => "float", @@ -274,6 +275,7 @@ public static string GetCSharpType(SchemaContext context) ("integer", _) => "int", ("number", _) => "double", ("string", _) => "string", + (null, "string") => "string", ("object", _) => "object", ("array", _) => $"{context.Children.FirstOrDefault(x => x.Hint == Hint.ArrayItem)?.TypeData?.CSharpTypeWithoutNullability}".AsArray(), diff --git a/src/libs/AutoSDK/Sources/Sources.Models.cs b/src/libs/AutoSDK/Sources/Sources.Models.cs index 431b294ab5..1a397b584d 100644 --- a/src/libs/AutoSDK/Sources/Sources.Models.cs +++ b/src/libs/AutoSDK/Sources/Sources.Models.cs @@ -76,6 +76,9 @@ public static string GenerateClassModel( var requiredKeyword = isRequiredKeywordSupported ? " required" : string.Empty; + var additionalPropertiesPostfix = modelData.ClassName == "AdditionalProperties" + ? "2" + : string.Empty; return $@" {modelData.Summary.ToXmlDocumentationSummary(level: 4)} @@ -93,7 +96,7 @@ public sealed partial class {modelData.ClassName} {"Additional properties that are not explicitly defined in the schema".ToXmlDocumentationSummary(level: 8)} {jsonSerializer.GenerateExtensionDataAttribute()} - public global::System.Collections.Generic.IDictionary AdditionalProperties {{ get; set; }} = new global::System.Collections.Generic.Dictionary(); + public global::System.Collections.Generic.IDictionary AdditionalProperties{additionalPropertiesPostfix} {{ get; set; }} = new global::System.Collections.Generic.Dictionary(); }}".RemoveBlankLinesWhereOnlyWhitespaces(); } } \ No newline at end of file