</>
Integrating camelcase for Django REST Framework & drf_spectacular
In Django REST API you usually want to achieve:
- Camelcase instead of snake_case for your data:
- that is why djangorestframework-camel-case was created
- Autogenerated Swagger documentation for your API
- I like to use drf_spectacular
However, if you combine these two, types generated by drf_spectacular
are still in snake_case.
The following configuration helps to solve the issue:
# settings.pySPECTACULAR_SETTINGS = {# makes params in URLs camelcase for consistency'CAMELIZE_NAMES': True,# transforms data types and responses'POSTPROCESSING_HOOKS': ['drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields']}