detect_schema_drift
Detects differences between a Zod schema and an OpenAPI spec, highlighting missing or extra fields, type conflicts, and required/optional mismatches to prevent contract drift.
Instructions
Compare a Zod schema in a TypeScript file against an OpenAPI spec — finds silent divergence. Use when Zod and OpenAPI docs are maintained separately and may have drifted apart. Reports missing fields, extra fields, type conflicts, and required/optional mismatches.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| zod_file_path | Yes | Absolute path to the .ts or .js file containing the Zod schema | |
| openapi_file_path | Yes | Absolute path to the OpenAPI spec (.yaml, .yml, or .json) | |
| schema_export_name | Yes | Name of the exported Zod schema variable (e.g. "UserSchema") | |
| openapi_schema_name | No | Schema name in components.schemas to compare against. Defaults to schema_export_name. |