Browse Source

Feature/more openapi tests (#837)

* More OpenAPI tests

* Open API improvements.
pull/840/head
Sebastian Stehle 4 years ago
committed by GitHub
parent
commit
9fc1d7871d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      backend/src/Squidex.Domain.Apps.Core.Model/FieldDescriptions.Designer.cs
  2. 6
      backend/src/Squidex.Domain.Apps.Core.Model/FieldDescriptions.resx
  3. 5
      backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/ContentJsonSchema.cs
  4. 4
      backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/Builder.cs
  5. 4
      backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/SchemasOpenApiGenerator.cs
  6. 28
      backend/tools/TestSuite/TestSuite.ApiTests/OpenApiTests.cs

8
backend/src/Squidex.Domain.Apps.Core.Model/FieldDescriptions.Designer.cs

@ -448,11 +448,11 @@ namespace Squidex.Domain.Apps.Core {
}
/// <summary>
/// Looks up a localized string similar to The name of the schema..
/// Looks up a localized string similar to The display name of the schema..
/// </summary>
public static string ContentSchema {
public static string ContentSchemaDisplayName {
get {
return ResourceManager.GetString("ContentSchema", resourceCulture);
return ResourceManager.GetString("ContentSchemaDisplayName", resourceCulture);
}
}
@ -466,7 +466,7 @@ namespace Squidex.Domain.Apps.Core {
}
/// <summary>
/// Looks up a localized string similar to The display name of the schema..
/// Looks up a localized string similar to The name of the schema..
/// </summary>
public static string ContentSchemaName {
get {

6
backend/src/Squidex.Domain.Apps.Core.Model/FieldDescriptions.resx

@ -246,14 +246,14 @@
<data name="ContentRequestStatus" xml:space="preserve">
<value>The status for the content.</value>
</data>
<data name="ContentSchema" xml:space="preserve">
<value>The name of the schema.</value>
<data name="ContentSchemaDisplayName" xml:space="preserve">
<value>The display name of the schema.</value>
</data>
<data name="ContentSchemaId" xml:space="preserve">
<value>The ID of the schema.</value>
</data>
<data name="ContentSchemaName" xml:space="preserve">
<value>The display name of the schema.</value>
<value>The name of the schema.</value>
</data>
<data name="ContentsItems" xml:space="preserve">
<value>The contents.</value>

5
backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/ContentJsonSchema.cs

@ -37,8 +37,9 @@ namespace Squidex.Domain.Apps.Core.GenerateJsonSchema
if (extended)
{
jsonSchema.Properties["newStatusColor"] = JsonTypeBuilder.StringProperty(FieldDescriptions.ContentNewStatusColor, false);
jsonSchema.Properties["schema"] = JsonTypeBuilder.StringProperty(FieldDescriptions.ContentSchema, true);
jsonSchema.Properties["SchemaName"] = JsonTypeBuilder.StringProperty(FieldDescriptions.ContentSchemaName, true);
jsonSchema.Properties["schemaId"] = JsonTypeBuilder.StringProperty(FieldDescriptions.ContentSchemaId, true);
jsonSchema.Properties["schemaName"] = JsonTypeBuilder.StringProperty(FieldDescriptions.ContentSchemaName, true);
jsonSchema.Properties["schemaDisplayName"] = JsonTypeBuilder.StringProperty(FieldDescriptions.ContentSchemaDisplayName, true);
jsonSchema.Properties["statusColor"] = JsonTypeBuilder.StringProperty(FieldDescriptions.ContentStatusColor, true);
}

4
backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/Builder.cs

@ -60,7 +60,7 @@ namespace Squidex.Areas.Api.Controllers.Contents.Generator
return BuildResult(contentSchema);
});
var path = $"/content/{AppName}";
var path = $"api/content/{AppName}";
var builder = new OperationsBuilder
{
@ -108,7 +108,7 @@ namespace Squidex.Areas.Api.Controllers.Contents.Generator
return BuildResult(contentSchema);
});
var path = $"/content/{AppName}/{schema.Name}";
var path = $"api/content/{AppName}/{schema.Name}";
var builder = new OperationsBuilder
{

4
backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/SchemasOpenApiGenerator.cs

@ -110,7 +110,7 @@ namespace Squidex.Areas.Api.Controllers.Contents.Generator
.Describe(Resources.OpenApiSchemaQuery)
.HasQueryOptions(true)
.Responds(200, "Content items retrieved.", builder.ContentsSchema)
.Responds(400, "Query not valid.");
.Responds(400, "Content query not valid.");
builder.AddOperation(OpenApiOperationMethod.Get, "/{id}")
.RequirePermission(Permissions.AppContentsReadOwn)
@ -121,7 +121,7 @@ namespace Squidex.Areas.Api.Controllers.Contents.Generator
builder.AddOperation(OpenApiOperationMethod.Get, "/{id}/{version}")
.RequirePermission(Permissions.AppContentsReadOwn)
.Operation("Get")
.Operation("GetVersioned")
.OperationSummary("Get a [schema] content item by id and version.")
.HasPath("version", JsonObjectType.Number, "The version of the content item.")
.HasId()

28
backend/tools/TestSuite/TestSuite.ApiTests/OpenApiTests.cs

@ -13,17 +13,17 @@ using Xunit;
namespace TestSuite.ApiTests
{
public class OpenApiTests : IClassFixture<ClientManagerFixture>
public class OpenApiTests : IClassFixture<ContentFixture>
{
public ClientManagerFixture _ { get; }
public ContentFixture _ { get; }
public OpenApiTests(ClientManagerFixture fixture)
public OpenApiTests(ContentFixture fixture)
{
_ = fixture;
}
[Fact]
public async Task Should_provide_spec()
public async Task Should_provide_general_spec()
{
var url = $"{_.ClientManager.Options.Url}/api/swagger/v1/swagger.json";
@ -31,5 +31,25 @@ namespace TestSuite.ApiTests
Assert.NotNull(document);
}
[Fact]
public async Task Should_provide_content_spec()
{
var url = $"{_.ClientManager.Options.Url}/api/content/{_.AppName}/swagger/v1/swagger.json";
var document = await OpenApiDocument.FromUrlAsync(url);
Assert.NotNull(document);
}
[Fact]
public async Task Should_provide_flat_content_spec()
{
var url = $"{_.ClientManager.Options.Url}/api/content/{_.AppName}/flat/swagger/v1/swagger.json";
var document = await OpenApiDocument.FromUrlAsync(url);
Assert.NotNull(document);
}
}
}

Loading…
Cancel
Save