ungdev / etuutt-api

Users, classes, assos : An awesome API to rule them all
MIT License
2 stars 2 forks source link

When a field is empty, it is not sent in the responses #28

Closed TeddyRoncin closed 2 years ago

TeddyRoncin commented 2 years ago

Description

Everything is in the title. Here are 2 screenshots to illustrate (the route is GET users/{id}) : Expected : image Actual : image

How to fix it

There is a property called skip_null_values which should be set to false in the normalization_context of the call to ApiResource in the entities. Here is a screenshot of a fixed file and of a non-fixed file (Entity/User.php) : Fixed : image Actual : image

ThomasRitaine commented 2 years ago

Ok c'est très clair. Super ticket @TeddyRoncin ! 🎉

Je te laisse faire la PR pour le corriger