Skip to content

SampleApi Schema

The SampleApi project demonstrates every major feature of the API Contracts generator. The full data file is available as JSON for consumption by AI agents, documentation pipelines, and automated tooling.

The generated schema contains 23 public types spanning classes, structs, records, interfaces, enums, and more:

TypeKindMembersSummary
Addressrecord6Represents a physical or mailing address.
ApiEndpointsclass8Provides well-known route path constants for the sample API.
ApiResponse<T>class6A generic envelope for API responses containing a data payload and metadata.
AuditableEntityclass5Base class for entities that require audit tracking.
ContactMethodenum0Available contact methods for a customer.
Customerclass7Represents a customer in the system.
DateRangestruct12Represents an inclusive date range with a start and end date.
FeatureFlagsenum0Feature flags that can be independently enabled for the application.
ICustomerServiceinterface5Service for managing customers.
IOrderNotificationServiceinterface7A service that publishes notifications for key order lifecycle events.
IRepository<TEntity>interface8A generic repository interface for performing CRUD and query operations.
Moneyrecord struct6Represents a monetary amount in a specific currency.
Orderclass6Represents an order placed by a customer.
OrderEventArgsclass3Provides data for order-related events.
OrderItemclass3Represents a single item within an order.
OrderStatusenum0The status of an order.
PagedResult<T>record8Represents a paged subset of a larger collection.
ProblemDetailsclass6A machine-readable format for specifying errors in HTTP API responses (RFC 9457).
ProductDtoclass10A DTO annotated with System.Text.Json serialization attributes.
RateLimitOptionsclass3Configuration options for API rate limiting.
Result<T>class6Encapsulates the outcome of an operation with a success value or an error message.
SoftDeletableEntityclass5Base class for entities that support soft deletion with audit tracking.
ValidationErrorrecord4Describes a validation error associated with a specific input field.

Classes with properties, required members, and XML documentation:

Customer.cs
/// <summary>
/// Represents a customer in the system.
/// </summary>
public class Customer
{
/// <summary>Gets or sets the unique identifier.</summary>
public required Guid Id { get; set; }
/// <summary>Gets or sets the customer's full name.</summary>
public required string FullName { get; set; }
/// <summary>Gets or sets the email address.</summary>
public string? Email { get; set; }
}

Every generated schema includes a versioned envelope with package metadata and a deterministic API hash:

Schema envelope
{
"$schema": "/api.contracts/schemas/api-schema.json",
"schemaVersion": "1.0.0",
"package": {
"name": "SampleApi",
"version": "1.0.0.0",
"targetFramework": "net10.0"
},
"types": [ ... ],
"apiHash": "sha256:d5dbe44a66cf9c54a107f58ca8e8c8a84cffa81ed7dc03d34547f4d3e9f709f4"
}

Here’s what the Customer type looks like in the generated schema:

Customer type in schema
{
"name": "Customer",
"fullName": "SampleApi.Customer",
"namespace": "SampleApi",
"kind": "class",
"accessibility": "public",
"docs": {
"summary": "Represents a customer in the system.",
"remarks": "This is a sample domain model demonstrating the API Contracts generator. It shows how types, properties, and methods are captured in the schema."
},
"members": [
{
"name": "CreatedAt",
"kind": "property",
"accessibility": "public",
"signature": "DateTimeOffset Customer.CreatedAt",
"returnType": "System.DateTimeOffset",
"docs": { "summary": "Gets or sets the date when the customer was created." }
},
{
"name": "Email",
"kind": "property",
"accessibility": "public",
"signature": "string? Customer.Email",
"returnType": "string?",
33 collapsed lines
"isReturnNullable": true,
"docs": { "summary": "Gets or sets the email address." }
},
{
"name": "FullName",
"kind": "property",
"accessibility": "public",
"signature": "string Customer.FullName",
"returnType": "string",
"docs": { "summary": "Gets or sets the customer's full name." }
},
{
"name": "Id",
"kind": "property",
"accessibility": "public",
"signature": "Guid Customer.Id",
"returnType": "System.Guid",
"docs": { "summary": "Gets or sets the unique identifier." }
},
{
"name": "IsActive",
"kind": "property",
"accessibility": "public",
"signature": "bool Customer.IsActive",
"returnType": "bool",
"docs": { "summary": "Gets or sets whether the customer is active." }
},
{
"name": "PreferredContact",
"kind": "property",
"accessibility": "public",
"signature": "ContactMethod Customer.PreferredContact",
"returnType": "SampleApi.ContactMethod",
"docs": { "summary": "Gets or sets the customer's preferred contact method." }
},
{
"name": "Tags",
"kind": "property",
"accessibility": "public",
"signature": "List<string> Customer.Tags",
"returnType": "System.Collections.Generic.List<string>",
"docs": { "summary": "Gets or sets the customer's tags for segmentation." }
}
]
}

The complete schema JSON for the SampleApi project is published at:

/api.contracts/schemas/SampleApi.api-schema.json

Consumers — including AI agents, SDK generators, and documentation pipelines — can reference this URL directly to discover the full API surface.