SHARE
TWEET

Untitled

a guest Oct 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // nuget:Newtonsoft.Json.Schema
  2.  
  3. using System;
  4. using Newtonsoft.Json.Schema;
  5. using Newtonsoft.Json.Schema.Generation;
  6.  
  7. //nuget Newtonsoft.Json.Schema v2.0.8
  8.  
  9. public class Program
  10. {
  11.     public static void Main()
  12.     {
  13.         Test1();
  14.     }
  15.    
  16.     static void Test1()
  17.     {
  18.         var jsonSchemaGenerator = new JSchemaGenerator();
  19.         jsonSchemaGenerator.GenerationProviders.Add(new StringEnumGenerationProvider());
  20.         var myType = typeof(Person);
  21.         var schema = jsonSchemaGenerator.Generate(myType);
  22.         schema.Title = myType.Name;
  23.         Console.WriteLine(schema);
  24.  
  25.     }
  26. }
  27.  
  28. class Person
  29. {
  30.     public int id       {get;set;}
  31.     public string name  {get;set;}
  32.     public DayOfWeek DoW {get;set;}
  33.    
  34. }
  35. /*
  36. Memory: ~ 390 kb
  37. CPU:    0.766s
  38.  
  39. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top