huma icon indicating copy to clipboard operation
huma copied to clipboard

Enabling recursive process structs for patameters

Open birukbelay opened this issue 6 months ago • 1 comments

On huma parameters are not checked recursively, on structs which limits us to only embedding structs for queries on humas code on huma/huma.go line 213: it sets recurseFields to false, , false, "Body")

but because of that it prevents use of nested structs specially for such cases func (uh *IGenericController[T, C, U, F, Q]) OffsetPaginated(ctx context.Context, filter *struct { Filter F Query Q dtos.PaginationInput }) (*dtos.HumaResponse[dtos.PResp[[]T]], error) {

resp, err := DbFetchManyWithOffset[T](uh.GormConn, ctx, filter.Filter, filter.PaginationInput)
return dtos.PHumaReturn(resp, err)

}

because F and Q are Generic type i could not just embed them with out Filter & Query fields, so only by setting the value on huma/huma.go:213 we can fix this problem

birukbelay avatar Jul 24 '25 08:07 birukbelay

I would also like to know why we can't use struct embedded types or how to use them for request types.

For example, I would like to do,

type pagination struct {
	Limit  int32 `query:"limit" default:"20" minimum:"1" maximum:"100"`
	Offset int32 `query:"offset" default:"0" minimum:"0"`
}

type email struct {
	Email string `query:"Email" format:"email" example:"[email protected]"`
}

func (s *Server) ListUsers(ctx context.Context, input *struct{pagination; email}) (*response[userArray], error) {
}

effectively

repelliuss avatar Jul 26 '25 15:07 repelliuss