elysiajs / elysia-swagger

A plugin for Elysia to auto-generate Swagger page
MIT License
74 stars 36 forks source link

TDate returning wrong values for OpenAI document #124

Open Hoyci opened 1 month ago

Hoyci commented 1 month ago

I'm creating a documentation for my API, but when I create a Response t.Object like this: t.Object({ user: t.Object({ id: t.String(), email: t.String(), createdAt: t.Date(), updatedAt: t.Date() }) })

image

createdAt and updatedAt is transformed for this on the OpenAPI Document "createdAt": { "anyOf": [ { "type": "Date" }, { "format": "date", "default": "2024-05-16T23:05:28.064Z", "type": "string" }, { "format": "date-time", "default": "2024-05-16T23:05:28.064Z", "type": "string" } ] }, "updatedAt": { "anyOf": [ { "type": "Date" }, { "format": "date", "default": "2024-05-16T23:05:28.065Z", "type": "string" }, { "format": "date-time", "default": "2024-05-16T23:05:28.065Z", "type": "string" } ] } },

And to work well needs to be like:

"createdAt": { "format": "date", "default": "2024-05-16T23:05:28.065Z", "type": "string" }

image

Is this an error in my code or a bug on elysia-swagger?

darr1s commented 3 weeks ago

Facing this issues as well.