django-ninja-extra
django-ninja-extra copied to clipboard
Provide a way to pass model_config (ConfigDict) to the generated schemas
I would like to pass model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True, from_attributes=True) to every generated schema and pass by_alias=True to every generated API view. This allows use of camelcase.
Currently in ninja-extra ModelConfig there is no way to apply properties to the generated schemas. I think at fault here is actually django-ninja's create_schema() function for not accepting a way to customise the Config or model_config options.
I think my latter point is fixed by adding create_route_info={'by_alias': True} or similar to the ModelConfig() arguments.
@Tatsh It's a good idea. I will look at the implementation again and see how this can be achieved
@Tatsh This has been resolved. Another solution to this would be to create the schema manually and pass ModelConfig
Thanks for the update. Closing.