starlette-jsonapi icon indicating copy to clipboard operation
starlette-jsonapi copied to clipboard

"many" argument of serialization functions seems redundant and adverse

Open LeafyLappa opened this issue 2 years ago • 1 comments

BaseResource methods serialize and serialize_related have this argument "many" with the default value of False, making it possible to break the JSON:API specification (e.g. if you serialize one object as collection) without any apparent benefit.

Perhaps those functions could contain logic to determine whether data passed to them is iterable, treating strings and such as single objects of course.

LeafyLappa avatar Aug 05 '21 13:08 LeafyLappa

That's a fair point, and I'd be happy to review a PR if you'd like to have a go at it. Otherwise, I will try to look at this in the near future.

vladmunteanu avatar Aug 05 '21 17:08 vladmunteanu