eadwinCode / django-ninja-extra

Django Ninja Extra - Class-Based Utility and more for Django Ninja(Fast Django REST framework)
https://eadwincode.github.io/django-ninja-extra/
MIT License
369 stars 28 forks source link

Provide a way to pass model_config (ConfigDict) to the generated schemas #174

Open Tatsh opened 1 month ago

Tatsh commented 1 month ago

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.

eadwinCode commented 1 month ago

@Tatsh It's a good idea. I will look at the implementation again and see how this can be achieved