Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was thinking the exact same thing when I first read about DRF's Serializers. Also I don't quite get why serialization is always expected to work automatically, at least not in the context of mapping a business layer to an API layer (e.g. for JSON consumption), as those domains don't have to map directly onto each other.

Therefore, for an ongoing project I've implemented something along the lines of your idea (if I got that correctly), by describing API-Layer models in terms of properties, which are just named sets of pure lambdas. The most general property only requires a single one to compute the property value from an input business-model.

This allows for some very nice things, especially with regards to API-level functionality like support for nested ?expand=, ?only=, and such niceties.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: