feat: spec-level Postel's-Law tolerant readers#36
Merged
Conversation
Vendored `scripts/lib/preprocess.mjs` is now in lockstep with mono's `@devhelm/openapi-tools` and runs `relaxResponseEnumsInSpec` before openapi-zod-client consumes the spec. Response-DTO multi-value enums are dropped at the spec level, so the generated Zod is `z.string()` for those fields — `MonitorDto.type` decodes any string, including future values added by the API after this CLI version was built. Request DTOs keep their literal unions for strict authoring-time validation. `scripts/generate-zod.mjs` clones the spec before preprocessing so the spec-facts emitter (`spec-facts.generated.ts`) keeps reading from the *un-relaxed* spec — the YAML / oclif flag validators stay strict. See `mini/runbooks/api-contract.md` § 3.1 for the cross-surface design. Coverage: 998 / 998 tests pass; lint + tsc clean. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CLI now decodes response-DTO multi-value enums as plain strings, so
MonitorDto.type,IncidentDto.status, etc. flow through the Zodschemas as
z.string()and accept future API values added after thisCLI version was built. Authoring schemas (oclif
--typeflags, YAMLconfig validation) stay strict —
spec-facts.generated.tsreads fromthe un-relaxed spec snapshot.
Implementation
scripts/lib/preprocess.mjsis the vendored copy of mono's@devhelm/openapi-toolspreprocessor. It now callsrelaxResponseEnumsInSpecbefore the spec is handed toopenapi-zod-client, so the relaxation happens at the spec level(not as a post-processing regex).
scripts/generate-zod.mjsclonesthe spec before preprocessing so
generateSpecFactsoperates on thestrict snapshot — request-side authoring DX is preserved.
Cross-surface design:
mini/runbooks/api-contract.md§ 3.1.Tests
npm run lintclean,npm run typecheckclean.Test plan
npm run zodgenproducesz.string()onresponse DTOs and preserves
z.enum([...])on request DTOs.Made with Cursor