mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.5 KiB
85 lines
2.5 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using NodaTime;
|
|
using Squidex.Domain.Apps.Entities.Schemas;
|
|
using Squidex.Infrastructure;
|
|
using Squidex.Infrastructure.Reflection;
|
|
|
|
namespace Squidex.Areas.Api.Controllers.Schemas.Models
|
|
{
|
|
public sealed class SchemaDto
|
|
{
|
|
/// <summary>
|
|
/// The id of the schema.
|
|
/// </summary>
|
|
public Guid Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// The name of the schema. Unique within the app.
|
|
/// </summary>
|
|
[Required]
|
|
[RegularExpression("^[a-z0-9]+(\\-[a-z0-9]+)*$")]
|
|
public string Name { get; set; }
|
|
|
|
/// <summary>
|
|
/// The name of the category.
|
|
/// </summary>
|
|
public string Category { get; set; }
|
|
|
|
/// <summary>
|
|
/// The schema properties.
|
|
/// </summary>
|
|
[Required]
|
|
public SchemaPropertiesDto Properties { get; set; }
|
|
|
|
/// <summary>
|
|
/// Indicates if the schema is published.
|
|
/// </summary>
|
|
public bool IsPublished { get; set; }
|
|
|
|
/// <summary>
|
|
/// The user that has created the schema.
|
|
/// </summary>
|
|
[Required]
|
|
public RefToken CreatedBy { get; set; }
|
|
|
|
/// <summary>
|
|
/// The user that has updated the schema.
|
|
/// </summary>
|
|
[Required]
|
|
public RefToken LastModifiedBy { get; set; }
|
|
|
|
/// <summary>
|
|
/// The date and time when the schema has been created.
|
|
/// </summary>
|
|
public Instant Created { get; set; }
|
|
|
|
/// <summary>
|
|
/// The date and time when the schema has been modified last.
|
|
/// </summary>
|
|
public Instant LastModified { get; set; }
|
|
|
|
/// <summary>
|
|
/// The version of the schema.
|
|
/// </summary>
|
|
public int Version { get; set; }
|
|
|
|
public static SchemaDto FromSchema(ISchemaEntity schema)
|
|
{
|
|
var response = new SchemaDto { Properties = new SchemaPropertiesDto() };
|
|
|
|
SimpleMapper.Map(schema, response);
|
|
SimpleMapper.Map(schema.SchemaDef, response);
|
|
SimpleMapper.Map(schema.SchemaDef.Properties, response.Properties);
|
|
|
|
return response;
|
|
}
|
|
}
|
|
}
|
|
|