Deterministic Hashing
Every build produces the same schema for the same API surface. Detect changes instantly via apiHash (SHA-256) — no more silent breaking changes.
Deterministic Hashing
Every build produces the same schema for the same API surface. Detect changes instantly via apiHash (SHA-256) — no more silent breaking changes.
AI-Ready Metadata
All public types are captured automatically with their XML documentation, JSON contracts, and full type signatures. LLMs and agents consume data files natively.
Cryptographic Signatures
Optional RSA-SHA256 signatures ensure schema integrity and provenance. Verify that schemas haven’t been tampered with.
Zero Runtime Cost
Powered by a Roslyn incremental source generator — all schema work happens at compile time. No reflection, no runtime overhead.
Install the source generator NuGet package
<PackageReference Include="ApiContracts.Generator" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />Annotate your types (optional — all public types are captured automatically)
// All public types are included implicitly.// Use [ApiContract(Ignore = true)] to exclude a type:[ApiContract(Ignore = true)]public class InternalHelper { }Build — the generator walks all public types, extracts XML docs, models JSON serialization, and emits deterministic data files
dotnet buildConsume the schema in documentation, AI agents, or tooling
var result = SchemaVerifier.ValidateSchema(schemaJson);Console.WriteLine($"Valid: {result.IsValid}, Hash: {result.ApiHash}");Every public class, struct, record, interface, enum, and delegate — including all public members with full signatures, parameters, return types, and modifiers.
{ "name": "Customer", "fullName": "SampleApi.Customer", "kind": "class", "members": [ { "name": "FullName", "kind": "property", "returnType": "string", "signature": "string Customer.FullName" } ]}All XML documentation is normalized and captured: summaries, remarks, parameter descriptions, return docs, <example> blocks, and <seealso> references.
{ "docs": { "summary": "Service for managing customers.", "remarks": "Provides CRUD operations and search capabilities.", "parameters": { "id": "The customer identifier." }, "returns": "The customer if found; otherwise, null." }}System.Text.Json serialization behavior is captured per type — property names, types, required/nullable/ignored flags, and JSON type mappings.
{ "json": { "contractType": "object", "useCamelCase": true, "properties": [ { "clrName": "FullName", "jsonName": "fullName", "jsonType": "string", "required": true } ] }}