talira

NJsonSchema

Read, generate and validate JSON Schema in .NET, and generate C# and TypeScript from it

open sourceMITfree

NJsonSchema is a .NET library by Rico Suter that reads, generates and validates JSON Schema (draft 4 and later). It validates JSON data against a schema, generates a schema from a .NET type through reflection or from sample JSON, resolves $ref references (relative, URL and file), and generates C# and TypeScript classes or interfaces from a schema. It uses Json.NET for JSON, targets .NET Standard 2.0, handles Swagger and OpenAPI DTO schemas, and is the schema engine behind NSwag.

Problems it solves

  • validate incoming JSON against a JSON Schema in my C# service
  • generate a JSON Schema from my .NET classes
  • generate C# or TypeScript classes from a JSON Schema file

Features

  • validate JSON data against a JSON Schema
  • generate a schema from a .NET type or sample JSON
  • $ref resolution (relative, URL and file)
  • C# and TypeScript code generation from a schema
  • YAML schemas through NJsonSchema.Yaml