// ========================================================================== // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex UG (haftungsbeschränkt) // All rights reserved. Licensed under the MIT license. // ========================================================================== using System; using System.Collections.ObjectModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Runtime.Serialization; using Newtonsoft.Json; using Squidex.Domain.Apps.Core.Schemas; using Squidex.Web.Json; namespace Squidex.Areas.Api.Controllers.Schemas.Models { [JsonConverter(typeof(TypedJsonInheritanceConverter), "fieldType")] [KnownType(nameof(Subtypes))] public abstract class FieldPropertiesDto { /// /// Optional label for the editor. /// [StringLength(100)] public string? Label { get; set; } /// /// Hints to describe the schema. /// [StringLength(1000)] public string? Hints { get; set; } /// /// Placeholder to show when no value has been entered. /// [StringLength(100)] public string? Placeholder { get; set; } /// /// Indicates if the field is required. /// public bool IsRequired { get; set; } /// /// Optional url to the editor. /// public string? EditorUrl { get; set; } /// /// Tags for automation processes. /// [Required] public ReadOnlyCollection Tags { get; set; } public abstract FieldProperties ToProperties(); public static Type[] Subtypes() { var type = typeof(FieldPropertiesDto); return type.Assembly.GetTypes().Where(type.IsAssignableFrom).ToArray(); } } }