using Newtonsoft.Json.Schema;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
public static void Main()
var fields = new List<ContractRegistrationStatusDto>{
new ContractRegistrationStatusDto { FieldId = 1, FieldName = "EMSControlled", FieldType = "string", EvaluationValue = "Y" },
new ContractRegistrationStatusDto { FieldId = 2, FieldName = "PMNotificationChecked", FieldType = "string", EvaluationValue = "Y" },
new ContractRegistrationStatusDto { FieldId = 3, FieldName = "PMTemplateSelected", FieldType = "string", EvaluationValue = "Y" }
var schema = new JsonSchema
Type = JsonSchemaType.Object,
Properties = new Dictionary<string, JsonSchema>()
foreach (var f in fields) {
var enumValue = new List<JToken>();
enumValue.Add(f.EvaluationValue);
var fieldSchema = new JsonSchema
Type = JsonSchemaType.Any,
Id = f.FieldId.ToString(),
Enum = new List<JToken>()
fieldSchema.Enum.Add(new JValue(f.EvaluationValue));
schema.Properties.Add(f.FieldName, fieldSchema );
Console.WriteLine(schema.ToString());
public class ContractRegistrationStatusDto
public int FieldId { get; set; }
public string FieldName { get; set; }
public string FieldType { get; set; }
public string EvaluationValue { get; set; }