Browse Source

Fix query validator and already uploaded assets.

pull/556/head
Sebastian 5 years ago
parent
commit
abbe9dd8b8
  1. 8
      backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/SchemaBuilder.cs
  2. 2
      backend/src/Squidex.Infrastructure/Queries/Json/PropertyPathValidator.cs
  3. 7
      backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs
  4. 8
      backend/tests/Squidex.Infrastructure.Tests/Queries/QueryJsonConversionTests.cs

8
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)

2
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;
}

7
backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs

@ -213,11 +213,18 @@ namespace Squidex.Areas.Api.Controllers.Assets
}
}
try
{
using (Profiler.Trace("ResizeUpload"))
{
await assetStore.UploadAsync(fileName, destinationStream, overwrite);
destinationStream.Position = 0;
}
}
catch (AssetAlreadyExistsException)
{
destinationStream.Position = 0;
}
await destinationStream.CopyToAsync(bodyStream, ct);
}

8
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<object[]> DateTimeTests()
{
const string value = "2012-11-10T09:08:07Z";

Loading…
Cancel
Save