Skip to content

Quick Start

<ItemGroup>
<PackageReference Include="ApiContracts.Abstractions" />
<PackageReference Include="ApiContracts.Generator"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false" />
</ItemGroup>

All public types are included automatically. Use [ApiContract(Ignore = true)] to exclude specific types or members:

using ApiContracts;
// All public types are emitted to the data file.
// To exclude a type:
[ApiContract(Ignore = true)]
public class InternalHelper { }
Terminal window
dotnet build

The generator automatically walks all public types and members, extracts XML documentation, models System.Text.Json serialization behavior, computes a deterministic apiHash, and emits schema as embedded source.

using ApiContracts.Generated;
var json = EmbeddedSchemas.MyAssemblySchema;
using ApiContracts.Verification;
var result = SchemaVerifier.ValidateSchema(json);
Console.WriteLine($"Valid: {result.IsValid}, Hash: {result.ApiHash}");