FSharp.Data.JsonSchema

Provides an opinionated, idiomatic JSON serializer and JSON Schema definition generation for F# types using FSharp.SystemTextJson and NJsonSchema.

Build status

Build History

NuGet Badge

Why JSON Schema?

JSON Schema is a standard, evolving format for specifying the structure of JSON documents. JSON Schema is used in Open API and can be used by clients to validate that the payload received or to be sent matches the expected schema. Use of these documents can allow for a more nuanced approach to versioning APIs, as well.

Tools exist for generating nicely formatted JSON from F#, e.g. FSharpLu.Json, Newtonsoft.Json.FSharp, Newtonsoft.Json.FSharp.Idiomatic, and FSharp.SystemTextJson.

Newtonsoft.Json Schema and NJsonSchema provide a way to generate and validate JSON Schema for .NET languages, but these don't necessarily translate well to F# types, e.g. anyOf mapping to F#'s discriminated unions. This library strives to fill this gap.