OSS-first docs

These docs teach the open system first: contracts, generated surfaces, runtimes, governance, and incremental adoption. Studio shows up as the operating layer on top, not as the source of truth.

Contract-first API

Design APIs by writing contracts first, then generate consistent implementations across frameworks.

Problems Solved

  • API drift between frontend and backend
  • Inconsistent error handling across endpoints
  • Documentation becomes outdated quickly
  • Manual OpenAPI maintenance is error-prone

Solutions

  • Single source of truth for API contracts
  • Generate OpenAPI and SDKs from contracts
  • Type-safe request/response validation
  • Always-in-sync documentation

Quick Start

Define your first API contract and generate consistent implementations.

src/contracts/user-create.operation.ts
import { defineOperation } from '@contractspec/lib.contracts-spec/operations';
import { SchemaModel, ScalarTypeEnum } from '@contractspec/lib.schema';

export const CreateUserOperation = defineOperation({
  goal: 'Create a new user account with validation',
  context: 'Used by frontend registration forms and internal admin tools',
  input: new SchemaModel({
    type: 'object',
    properties: {
      email: {
        type: 'string',
        format: 'email',
        required: true,
      },
      password: {
        type: 'string',
        minLength: 8,
        required: true,
      },
    },
  }),
  output: new SchemaModel({
    type: 'object',
    properties: {
      id: { type: 'string', required: true },
      email: { type: 'string', required: true },
      createdAt: { type: 'string', format: 'date-time', required: true },
    },
  }),
  metadata: {
    name: 'createUser',
    tags: ['users', 'auth'],
    description: 'Create a new user account with email and password',
  },
});

Generate OpenAPI

Export OpenAPI documentation directly from your contracts.

export-openapi
contractspec openapi export \
  --registry ./src/contracts/registry.ts \
  --out ./openapi.json
OSS docsStart with OSS. Adopt Studio when you want the operating layer.

Why ContractSpec

Keep educational and comparison content reachable without letting it define the primary OSS learning path.