manosim/django-rest-framework-docs

Path for nested `urls.py` files not properly built.

StyXman opened this issue · 0 comments

I have a project level nestor/urls.py file like this:

urlpatterns = [
    url(r'^v1/', include('nestor.v1.urls', namespace='api-v1')),
    url(r'^docs/', include('rest_framework_docs.urls', namespace='api-docs')),
]

Then nestor/v1/urls.py like:

router = rest_framework.routers.DefaultRouter()

router.register('node', Node, base_name='node')
router.register('vm', VirtualMachine, base_name='vm')
router.register('ldev', LDev, base_name='ldev')

# BUG: DRFDocs is not picking up the nesting properly
urlpatterns = [
    url(r'^', include(router.urls)),
]

The generated URLs in the doc look like:

/node/
/node/<pk>/
/vm/
/vm/<pk>/
/vm/<pk>/reboot/
/ldev/
/

Clearly, the v1/ prefix is missing. I think the culprit is the recursive part of the endpoint generator:

https://github.com/manosim/django-rest-framework-docs/blob/master/rest_framework_docs/api_docs.py#L27

In that line, the parent_patter that was carried in the recursive call is replaced and not accumulated.

Also, I have the impression that @manosim has stopped working on the package.