Any way to serialize date and date-time formats differently in the request body? #3918
Unanswered
andresmanz
asked this question in
Q&A
Replies: 2 comments
-
|
I think this is a bug and there might be a pull request for it too but not sure if there's a linked issue. Are you using Zod or Valibot btw? If yes, possible to use those for transforms? You have more freedom there with custom overrides and behavior |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Thank you very much, I'll try something with zod. You're right, there's this for example: #3723. Which is for query params only, but could be extended to the body I guess. And there's this: #3216 But it's been closed. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Our API expects string values with a "date" format (OpenAPI format: date) to be in "YYYY-MM-DD". However, with the date transformer enabled, the client serializes all Date objects as full ISO strings ("YYYY-MM-DDTHH:mm:ss.sssZ"), regardless of whether the schema defines the field as "date" or "date-time".
Is there a clean way to ensure date-formatted fields are serialized as "YYYY-MM-DD" while keeping date-time fields as full ISO strings? I've looked into using a custom bodySerializer, but it lacks access to the request schema/metadata, so I can't distinguish between the two types dynamically.
Am I missing a built-in configuration, or is disabling the date transformer and handling dates manually the recommended path for now?
Beta Was this translation helpful? Give feedback.
All reactions