-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
Allow anonymous fields to be used as request input parameters #617
Comments
@lsdch this example seems incomplete (I'm not sure what Identifier InputUUID `path:"uuid" format:"uuid"` Then rather than |
Hey, sorry about the late response ! So I have a generic The challenge is that item identifiers may have different type (e.g. UUID, string) and different input source (e.g. type IdentifierInput[T any] interface {
Identifier() T
}
type GetInputInterface[Item any, ID any] interface {
IdentifierInput[ID] // The identifier of the item to get
// ... some resolvers to handle things like access control
} Because of how Go is designed, I could not access the identifier from inside func GetHandler[
OperationInput GetInputInterface[Item, ID],
Item any,
ID any,
](
find models.ItemFinder[ID, Item],
) func(context.Context, OperationInput) (*GetHandlerOutput[Item], error) {
// Huma handler
return func(ctx context.Context, input OperationInput) (*GetHandlerOutput[Item], error) {
item, err := find(input.DB(), input.Identifier()) // getting the identifier directly from the input
// ... boilerplate
return &GetHandlerOutput[Item]{Body: item}, err
}
} |
Hi! Would you consider adding support for anonymous fields in request input parameters ?
My use case is the implementation of generic operation handlers such as :
The text was updated successfully, but these errors were encountered: