Skip to content
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

fix: check if struct implements interface SchemaProvider after deref #413

Merged
merged 2 commits into from
Apr 26, 2024

Conversation

lennycampino
Copy link
Contributor

@lennycampino lennycampino commented Apr 26, 2024

Problem:
Currently the Schema(r Registry) *Schema on types that implement a custom schema will only be called if the field is not a pointer.

Solution:
In the function SchemaFromType we first deref the type so that we always compare a non pointer type against the interface.

fixes: #412

Copy link

codecov bot commented Apr 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.65%. Comparing base (dcfa3e9) to head (4ee4554).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #413   +/-   ##
=======================================
  Coverage   92.65%   92.65%           
=======================================
  Files          21       21           
  Lines        3539     3539           
=======================================
  Hits         3279     3279           
  Misses        221      221           
  Partials       39       39           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@danielgtaylor
Copy link
Owner

@lennycampino nice fix, thank you! 👍

@danielgtaylor danielgtaylor merged commit ed2c3cd into danielgtaylor:main Apr 26, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Schema(r huma.Registry) *huma.Schema not working on Pointer
2 participants