diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/SchemaBuilder.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/SchemaBuilder.cs index b84cafd7d..8a1a95b7e 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/SchemaBuilder.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/SchemaBuilder.cs @@ -51,14 +51,14 @@ namespace Squidex.Domain.Apps.Core.GenerateJsonSchema return Enrich(new JsonSchemaProperty { Type = JsonObjectType.Number }, description, isRequired); } - public static JsonSchemaProperty ObjectProperty(JsonSchema item, string? description = null, bool isRequired = false) + public static JsonSchemaProperty StringProperty(string? description = null, bool isRequired = false) { - return Enrich(new JsonSchemaProperty { Type = JsonObjectType.Object, Reference = item }, description, isRequired); + return Enrich(new JsonSchemaProperty { Type = JsonObjectType.String }, description, isRequired); } - public static JsonSchemaProperty StringProperty(string? description = null, bool isRequired = false) + public static JsonSchemaProperty ObjectProperty(JsonSchema reference, string? description = null, bool isRequired = false) { - return Enrich(new JsonSchemaProperty { Type = JsonObjectType.String }, description, isRequired); + return Enrich(new JsonSchemaProperty { Reference = reference }, description, isRequired); } public static JsonSchemaProperty JsonProperty(string? description = null, bool isRequired = false) diff --git a/backend/src/Squidex.Infrastructure/Queries/Json/PropertyPathValidator.cs b/backend/src/Squidex.Infrastructure/Queries/Json/PropertyPathValidator.cs index 8361ebde0..855af6232 100644 --- a/backend/src/Squidex.Infrastructure/Queries/Json/PropertyPathValidator.cs +++ b/backend/src/Squidex.Infrastructure/Queries/Json/PropertyPathValidator.cs @@ -23,7 +23,7 @@ namespace Squidex.Infrastructure.Queries.Json { schema = p; - if (schema.Type == JsonObjectType.None) + if (schema.Type == JsonObjectType.None && schema.Reference == null) { break; } diff --git a/backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs b/backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs index ee29ad07e..9ee8ac023 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs @@ -213,9 +213,16 @@ namespace Squidex.Areas.Api.Controllers.Assets } } - using (Profiler.Trace("ResizeUpload")) + try + { + using (Profiler.Trace("ResizeUpload")) + { + await assetStore.UploadAsync(fileName, destinationStream, overwrite); + destinationStream.Position = 0; + } + } + catch (AssetAlreadyExistsException) { - await assetStore.UploadAsync(fileName, destinationStream, overwrite); destinationStream.Position = 0; } diff --git a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryJsonConversionTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryJsonConversionTests.cs index 5f2f5c49d..5872e42cf 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryJsonConversionTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryJsonConversionTests.cs @@ -113,6 +113,14 @@ namespace Squidex.Infrastructure.Queries AssertErrors(json, "'notfound' is not a property of 'nested'."); } + [Fact] + public void Should_add_error_if_nested_reference_property_does_not_exist() + { + var json = new { path = "reference.notfound", op = "eq", value = 1 }; + + AssertErrors(json, "'notfound' is not a property of 'nested'."); + } + public static IEnumerable DateTimeTests() { const string value = "2012-11-10T09:08:07Z";