Benzene.JsonSchema 0.0.3-alpha.3

This is a prerelease version of Benzene.JsonSchema.
dotnet add package Benzene.JsonSchema --version 0.0.3-alpha.3
                    
NuGet\Install-Package Benzene.JsonSchema -Version 0.0.3-alpha.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Benzene.JsonSchema" Version="0.0.3-alpha.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Benzene.JsonSchema" Version="0.0.3-alpha.3" />
                    
Directory.Packages.props
<PackageReference Include="Benzene.JsonSchema" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Benzene.JsonSchema --version 0.0.3-alpha.3
                    
#r "nuget: Benzene.JsonSchema, 0.0.3-alpha.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Benzene.JsonSchema@0.0.3-alpha.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Benzene.JsonSchema&version=0.0.3-alpha.3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Benzene.JsonSchema&version=0.0.3-alpha.3&prerelease
                    
Install as a Cake Tool

JSON Schema Validation

JSON Schema is the standard, language-neutral way to describe and validate the shape of JSON documents. Validating with JSON Schema means the contract is the validator: the same schema document that describes a payload in your spec can reject non-conforming payloads at the door — with no C# validator classes to write, and no way for the two to drift apart.

Integration with Benzene

JSON Schema validation runs as pipeline middleware over the raw request body, before deserialization — the natural place for a document validator (it checks the wire JSON itself, so it also catches malformed or missing bodies).

For each message it obtains a schema for the current topic and evaluates the body against it. A failing body short-circuits with a ValidationError result whose payload is an array of property-scoped messages — the same failure contract as Benzene.FluentValidation and Benzene.DataAnnotations:

["/name: Value is longer than 5 characters", "/lines/0/sku: Required properties [\"sku\"] are not present"]

A null schema for a topic means "no validation" and the message passes through.

.UseJsonSchema()
.UseMessageHandlers()

Where schemas come from

  • Generated (default): DefaultJsonSchemaProvider derives a schema from the registered handler's request type (JsonSchema.Net.Generation, draft 2020-12, camelCase).
  • Bring your own: register hand-authored schema documents per request type — the same documents you can serve from the spec via Benzene.Schema.OpenApi's SuppliedSchemaCatalog, so published contract and runtime validation stay aligned:
var schemas = new SuppliedJsonSchemaCatalog()
    .AddJson(typeof(CreateOrderMessage), File.ReadAllText("schemas/create-order.json"));

services.UsingBenzene(x => x.AddSuppliedJsonSchemas(schemas));
  • Fully custom: implement IJsonSchemaProvider<TContext> to source schemas from anywhere (a registry service, embedded resources, per-tenant stores).
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.3-alpha.3 54 8/19/2026
0.0.3-alpha.2 51 8/19/2026
0.0.3-alpha.1 50 8/19/2026
0.0.2.18-alpha 58 7/14/2026
0.0.2.17-alpha 55 7/13/2026
0.0.2.16-alpha 55 7/11/2026
0.0.2.15-alpha 144 2/7/2025
0.0.2.14-alpha 136 2/7/2025
0.0.2.13-alpha 126 2/6/2025
0.0.2.12-alpha 129 12/19/2024
0.0.2-alpha.6 48 8/13/2026
0.0.2-alpha.5 52 8/13/2026
0.0.2-alpha.4 62 8/10/2026
0.0.2-alpha.3 48 8/10/2026
0.0.2-alpha.2 50 7/23/2026
0.0.2-alpha.1 60 7/23/2026