BeanieODM / beanie

Asynchronous Python ODM for MongoDB
http://beanie-odm.dev/
Apache License 2.0
1.91k stars 201 forks source link

fix: allow json_schema_extra as Callable (#884) #896

Closed valentinoli closed 2 months ago

valentinoli commented 4 months ago

Simply check if field.json_schema_extra is a dict. That way None is returned when it is a Callable. It seems too complicated to support Callable, it would require calling the function with the schema as an argument. I would assume that function call is only done internally in Pydantic so there is not a clear way to do this and retrieve the modified schema after calling the function. So I propose not to support that for now. This means for instance that adding original_field to the JSON schema of a beanie.BackLink field in a callable would not be supported...

See #884

roman-right commented 2 months ago

Hi @valentinoli , Looks good. Thank you. I plan to merge the PR at this weekend

valentinoli commented 2 months ago

Great, thank you :)

roman-right commented 2 months ago

Merged. It will be published today

valentinoli commented 2 months ago

@roman-right Thanks, I think you left this one out in the release notes, could you add it?