feat(core): add formatType config for custom string format types - #3727
Draft
chrisahardie wants to merge 3 commits into
Draft
feat(core): add formatType config for custom string format types#3727chrisahardie wants to merge 3 commits into
chrisahardie wants to merge 3 commits into
Conversation
Map any OpenAPI string format to a custom TypeScript type via
override.formatType. Supports type+import, Zod transform/codec
replacement, and mock expression overrides. Uses StringFormat =
'date' | 'date-time' | 'time' | (string & {}) for autocomplete.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Moves the dayjs dependency from the root package.json catalog to a pinned version in tests/package.json, since it's only needed for formatType test fixtures. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Restore unconditional date/date-time branch in buildPrimitivePayload and buildDefaultPayload so factory methods emit ISO date strings when neither formatType nor useDates is set (was regressed to empty string) - Guard Zod formatType lookup against undefined schema.format matching empty-string key - Document Zod transform and Effect limitations in formatType docs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
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.
Partially solves #1939
Summary
Adds
override.formatType— a config that maps any OpenAPIstringformat (e.g.date,date-time,uuid,email) to a custom TypeScript type, with integrated support across Zod schemas, Effect schemas, faker mocks, and factory defaults.Motivation
Users working with Temporal API, dayjs, branded types, or domain-specific formats have no way to override the generated type for string formats beyond the binary
useDatesflag. This feature generalizes type mapping to any format string, with full control over imports, Zod validation, mock generation, and factory defaults.Config shape
What's NOT in scope
Runtime response deserialization and request body serialization are deliberately excluded. These are orthogonal concerns being addressed separately (see #1939).