elysiajs / elysia-swagger

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

TDate returning wrong values for OpenAI document #124

Open Hoyci opened 6 months ago

Hoyci commented 6 months 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 5 months ago

Facing this issues as well.

mphill commented 1 day ago

The swagger Date types are still generated as date | string; Note the lowercase date, which is invalid.