5

I'm trying to document my Django REST API using Django Rest Swagger.

My main url conf looks like this:

urlpatterns =[
    url(r'^tickers/', include('tickerapi.urls')),
]

and tickerapi/urls:

schema_view = get_swagger_view(title='Ticker API')

urlpatterns = [
    url(r'^docs/', schema_view),
    url(r'^(?P<channel_name>[-\w]+)/', include([
        url(r'^$', views.ChannelUpdateView.as_view(),name='channel_update'), 
        url(r'^ONAIR$', views.CarouselsOnAirContentList.as_view(),name='carousel_onair_content_list'),      
        url(r'^(?P<carousel_name>[-\w]+)$', views.CarouselUpdateView.as_view(), name='carousel_update'),
    ])),
]

As you can see, my url are nested in order to have different views handling the following urls:

  • /tickers/{channel_name} (Operations: PUT, PATCH)
  • /tickers/{channel_name}/ONAIR (Operations: GET)
  • /tickers/{channel_name}/{carousel_name} (Operations: GET, PUT, PATCH)

My issue is that Django Rest Swagger is only displaying part of the nested urls, like so: Django Rest Swagger Screenshot

From what I can understand Django Rest Swagger is considering that /tickers/{channel_name} and /tickers/{channel_name}/{carousel_name} is the same endpoint. Indeed, if I only allow GET operation on the view handling /tickers/{channel_name}/{carousel_name} (using a ListAPIView), the missing nest URL is showing in Swagger, minus the GET operation: Django Rest Swagger Screenshot

Has anyone come across this issue ? I'm using Django 1.10.5, Django Rest Framework 3.5.4 and Django Rest Swagger 2.1.1

Thank you for you help

bobby
  • 81
  • 1
  • 6

0 Answers0