Ejemplo n.º 1
0
        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"]             = SchemaBuilder.GuidProperty($"The id of the {schemaName} content.",                                         true),
                    ["data"]           = SchemaBuilder.ObjectProperty(dataSchema,                                                                   $"The data of the {schemaName}.",       true),
                    ["dataDraft"]      = SchemaBuilder.ObjectProperty(dataSchema,                                                                   $"The draft data of the {schemaName}."),
                    ["version"]        = SchemaBuilder.NumberProperty($"The version of the {schemaName}.",                                          true),
                    ["created"]        = SchemaBuilder.DateTimeProperty($"The date and time when the {schemaName} content has been created.",       true),
                    ["createdBy"]      = SchemaBuilder.StringProperty($"The user that has created the {schemaName} content.",                       true),
                    ["lastModified"]   = SchemaBuilder.DateTimeProperty($"The date and time when the {schemaName} content has been modified last.", true),
                    ["lastModifiedBy"] = SchemaBuilder.StringProperty($"The user that has updated the {schemaName} content last.",                  true),
                    ["status"]         = SchemaBuilder.StringProperty($"The status of the content.",                                                true)
                },
                Type = JsonObjectType.Object
            };

            return(contentSchema);
        }
Ejemplo n.º 2
0
        public static JsonSchema BuildSchema(string name, JsonSchema?dataSchema, bool extended = false)
        {
            var jsonSchema = new JsonSchema
            {
                Properties =
                {
                    ["id"]             = SchemaBuilder.StringProperty($"The id of the {name} content.",                                       true),
                    ["created"]        = SchemaBuilder.DateTimeProperty($"The date and time when the {name} content has been created.",       true),
                    ["createdBy"]      = SchemaBuilder.StringProperty($"The user that has created the {name} content.",                       true),
                    ["lastModified"]   = SchemaBuilder.DateTimeProperty($"The date and time when the {name} content has been modified last.", true),
                    ["lastModifiedBy"] = SchemaBuilder.StringProperty($"The user that has updated the {name} content last.",                  true),
                    ["newStatus"]      = SchemaBuilder.StringProperty("The new status of the content."),
                    ["status"]         = SchemaBuilder.StringProperty("The status of the content.",                                           true),
                },
                Type = JsonObjectType.Object
            };

            if (extended)
            {
                jsonSchema.Properties["newStatusColor"] = SchemaBuilder.StringProperty("The color of the new status.", false);
                jsonSchema.Properties["schema"]         = SchemaBuilder.StringProperty("The name of the schema.", true);
                jsonSchema.Properties["SchemaName"]     = SchemaBuilder.StringProperty("The display name of the schema.", true);
                jsonSchema.Properties["statusColor"]    = SchemaBuilder.StringProperty("The color of the status.", true);
            }

            if (dataSchema != null)
            {
                jsonSchema.Properties["data"]      = SchemaBuilder.ObjectProperty(dataSchema, $"The data of the {name}.", true);
                jsonSchema.Properties["dataDraft"] = SchemaBuilder.ObjectProperty(dataSchema, $"The draft data of the {name}.");
            }

            return(jsonSchema);
        }
Ejemplo n.º 3
0
 public JsonSchemaProperty?Visit(IField <DateTimeFieldProperties> field, Args args)
 {
     return(SchemaBuilder.DateTimeProperty());
 }