Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] API requires all dates to be UTC - is there a way to encode all dates like this? #740

Open
dJani97 opened this issue Mar 21, 2024 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@dJani97
Copy link

dJani97 commented Mar 21, 2024

Please describe a problem.
I'm using an API which requires all dates to be UTC, meaning, they should be in this format, ending with a Z:

"2024-01-02T09:00:00.000Z"

If they don't end with a Z, I get an internal server error 😓

To comply with this, I have to make a copy of any newly created objects in my repository layer, and manually overwrite all DateTime fields in the class by calling the .toUtc() method on their value. This is complicated, and it's easy to accidentally miss a field.

Describe the solution you'd like
Is there any way to write a custom converter or something, and apply it globally for all DateTime objects?

I know json_serializable has #custom-types-and-custom-encoding, is this accessible somehow when I'm using swagger-dart-code-generator?

@dJani97 dJani97 added the question Further information is requested label Mar 21, 2024
@Vovanella95
Copy link
Collaborator

Hi @dJani97 , I can add string formatter for DateTime. Will let you know soon about updates

@xioxin
Copy link

xioxin commented Oct 24, 2024

The Scalars Implementation can solve this problem.

You can refer to this:
#750 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants