CSharp · Console
using Newtonsoft.Json;
using Newtonsoft.Json.Schema;
using Newtonsoft.Json.Schema.Generation;
using System.ComponentModel;
using System;
public class Program
{
public static void Main()
{
JSchemaGenerator generator = new JSchemaGenerator();
//generator.SchemaReferenceHandling = SchemaReferenceHandling.None;
generator.DefaultRequired = Required.DisallowNull;
JSchema schema = generator.Generate(typeof(MotionConfigSchema));
Console.WriteLine(schema.ToString());
}
}
public class Channel
{
public string DataPath { get; private set; }
public float Gain { get; private set; } = 1.0f;
}
[Description("Motion Configuration file fields description.")]
public class MotionConfigSchema
{
[Description("Yaw in °/sec")]
public Channel? Yaw {get; set;}
[Description("Roll in °")]
public Channel? Roll {get; set;}
}