public JsonSchema CreateContentSchema(Schema schema, JsonSchema dataSchema)
        {
            Guard.NotNull(schema, nameof(schema));
            Guard.NotNull(dataSchema, nameof(dataSchema));

            var schemaName = schema.Properties.Label.WithFallback(schema.Name);

            var contentSchema = new JsonSchema
            {
                Properties =
                {
                    ["id"]             = Builder.GuidProperty($"The id of the {schemaName} content.",                                         true),
                    ["data"]           = Builder.ObjectProperty(dataSchema,                                                                   $"The data of the {schemaName}.",      true),
                    ["dataDraft"]      = Builder.ObjectProperty(dataSchema,                                                                   $"The draft data of the {schemaName}.",false),
                    ["version"]        = Builder.NumberProperty($"The version of the {schemaName}.",                                          true),
                    ["created"]        = Builder.DateTimeProperty($"The date and time when the {schemaName} content has been created.",       true),
                    ["createdBy"]      = Builder.StringProperty($"The user that has created the {schemaName} content.",                       true),
                    ["lastModified"]   = Builder.DateTimeProperty($"The date and time when the {schemaName} content has been modified last.", true),
                    ["lastModifiedBy"] = Builder.StringProperty($"The user that has updated the {schemaName} content last.",                  true),
                    ["status"]         = Builder.StringProperty($"The status of the content.",                                                true)
                },
                Type = JsonObjectType.Object
            };

            return(contentSchema);
        }
Example #2
0
        public JsonSchemaProperty?Visit(IField <StringFieldProperties> field)
        {
            var property = Builder.StringProperty();

            property.MinLength = field.Properties.MinLength;
            property.MaxLength = field.Properties.MaxLength;

            if (field.Properties.AllowedValues != null)
            {
                var names = property.EnumerationNames ??= new Collection <string>();

                foreach (var value in field.Properties.AllowedValues)
                {
                    names.Add(value);
                }
            }

            return(property);
        }
Example #3
0
 public JsonProperty Visit(IField <JsonFieldProperties> field)
 {
     return(Builder.StringProperty());
 }