Open knyghty opened 4 years ago
I have the same problem :)
I think I've found a way to make this work by doing a bit of explicit configuration. I just had to implement the OpenAPI schema endpoint from the DRF docs and then passed the renderer classes configured according to this package's docs:
from django.urls import re_path
from rest_framework.schemas import get_schema_view
from rest_framework.settings import api_settings
urlpatterns = [
re_path(
"^openapi/$",
get_schema_view(
title="My API",
renderer_classes=api_settings.DEFAULT_RENDERER_CLASSES,
),
name="openapi-schema",
),
]
Next time I access my OpenAPI schema url or my Swagger url all fields are camelCased :ok_hand: Hope this helps.
https://github.com/tfranzel/drf-spectacular supports djangorestframework-camel-case
Right now if you use this package and DRF's OpenAPI schema generator, the fields don't end up camelized. I have kludged together a quick fix for this:
It works for me and it seems like a good fit for this project, but I thought I'd check in first before making a PR because I'm not sure if it's an amazing idea. It's very useful and works, but overriding a private API (
_map_serializer()
) doesn't seem great, especially since DRF's schema generation is quite new and a bit of a moving target at the moment.But if you'd like I can add some tests for this and submit a PR, but it might need some maintenance.