When using a custom RequestBody in a huma.Operation given to the huma.Register function, s.propertyNames field is only populated when the PrecomputeMessages() method is explicitly called on the Schema given to a MediaType.
Example:
// Schema definition
// ...
schema.PrecomputeMessages()
huma.Register(
api,
huma.Operation{
OperationID: "post-user-attributes",
Method: http.MethodPost,
Path: "/",
Description: "upsert the given attributes for the given user, validating using the given appKey's attributes",
Summary: "upsert attributes",
DefaultStatus: http.StatusOK,
RequestBody: &huma.RequestBody{
Description: "My custom request schema",
Required: true,
Content: map[string]*huma.MediaType{
"application/json": {
Schema: schema,
},
},
},
},
// handler omitted
If this is a feature, I believe that it should be explicitly documented.
https://github.com/danielgtaylor/huma/blob/6019e80758fc8b209c5e1a4e319d429572104f35/validate.go#L543
When using a custom
RequestBody
in ahuma.Operation
given to thehuma.Register
function,s.propertyNames
field is only populated when thePrecomputeMessages()
method is explicitly called on theSchema
given to aMediaType
.Example:
If this is a feature, I believe that it should be explicitly documented.
Thanks 🙏