vitalik / django-ninja

💨 Fast, Async-ready, Openapi, type hints based framework for building APIs
https://django-ninja.dev
MIT License
7.03k stars 421 forks source link

Pass serialisation context to model_dump (fixes #1233) #1261

Closed scorpp closed 1 month ago

scorpp commented 1 month ago

Pydantic starting with 2.7 added support for context param in model_dump and model_dump_json allowing to pass arbitrary additional data into custom serializers.

Passing request in serialisation context may be useful in cases where customising serialisation is necessary.

vitalik commented 1 month ago

Hi @scorpp

Could you as well add some test case(s) for for this ?

vitalik commented 1 month ago

Thank you