-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
tag readOnly:"true" does not seem to work on object types #455
Comments
@bshtmichielsen nice catch! I suspect this is similar to nullability, see the documentation at https://huma.rocks/features/request-validation/#nullable and the discussion we had in #351. Basically, the |
@danielgtaylor Thanks for your reply. I must say I am a little unsure about what you are saying. It is the first time I am using Huma so maybe it is just me not understanding all features yet, however, to me the nullable issue regards something at the structural level of the model that is underlying. Whether or not a certain field should be able to accept a "nil"-like value. To me the "readOnly" tag does that actually regard the structure at all, it is merely a hint to the user that a certain field should not be sent on Post/Put and if sent anyway it will be ignored. Adding the "readOnly" tag should probably only affect the API-endpoint and its doc and not the way the underlying struct functions. If that brings to technical issues down the road, probably a default instance of the readOnly struct is not an issue. For example in my case: BTW I am the OP of this issue, I just made it from another computer, apparently with a different account. |
I have defined 2 structs, named Notice, and User. The Notice struct has a field of type User with
json:"user" readOnly:"true"
but it ends up in the Body for a post request anyway. Primitive fields, like string and int and such, withreadOnly:"true"
seem to exhibit the expected behaviour.The text was updated successfully, but these errors were encountered: