Skip to main content

Local read-only scanner for Zod/OpenAPI contract drift risks.

Project description

Zod OpenAPI Contract Lint Kit

Local read-only prototype for finding common drift risks between Zod schemas, OpenAPI metadata, route responses, and generated API clients.

Why this exists

Teams often start with Zod as runtime validation and later generate OpenAPI specs/clients. Drift appears when schemas use constructs generators cannot represent cleanly, when route metadata is missing, or when auth/error responses are inconsistent.

This prototype scans TypeScript files and reports review items. It does not execute application code, import project modules, call network APIs, or modify files.

Current v1 checks

  • Zod object schemas exported without nearby OpenAPI metadata (.openapi(...) or .describe(...)).
  • z.any() / z.unknown() in public contracts.
  • z.date() fields that may serialize differently in OpenAPI/client transports.
  • z.record(...) map types that may need additionalProperties review.
  • z.union(...) without a nearby discriminator hint.
  • z.transform(...), .refine(...), .superRefine(...) in public schemas.
  • Route handlers with auth hints but no visible 401 / 403 response docs nearby.
  • Error responses without an obvious schema/envelope reference.

Try locally

python3 scanner.py examples
python3 scanner.py examples --format json
python3 scanner.py examples --output report.md
python3 scanner.py examples --fail-on-severity high
python3 scanner.py examples --min-severity high
python3 scanner.py examples --only-rule zod-date-serialization-review
python3 scanner.py --list-rules
python3 scanner.py --list-rules --format json
python3 scanner.py examples --ignore-rule runtime-only-zod-effect

CI usage

See docs/CI_USAGE.md for report-only, high-risk-only, and scoped rollout examples.

Safety

  • Read-only local scan.
  • No GitHub/npm/OpenAPI service account required.
  • No dependency installation required for the prototype.
  • Findings are review prompts, not automatic migration claims.
  • CI failure is opt-in via --fail-on-severity.
  • Rule filtering is explicit and local; unknown rule ids fail fast instead of silently changing coverage.
  • --min-severity supports high-risk-only reports for CI summaries.
  • --list-rules can be used to review active rule coverage before adding the scanner to CI.

Roadmap

  • Expand fixtures across common Zod/OpenAPI routing patterns.
  • Add fixtures for hono/zod-openapi/express-zod-api route variants.
  • Package as a small developer CLI after the prototype stabilizes.
  • Add more routing-library examples and release notes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zod_openapi_contract_lint_kit-0.1.1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zod_openapi_contract_lint_kit-0.1.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file zod_openapi_contract_lint_kit-0.1.1.tar.gz.

File metadata

File hashes

Hashes for zod_openapi_contract_lint_kit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6e38021c53b47b2b4b7040864603567543f99cb9dc5b248b42c7078b98b7ce5b
MD5 f5d7aefc0e2537f30db4ed58d8678e02
BLAKE2b-256 c7d15c7fdccb750a50e9dc60c0a850e1b4c819ea612a8b32900ffc62fff7fd8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for zod_openapi_contract_lint_kit-0.1.1.tar.gz:

Publisher: publish.yml on vasiliy0/zod-openapi-contract-lint-kit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zod_openapi_contract_lint_kit-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for zod_openapi_contract_lint_kit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 00546ca1fc2166827a0122e41d11e030295008a7bbec86c1f7371987eec344f4
MD5 402dd49ed003e44670ee490ab7bb4f5e
BLAKE2b-256 cbe95531832499a52b6c6c2b3eb5d8aef65fcd526dd4d3371076fbc60e5186c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for zod_openapi_contract_lint_kit-0.1.1-py3-none-any.whl:

Publisher: publish.yml on vasiliy0/zod-openapi-contract-lint-kit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page