How to use djangorestframework-camel-case with drf-spectacular for camelcase schema

26 views Asked by At

I have set up djangorestframework_camel_case and it works for rendered response data in swagger-ui (drf-spectacular) - camel case response is generated. But the schema generated in the swagger-ui is still snake-case. How can I make sure it also applies camel case to schema?

I see this PR that apparently adds support for djangorestframework_camel_case, not sure exactly if it is expected to work out of the box, nothing in the docs.

1

There are 1 answers

0
muon On

Add this in spectacular_settings:

    'CAMELIZE_NAMES': False, 
    
    'POSTPROCESSING_HOOKS': [
        'drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields',
        'drf_spectacular.hooks.postprocess_schema_enums'
    ],

Thanks to