kernelci / kernelci-core

Core KernelCI tools
https://kernelci.org
GNU Lesser General Public License v2.1
107 stars 97 forks source link

kernelci.api.model_base: update `model_serializer` #2738

Closed JenySadadia closed 1 week ago

JenySadadia commented 1 week ago

Add a hack to handle exclude fields while dumping model fields to dictionary. The hack should be removed after a pydantic bug is fixed: https://github.com/pydantic/pydantic/issues/6575 Also, use SerializationInfo to get mode of serialization and convert ObjectId fields to string only if json response is required with mode=json in model_dump function. That is due to other operations such as inserting or updating objects in DB doesn't need the conversion as data types should be ObjectId in the DB.