danielgtaylor / huma

Huma REST/HTTP API Framework for Golang with OpenAPI 3.1
https://huma.rocks/
MIT License
1.87k stars 138 forks source link

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

Closed lennycampino closed 4 months ago

lennycampino commented 4 months ago

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

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

danielgtaylor commented 4 months ago

@lennycampino nice fix, thank you! :+1: