diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonTypeVisitor.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonTypeVisitor.cs index 8c29811a7..0b6d519ba 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonTypeVisitor.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonTypeVisitor.cs @@ -81,12 +81,30 @@ namespace Squidex.Domain.Apps.Core.GenerateJsonSchema public JsonSchemaProperty? Visit(IField field, Args args) { - return JsonTypeBuilder.ArrayProperty(JsonTypeBuilder.String()); + var property = JsonTypeBuilder.ArrayProperty(JsonTypeBuilder.String()); + + property.Default = field.Properties.DefaultValue; + + if (field.Properties.MinItems != null) + { + property.MinItems = field.Properties.MinItems.Value; + } + + if (field.Properties.MaxItems != null) + { + property.MaxItems = field.Properties.MaxItems.Value; + } + + return property; } public JsonSchemaProperty? Visit(IField field, Args args) { - return JsonTypeBuilder.BooleanProperty(); + var property = JsonTypeBuilder.BooleanProperty(); + + property.Default = field.Properties.DefaultValue; + + return property; } public JsonSchemaProperty? Visit(IField field, Args args) @@ -104,12 +122,28 @@ namespace Squidex.Domain.Apps.Core.GenerateJsonSchema BuildComponent(itemSchema, field.Properties.SchemaIds, args); - return JsonTypeBuilder.ArrayProperty(itemSchema); + var property = JsonTypeBuilder.ArrayProperty(itemSchema); + + if (field.Properties.MinItems != null) + { + property.MinItems = field.Properties.MinItems.Value; + } + + if (field.Properties.MaxItems != null) + { + property.MaxItems = field.Properties.MaxItems.Value; + } + + return property; } public JsonSchemaProperty? Visit(IField field, Args args) { - return JsonTypeBuilder.DateTimeProperty(); + var property = JsonTypeBuilder.DateTimeProperty(); + + property.Default = field.Properties.DefaultValue?.ToString(); + + return property; } public JsonSchemaProperty? Visit(IField field, Args args) @@ -130,6 +164,8 @@ namespace Squidex.Domain.Apps.Core.GenerateJsonSchema { var property = JsonTypeBuilder.NumberProperty(); + property.Default = field.Properties.DefaultValue; + if (field.Properties.MinValue != null) { property.Minimum = (decimal)field.Properties.MinValue.Value; @@ -147,13 +183,25 @@ namespace Squidex.Domain.Apps.Core.GenerateJsonSchema { var property = JsonTypeBuilder.ArrayProperty(JsonTypeBuilder.String()); - property.Format = GeoJson.Format; + property.Default = field.Properties.DefaultValue; + + if (field.Properties.MinItems != null) + { + property.MinItems = field.Properties.MinItems.Value; + } + + if (field.Properties.MaxItems != null) + { + property.MaxItems = field.Properties.MaxItems.Value; + } property.ExtensionData = new Dictionary { ["schemaIds"] = field.Properties.SchemaIds ?? ReadonlyList.Empty() }; + property.UniqueItems = !field.Properties.AllowDuplicates; + return property; } @@ -161,6 +209,8 @@ namespace Squidex.Domain.Apps.Core.GenerateJsonSchema { var property = JsonTypeBuilder.StringProperty(); + property.Default = field.Properties.DefaultValue; + property.MaxLength = field.Properties.MaxLength; property.MinLength = field.Properties.MinLength; @@ -181,7 +231,21 @@ namespace Squidex.Domain.Apps.Core.GenerateJsonSchema public JsonSchemaProperty? Visit(IField field, Args args) { - return JsonTypeBuilder.ArrayProperty(JsonTypeBuilder.String()); + var property = JsonTypeBuilder.ArrayProperty(JsonTypeBuilder.String()); + + property.Default = field.Properties.DefaultValue; + + if (field.Properties.MinItems != null) + { + property.MinItems = field.Properties.MinItems.Value; + } + + if (field.Properties.MaxItems != null) + { + property.MaxItems = field.Properties.MaxItems.Value; + } + + return property; } public JsonSchemaProperty? Visit(IField field, Args args)