Browse Source
Feature/more openapi tests (#837)
* More OpenAPI tests
* Open API improvements.
pull/840/head
Sebastian Stehle
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
38 additions and
17 deletions
-
backend/src/Squidex.Domain.Apps.Core.Model/FieldDescriptions.Designer.cs
-
backend/src/Squidex.Domain.Apps.Core.Model/FieldDescriptions.resx
-
backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/ContentJsonSchema.cs
-
backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/Builder.cs
-
backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/SchemasOpenApiGenerator.cs
-
backend/tools/TestSuite/TestSuite.ApiTests/OpenApiTests.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 { |
|
|
|
|
|
|
|
@ -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> |
|
|
|
|
|
|
|
@ -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); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -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 |
|
|
|
{ |
|
|
|
|
|
|
|
@ -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() |
|
|
|
|
|
|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|