|
1 | | -# JsonSchemaProvider |
| 1 | +# JsonSchemaProvider: F# type provider for JSON schema |
| 2 | + |
| 3 | +[](https://www.nuget.org/packages/JsonSchemaProvider/) |
| 4 | +[](https://github.com/florenzen/JsonSchemaProvider/actions/workflows/main.yml?branch=main) |
| 5 | + |
| 6 | +The JsonSchemaProvider provides F# types from [JSON schemas](https://json-schema.org). It can be used to build |
| 7 | +JSON values in a strongly typed way that conform to the schema or to parse JSON values into an F# value that |
| 8 | +can be queried in a stringly types way. Specifications like numeric ranges or string patterns that cannot be |
| 9 | +validated at compile time are checked at runtime. |
| 10 | + |
| 11 | +The JSON schema can either be given as an inline string literal or by a local file. |
| 12 | + |
| 13 | +The type provider is built around [NJsonSchema](http://njsonschema.org/) for the schema parsing and validation |
| 14 | +and uses the `JsonValue` data type from [FSharp.Data](https://fsprojects.github.io/FSharp.Data/). |
| 15 | + |
| 16 | +The version history is kept in the [changelog](CHANGELOG.md). |
| 17 | + |
| 18 | +## Building |
| 19 | + |
| 20 | +The type provider requires the .NET SDK 7 or higher. |
| 21 | + |
| 22 | +The code comes with a [Dev Container specification](.devcontainer/devcontainer.json) that sets up the necessary |
| 23 | +tools and the .NET SDK. |
| 24 | + |
| 25 | +When not inside the Dev Container, issue a |
| 26 | + |
| 27 | +```bash |
| 28 | +dotnet tool restore |
| 29 | +``` |
| 30 | + |
| 31 | +to install the .NET tools listed in [dotnet-tools.json](.config/dotnet-tools.json). |
| 32 | + |
| 33 | +The code is built using [FAKE](https://fake.build) as follows. |
| 34 | + |
| 35 | +On Linux/macOS: |
| 36 | + |
| 37 | +```bash |
| 38 | +./build.sh |
| 39 | +``` |
| 40 | + |
| 41 | +On Windows: |
| 42 | + |
| 43 | +```powershell |
| 44 | +build.cmd |
| 45 | +``` |
| 46 | + |
| 47 | +The FAKE build script is based on [MiniScaffold](https://github.com/TheAngryByrd/MiniScaffold) and provides |
| 48 | +most of iyts build targets. The list of available targets can be obtained by |
| 49 | + |
| 50 | +```bash |
| 51 | +./build.sh ListTargets |
| 52 | +``` |
| 53 | + |
| 54 | +### Environment Variables |
| 55 | + |
| 56 | +- `CONFIGURATION` will set the [configuration](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build?tabs=netcore2x#options) of the dotnet commands. |
| 57 | + If not set, it will default to Release. |
| 58 | + - `CONFIGURATION=Debug ./build.sh` will result in `-c` additions to commands such as in `dotnet build -c Debug` |
| 59 | +- `ENABLE_COVERAGE` Will enable running code coverage metrics. AltCover can have |
| 60 | + [severe performance degradation](https://github.com/SteveGilham/altcover/issues/57) so code coverage |
| 61 | + evaluation are disabled by default to speed up the feedback loop. |
| 62 | + - `ENABLE_COVERAGE=1 ./build.sh` will enable code coverage evaluation |
| 63 | + |
| 64 | +## Documentation |
| 65 | + |
| 66 | +_Disclaimer:_ The type provider supports JSON schemas where the root level type is `object`, other JSON types |
| 67 | +are not supported. |
| 68 | + |
| 69 | +## License |
| 70 | + |
| 71 | +The JSON schema type provider is available under the MIT license. For more information see [license file](LICENSE). |
0 commit comments