Skip to content

Latest commit

 

History

History
72 lines (47 loc) · 2.73 KB

README.md

File metadata and controls

72 lines (47 loc) · 2.73 KB

JsonSchemaProvider: F# type provider for JSON schema

NuGet Badge GitHub Actions

The JsonSchemaProvider provides F# types from JSON schemas. It can be used to build JSON values in a strongly typed way that conform to the schema or to parse JSON values into an F# value that can be queried in a strongly typed way. Specifications like numeric ranges or string patterns that cannot be validated at compile time are checked at runtime.

The JSON schema can either be given as an inline string literal or by a local file.

The type provider is built around NJsonSchema for the schema parsing and validation and uses the JsonValue data type from FSharp.Data.

The version history is kept in the changelog.

See the documentation for instructions and examples how to use the type provider.

Building

The type provider requires the .NET SDK 8 or higher.

The code comes with a Dev Container specification that sets up the necessary tools and the .NET SDK.

When not inside the Dev Container, issue a

dotnet tool restore

to install the .NET tools listed in dotnet-tools.json.

The code is built using FAKE as follows.

On Linux/macOS:

./build.sh

On Windows:

build.cmd

The FAKE build script is based on MiniScaffold and provides most of its build targets. The list of available targets can be obtained by

./build.sh ListTargets

Environment Variables

  • CONFIGURATION will set the configuration of the dotnet commands. If not set, it will default to Release.
    • CONFIGURATION=Debug ./build.sh will result in -c additions to commands such as in dotnet build -c Debug

Debugging

Debugging type providers requires to run the FSharp compiler or interpreter on a source file using the type provider since the provider's code is executed in the compilation pipeline. See the comments in debugUtils/debug.fsx how to launch the code in the Ionide debugger.

License

The JSON schema type provider is available under the MIT license. For more information see license file.