using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.CodeDom.Compiler;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Schema;
using Newtonsoft.Json.Schema.Generation;
public Basics Basics { get; set; }
public Work[] Work { get; set; }
public Volunteer[] Volunteer { get; set; }
public Education[] Education { get; set; }
public Award[] Awards { get; set; }
public Publication[] Publications { get; set; }
public Skill[] Skills { get; set; }
public Language[] Languages { get; set; }
public Interest[] Interests { get; set; }
public Reference[] References { get; set; }
public string Title { get; set; }
public string Date { get; set; }
public string Awarder { get; set; }
public string Summary { get; set; }
public string Name { get; set; }
public string Label { get; set; }
public Uri Picture { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string Website { get; set; }
public string Summary { get; set; }
public Location Location { get; set; }
public Profile[] Profiles { get; set; }
public string Institution { get; set; }
public string Area { get; set; }
public string StudyType { get; set; }
public string StartDate { get; set; }
public string EndDate { get; set; }
public string Gpa { get; set; }
public string[] Courses { get; set; }
public string Name { get; set; }
public string[] Keywords { get; set; }
public string language { get; set; }
public string Fluency { get; set; }
public string Address { get; set; }
public string PostalCode { get; set; }
public string City { get; set; }
public string CountryCode { get; set; }
public string Region { get; set; }
public string Network { get; set; }
public string Username { get; set; }
public string Url { get; set; }
public string Name { get; set; }
public string Publisher { get; set; }
public string ReleaseDate { get; set; }
public string Website { get; set; }
public string Summary { get; set; }
public string Name { get; set; }
public string reference { get; set; }
[JsonProperty(Required = Required.Always)]
public string RequiredByProperty { get; set; }
public string Name { get; set; }
public string Level { get; set; }
public string[] Keywords { get; set; }
public string Organization { get; set; }
public string Position { get; set; }
public string Website { get; set; }
public string StartDate { get; set; }
public string EndDate { get; set; }
public string Summary { get; set; }
public string[] Highlights { get; set; }
public string Company { get; set; }
public string Position { get; set; }
public string Website { get; set; }
public string StartDate { get; set; }
public string EndDate { get; set; }
public string Summary { get; set; }
public string[] Highlights { get; set; }
public static void Test()
public static void Test(Type type)
Console.WriteLine("\nGenerating a schema for {0} with {1}.{2} = {3}.{4}:", type,
nameof(JSchemaGenerator), nameof(JSchemaGenerator.DefaultRequired),
nameof(Required), Required.Default);
var schema1 = GenerateSchema(type, Required.Default);
Console.WriteLine(schema1);
var schema2 = GenerateSchema(type, null);
Console.WriteLine("And without setting {0}.{1}:",
nameof(JSchemaGenerator), nameof(JSchemaGenerator.DefaultRequired));
Console.WriteLine(schema2);
public static string GenerateSchema(Type type, Required? defaultRequired = null)
var generator = new JSchemaGenerator
ContractResolver = new CamelCasePropertyNamesContractResolver(),
SchemaIdGenerationHandling = SchemaIdGenerationHandling.TypeName,
if (defaultRequired != null)
generator.DefaultRequired = defaultRequired.Value;
var schema = generator.Generate(type);
var sb = new StringBuilder();
schema.WriteTo(new JsonTextWriter(
Formatting = Formatting.Indented,
IndentChar = ' ', Indentation = 2,
}, new JSchemaWriterSettings
Version = SchemaVersion.Draft7
public static void Main()
Console.WriteLine("Environment version: {0} ({1})", System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription , GetNetCoreVersion());
Console.WriteLine("Json.NET version: " + typeof(JsonSerializer).Assembly.FullName);
Console.WriteLine("Json.NET Schema version: " + typeof(Newtonsoft.Json.Schema.JSchema).Assembly.FullName);
Console.WriteLine("Failed with unhandled exception: ");
public static string GetNetCoreVersion()
var assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly;
var assemblyPath = assembly.CodeBase.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2)
return assemblyPath[netCoreAppIndex + 1];