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); }
public static JsonProperty CreateProperty(IField field, JsonSchema4 reference) { var jsonProperty = Builder.ObjectProperty(reference); if (!string.IsNullOrWhiteSpace(field.RawProperties.Hints)) { jsonProperty.Description = $"{field.Name} ({field.RawProperties.Hints})"; } else { jsonProperty.Description = field.Name; } jsonProperty.IsRequired = field.RawProperties.IsRequired; return(jsonProperty); }
public JsonSchemaProperty?Visit(IField <GeolocationFieldProperties> field) { var geolocationSchema = Builder.Object(); geolocationSchema.Properties.Add("latitude", new JsonSchemaProperty { Type = JsonObjectType.Number, Minimum = -90, Maximum = 90, IsRequired = true }); geolocationSchema.Properties.Add("longitude", new JsonSchemaProperty { Type = JsonObjectType.Number, Minimum = -180, Maximum = 180, IsRequired = true }); var reference = schemaResolver("GeolocationDto", geolocationSchema); return(Builder.ObjectProperty(reference)); }