Skip to content

Commit

Permalink
fix: Fixed small issues with weaviate spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Oct 3, 2024
1 parent 7b860df commit 89c3e3c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/libs/AutoSDK/Extensions/OpenApiExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ public static PropertyData ToEnumValue(
.UseWordSeparator('_', '-', ' ', '.')
.Replace("+", "Plus")
.Replace("*", "Any")
.Replace("[]", "Array")
.Replace("'", string.Empty)
.Replace(".", string.Empty)
.Replace("[", string.Empty)
Expand Down
4 changes: 3 additions & 1 deletion src/libs/AutoSDK/Models/TypeData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand All @@ -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(),
Expand Down
5 changes: 4 additions & 1 deletion src/libs/AutoSDK/Sources/Sources.Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand All @@ -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<string, object> AdditionalProperties {{ get; set; }} = new global::System.Collections.Generic.Dictionary<string, object>();
public global::System.Collections.Generic.IDictionary<string, object> AdditionalProperties{additionalPropertiesPostfix} {{ get; set; }} = new global::System.Collections.Generic.Dictionary<string, object>();
}}".RemoveBlankLinesWhereOnlyWhitespaces();
}
}

0 comments on commit 89c3e3c

Please sign in to comment.