You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be useful to be able to link operations to another. Hypermedia links can link endpoints that are commonly used as follow-up to the current endpoint. The links could be defined on operation creation and be added to the API response automatically.
This could, for example, be achieved by adding a parameter to the Operation struct that is called "HypermediaLinks" that takes a string slice of operation ids. On the api creation, it should panic if a linked operation is not found.
The text was updated successfully, but these errors were encountered:
@Mcklmo this should be possible today to some degree via OpenAPI's support for links in the documentation, e.g. using the huma.Response.Links field https://pkg.go.dev/github.com/danielgtaylor/huma/v2#Response. Of course this is out-of-band of the response, but more efficient than sending it each time.
As for in-band response links, you can just use a utility function to add them. I do so in my own services for self and next links but given the many different ways (and semi-standards) to send such links I haven't built anything into Huma's core for it. Huma itself is meant to be easy to wrap with such functionality, so you could for example create your own register function that takes info about your links format and generates the OpenAPI and/or response data via a transformer to automate it all, or just write a few utility functions your handlers can call to populate the links as needed. Up to you!
Awesome, thanks for elaborating on how this can achieved with Huma already. This was insightful, as I'm still new to your framework. I'll definitely give it a try.
It would be useful to be able to link operations to another. Hypermedia links can link endpoints that are commonly used as follow-up to the current endpoint. The links could be defined on operation creation and be added to the API response automatically.
Example response to GET /users/1
This could, for example, be achieved by adding a parameter to the Operation struct that is called "HypermediaLinks" that takes a string slice of operation ids. On the api creation, it should panic if a linked operation is not found.
The text was updated successfully, but these errors were encountered: