← Docs

Recipe: Codegen with test gating

Generate implementation stubs from OpenAPI specs, then gate merges on passing generated test suites.

Overview

Meridian watches your spec repo. When an OpenAPI document changes, it emits typed client code and a matching test harness. PRs that fail the generated tests are blocked automatically.

Pipeline

  1. Push an OpenAPI spec to specs/
  2. Meridian runs openapi-generator with your template
  3. Generated client lands in src/generated/
  4. Test suite is emitted alongside the client
  5. CI runs tests; failing PRs are blocked

Config

{
  "codegen": {
    "generator": "typescript-axios",
    "template": "templates/client.mustache",
    "output": "src/generated",
    "testGate": true
  }
}

Test gating

When testGate is enabled, Meridian generates a contract test suite that validates every endpoint against the spec. The generated tests are committed alongside the client code. Your CI runs them; Meridian's status check fails the PR if any test breaks.