vbabiy / djangorestframework-camel-case

Camel case JSON support for Django REST framework.
Other
635 stars 122 forks source link

custom endpoint is not working #149

Open muonu opened 5 months ago

muonu commented 5 months ago

I am trying to set a custom path param product_id.

It seems to only work if url param is already camelCase. is this the expected behavior? this would mean manual mapping in the view from camelCase to snake_case.

custom_urlpatterns = [
   # works
    path('<int:productId>/sellers/', views.ProductSellerAPIView.as_view(), name='sellers'),

    # does NOT work
    # path('<int:product_id>/sellers/', views.ProductSellerAPIView.as_view(), name='sellers'),
]

# Combine both sets of URL patterns
urlpatterns = [
    path('', include(router.urls)),
]  + custom_urlpatterns

with snake_case param, when i post a request from swagger, I get

curl -X 'GET' \
  'http://localhost:8000/api/products/{product_id}/sellers/' \
  -H 'accept: application/json'

fails to insert the param.

I can make it work by setting param name = id instead of product_id, but wanted to check just in case the underlying issue might cause any other effects.

actually this might be drf-spectacular failing to play well with this middleware.

muonu commented 5 months ago

is there a setting to make sure it is not camelCasing the url params?