· Engineering notes
Lint OpenAPI before you write contract tests
Broken or ambiguous specs waste Pact/Schemathesis time. Run a lint pass, fix types and security schemes, then lock consumer or provider tests. Use the free Lab linter as the first gate.
Why lint comes first
- Contract tests encode whatever the spec claims. If
amountis typed wrong, you automate the bug (see sample report Medium contract row). - Missing
securitySchemesmeans "anonymous" looks intentional in generated tests. - Duplicate operationIds and dead refs break generators before CI asserts behaviour.
Tool: OpenAPI linter. Comparison of contract styles: Pact vs OpenAPI.
Artifact: lint → test order
## OpenAPI gate before contract work
[ ] Spec loads (OpenAPI 3.x) without $ref errors
[ ] Lab linter / Spectral (or equivalent) zero error-level rules
[ ] Paths used by this release have request/response schemas (not empty)
[ ] amount / money fields: number (or documented string+format) consistent with code
[ ] securitySchemes match how staging actually authenticates
[ ] Then: Schemathesis or Pact job on the PR
Block contract-test authoring until error-level lint is clean? Yes / waiver owner: ____
Minimal CI shape
# Example job step - adapt to your runner
- name: Lint OpenAPI
run: npx --yes @stoplight/spectral-cli lint openapi.yaml -F error
# Keep Lab linter for humans on a PR comment; CI needs a non-interactive binary
After lint is green, negative authz cases still need human design (BOLA). Lint will not invent tenant checks.
API engagements that leave suites in your repo: API testing.
If you want a written gap list on your spec before contract tests start, book a free 20-min test audit.