Skip to content

API Contracts

AI-ready schemas from your .NET assemblies — built for agents, tooling, and documentation.

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.

  1. Install the source generator NuGet package

    YourProject.csproj
    <PackageReference Include="ApiContracts.Generator"
    OutputItemType="Analyzer"
    ReferenceOutputAssembly="false" />
  2. Annotate your types (optional — all public types are captured automatically)

    InternalHelper.cs
    // All public types are included implicitly.
    // Use [ApiContract(Ignore = true)] to exclude a type:
    [ApiContract(Ignore = true)]
    public class InternalHelper { }
  3. Build — the generator walks all public types, extracts XML docs, models JSON serialization, and emits deterministic data files

    Terminal window
    dotnet build
  4. Consume the schema in documentation, AI agents, or tooling

    Usage.cs
    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.

Type schema
{
"name": "Customer",
"fullName": "SampleApi.Customer",
"kind": "class",
"members": [
{
"name": "FullName",
"kind": "property",
"returnType": "string",
"signature": "string Customer.FullName"
}
]
}