-
-
Notifications
You must be signed in to change notification settings - Fork 232
feat: #843 Allow 406 Not Acceptable with NoFormatFallback config #850
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
Conversation
- Added positive and negative test for unknown/invalid Accept header - Fixed a bug(?) with how Content-Type was set for 406 responses by moving the Content-Type set into the `transformWrite()`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new configuration flag, NoFormatFallback, to control behavior when a client requests an unknown Accept header, and fixes a bug where the Content-Type header was not set for 406 responses. Key changes include adding the NoFormatFallback field to Config, updating negotiation logic and default format assignment in api.go, and adding positive/negative tests in huma_test.go.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| huma_test.go | Added new test cases for unknown Accept header handling |
| huma.go | Moved setting of Content-Type header into transformAndWrite |
| api.go | Updated negotiation and default format assignment with NoFormatFallback |
Comments suppressed due to low confidence (1)
api.go:410
- [nitpick] It may be helpful to add a brief comment clarifying why DefaultFormat is only automatically set when NoFormatFallback is false, as this behavior is central to the new feature.
if config.DefaultFormat == "" && !config.NoFormatFallback {
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #850 +/- ##
==========================================
+ Coverage 92.47% 92.55% +0.08%
==========================================
Files 23 23
Lines 5501 5507 +6
==========================================
+ Hits 5087 5097 +10
+ Misses 354 351 -3
+ Partials 60 59 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fix: content type bug introduced in #850
PR for #843
NoFormatFallbackfield toConfigto control format fallback.Config).transformWrite().