-
-
Notifications
You must be signed in to change notification settings - Fork 150
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 about 'required by default' #458
Comments
@jpincas there is no switch you can flip to make everything optional by default. You can add Another alternative is to provide a custom schema or use the newly released If you don't want to do this for each input struct then you can also just write a function which goes over |
Thanks Daniel. I'll experiment with those options. |
@danielgtaylor Using the |
@jpincas sorry I think you may be running into https://github.com/danielgtaylor/huma/blob/main/schema.go#L280. There is some caching of required property info that should probably get recomputed after you modify |
OK understood - thanks for your help. |
Hi there. Currently switching over our API to Huma. Thank you for this - it's truly a masterwork.
I've looked all over the docs and searched for the answer to this question, so apologies if the answer is somewhere obvious. For various reasons, I basically need all body fields in a request to be optional. I'd rather not have to go through all my input structs (there are about 40), adding
required:"false"
to each field. Is there any way to override the 'required by default' behaviour (https://huma.rocks/features/request-validation/, Optional/Required, Point 1) so I can just mark the ones that ARE required?Thanks
The text was updated successfully, but these errors were encountered: