Click or drag to resize
Json.NET Schema

Generate with Descriptions

 

This sample generates a new JSchema from a .NET type with Description attributes.

Sample
Types
[DisplayName("Postal Address")]
[Description("The mailing address.")]
public class PostalAddress
{
    [DisplayName("Street Address")]
    [Description("The street address. For example, 1600 Amphitheatre Pkwy.")]
    public string StreetAddress { get; set; }

    [DisplayName("Locality")]
    [Description("The locality. For example, Mountain View.")]
    public string AddressLocality { get; set; }

    [DisplayName("Region")]
    [Description("The region. For example, CA.")]
    public string AddressRegion { get; set; }

    [DisplayName("Country")]
    [Description("The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code.")]
    public string AddressCountry { get; set; }

    [DisplayName("Postal Code")]
    [Description("The postal code. For example, 94043.")]
    public string PostalCode { get; set; }
}
Usage
JSchemaGenerator generator = new JSchemaGenerator();
generator.DefaultRequired = Required.DisallowNull;

JSchema schema = generator.Generate(typeof(PostalAddress));
// {
//   "title": "Postal Address",
//   "description": "The mailing address.",
//   "type": "object",
//   "properties": {
//     "StreetAddress": {
//       "title": "Street Address",
//       "description": "The street address. For example, 1600 Amphitheatre Pkwy.",
//       "type": "string"
//     },
//     "AddressLocality": {
//       "title": "Locality",
//       "description": "The locality. For example, Mountain View.",
//       "type": "string"
//     },
//     "AddressRegion": {
//       "title": "Region",
//       "description": "The region. For example, CA.",
//       "type": "string"
//     },
//     "AddressCountry": {
//       "title": "Country",
//       "description": "The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code.",
//       "type": "string"
//     },
//     "PostalCode": {
//       "title": "Postal Code",
//       "description": "The postal code. For example, 94043.",
//       "type": "string"
//     }
//   }
// }