fix: do not require Chi for humatest #370
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR decouples the
humatest
package from the Chi router, which was a pain for anyone using a router other than Chi. It also forced a non-stdlib dependency when using thehumago
stdlib adapter, which is not ideal. Because we can't yet rely on Go 1.22's stdlib router (Huma works with Go 1.20+), this embeds a tiny little 200 line router package used for testing. You can continue to usehumatest.Wrap
to wrap any other router/API as desired.This is a slight breaking change due to the removal of Chi in some function signatures, but worth it to fix the larger dependency issue. I am treating it as a fix rather than a major breaking change and will put plenty of notes about it in the release.
Additionally, this makes the dumped request/response during testing more readable (pretty prints JSON by default) and provides utility functions to print the request/response to stdout.