Closed danielgtaylor closed 4 weeks ago
The recent changes enhance the huma
framework's handling of request bodies and schema validation. Key improvements include automatic precomputation of schema messages when custom schemas are used, ensuring more robust validation. New test cases bolster error reporting capabilities, ensuring that invalid input scenarios are adequately handled without manual intervention.
Files | Change Summary |
---|---|
huma.go, huma_test.go | Enhanced request body handling and schema validation. Added new test for custom schema errors. |
schema.go | Updated schemaFromType to automatically call PrecomputeMessages() on custom schemas. |
sequenceDiagram
participant Client
participant Huma
participant SchemaProvider
Client->>Huma: POST / with custom RequestBody
Huma->>SchemaProvider: Get Schema
SchemaProvider->>Huma: Return Schema
Huma->>Schema: Call PrecomputeMessages()
Schema-->>Huma: Precomputed Messages
Huma->>Huma: Validate input against Schema
Huma-->>Client: Return Response
Objective | Addressed | Explanation |
---|---|---|
Need to explicitly call PrecomputeMessages() (Issue #454) |
✅ | |
Ensure custom schemas validate correctly in tests | ✅ |
🐰 In a field where schemas grow,
Precomputation helps us know,
With tests that catch the errors fast,
Our API thrives, robust and vast!
🥕✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 92.76%. Comparing base (
b13a422
) to head (7be3b0c
). Report is 2 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This fix makes it easier to use custom schemas by removing the need to manually call
schema.PrecomputeMessages()
before the server starts up.Fixes #454.
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation