Browse Source

Cleanup OpenAPI. (#754)

* Cleanup OpenAPI.

* Fix layout.
pull/756/head
Sebastian Stehle 4 years ago
committed by GitHub
parent
commit
3ed9d9c4bf
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs
  2. 14
      backend/src/Squidex/Areas/Api/Config/OpenApi/OpenApiServices.cs
  3. 4
      backend/src/Squidex/Areas/Api/Controllers/Contents/Models/BulkUpdateContentsJobDto.cs
  4. 18
      backend/src/Squidex/Areas/Api/Controllers/JsonQueryDto.cs
  5. 2
      frontend/app/features/assets/pages/assets-page.component.html
  6. 22
      frontend/app/features/content/pages/content/content-page.component.html
  7. 2
      frontend/app/features/content/pages/contents/contents-page.component.html

5
backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs

@ -14,11 +14,6 @@ namespace Squidex.Domain.Apps.Core.Contents
{
public sealed class ContentData : Dictionary<string, ContentFieldData?>, IEquatable<ContentData>
{
public IEnumerable<KeyValuePair<string, ContentFieldData?>> ValidValues
{
get => this.Where(x => x.Value != null);
}
public ContentData()
: base(StringComparer.Ordinal)
{

14
backend/src/Squidex/Areas/Api/Config/OpenApi/OpenApiServices.cs

@ -20,6 +20,7 @@ using Squidex.Domain.Apps.Core.Assets;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Json.Objects;
using Squidex.Infrastructure.Queries;
namespace Squidex.Areas.Api.Config.OpenApi
{
@ -119,7 +120,10 @@ namespace Squidex.Areas.Api.Config.OpenApi
CreateStringMap<Status>(),
CreateObjectMap<JsonObject>(),
CreateObjectMap<AssetMetadata>()
CreateObjectMap<AssetMetadata>(),
CreateAnyMap<IJsonValue>(),
CreateAnyMap<FilterNode<IJsonValue>>()
};
settings.SchemaType = SchemaType.OpenApi3;
@ -149,5 +153,13 @@ namespace Squidex.Areas.Api.Config.OpenApi
schema.Format = format;
});
}
private static ITypeMapper CreateAnyMap<T>()
{
return new PrimitiveTypeMapper(typeof(T), schema =>
{
schema.Type = JsonObjectType.None;
});
}
}
}

4
backend/src/Squidex/Areas/Api/Controllers/Contents/Models/BulkUpdateContentsJobDto.cs

@ -9,8 +9,6 @@ using NodaTime;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Entities.Contents.Commands;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Json.Objects;
using Squidex.Infrastructure.Queries;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Areas.Api.Controllers.Contents.Models
@ -20,7 +18,7 @@ namespace Squidex.Areas.Api.Controllers.Contents.Models
/// <summary>
/// An optional query to identify the content to update.
/// </summary>
public Query<IJsonValue>? Query { get; set; }
public JsonQueryDto? Query { get; set; }
/// <summary>
/// An optional id of the content to update.

18
backend/src/Squidex/Areas/Api/Controllers/JsonQueryDto.cs

@ -0,0 +1,18 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using NJsonSchema.Annotations;
using Squidex.Infrastructure.Json.Objects;
using Squidex.Infrastructure.Queries;
namespace Squidex.Areas.Api.Controllers
{
[JsonSchemaFlatten]
public sealed class JsonQueryDto : Query<IJsonValue>
{
}
}

2
frontend/app/features/assets/pages/assets-page.component.html

@ -2,7 +2,7 @@
<sqx-layout layout="main" titleText="i18n:common.assets" titleIcon="assets">
<ng-container menu>
<div class="row flex-nowrap gx-2">
<div class="row flex-nowrap flex-grow-1 gx-2">
<div class="col-auto offset-xl-2">
<button type="button" class="btn btn-text-secondary" (click)="reload()" title="i18n:assets.refreshTooltip" shortcut="CTRL + B">
<i class="icon-reset"></i> {{ 'common.refresh' | sqxTranslate }}

22
frontend/app/features/content/pages/content/content-page.component.html

@ -3,19 +3,21 @@
<form [formGroup]="contentForm.form" (ngSubmit)="saveAndPublish()">
<sqx-layout layout="main" [hideSidebar]="!content">
<ng-container title>
<a class="btn btn-text-secondary" (click)="back()" *ngIf="schema.type === 'Default'">
<i class="icon-angle-left"></i>
</a>
<div class="d-flex align-items-center">
<a class="btn btn-text-secondary" (click)="back()" *ngIf="schema.type !== 'Singleton'">
<i class="icon-angle-left"></i>
</a>
<ng-container *ngIf="content; noContentTitle">
<sqx-title message="i18n:contents.editPageTitle"></sqx-title>
</ng-container>
<ng-container *ngIf="content; else noContentTitle">
<sqx-title message="i18n:contents.editPageTitle"></sqx-title>
</ng-container>
<ng-template #noContentTitle>
{{ 'contents.createTitle' | sqxTranslate }}
<ng-template #noContentTitle>
<h3>{{ 'contents.createTitle' | sqxTranslate }}</h3>
<sqx-title message="i18n:contents.createPageTitle"></sqx-title>
</ng-template>
<sqx-title message="i18n:contents.createPageTitle"></sqx-title>
</ng-template>
</div>
</ng-container>
<ng-container menu>

2
frontend/app/features/content/pages/contents/contents-page.component.html

@ -2,7 +2,7 @@
<sqx-layout layout="main" titleText="i18n:common.contents" titleIcon="contents">
<ng-container menu>
<div class="row flex-nowrap gx-2">
<div class="row flex-nowrap flex-grow-1 gx-2">
<div class="col-auto ms-8">
<sqx-notifo topic="apps/{{contentsState.appId}}/schemas/{{schema?.id}}/contents"></sqx-notifo>

Loading…
Cancel
Save