Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How Can I Set camelCase for drf-spectacular #877

Closed
chaule97 opened this issue Nov 29, 2022 · 2 comments
Closed

How Can I Set camelCase for drf-spectacular #877

chaule97 opened this issue Nov 29, 2022 · 2 comments

Comments

@chaule97
Copy link

I read the document how to set camel case, it's just a guide to set 'CAMELIZE_NAMES': True in Settings. But It doesn't work

May you guide me? Thank you

@tfranzel
Copy link
Owner

I think the settings help text should have explained that sufficiently:

# Camelize names like "operationId" and path parameter names
# Camelization of the operation schema itself requires the addition of
# 'drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields'
# to POSTPROCESSING_HOOKS. Please note that the hook depends on
# ``djangorestframework_camel_case``, while CAMELIZE_NAMES itself does not.
'CAMELIZE_NAMES': False,

Full camelization has two components.

  1. To camelize operationIds and parameter names: 'CAMELIZE_NAMES': True
  2. To camelize serializer component field names:
    'POSTPROCESSING_HOOKS': [
        'drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields',
        'drf_spectacular.hooks.postprocess_schema_enums'
    ],

@chaule97
Copy link
Author

Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants