-
-
Notifications
You must be signed in to change notification settings - Fork 428
Description
What version of Elysia is running?
latest
What platform is your computer?
Linux 5.15.167.4-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
Here's the mismatch @SaltyAom:
If you write limit: t.Number({ default: 10 }) you get perfect TypeScript usage for handlers but the generated OpenAPI says limit is required and so does the Eden Treaty client.
If you write limit: t.Optional(t.Number({ default: 10 })) you get the correctly generated OpenAPI & Eden Treaty client but in handlers it is also optional, despite knowing that Elysia has already set these based on the defaults, forcing you to do a redundant fallback in code for every optional param with a default e.g.
const enableFee = query.enableFee ?? false
What is the expected behavior?
I expect that if default is set, Elysia will consider that and strongly type the query, params & body, whilst keeping optional for open api generation and eden treaty client.