manosim / manosim/django-rest-framework-docs
Path for nested `urls.py` files not properly built.
- Dominant language
- Python
- Stars
- 641
- Forks
- 178
- PR merge metrics
- No merged PRs in 30d
Description
I have a project level `nestor/urls.py` file like this:
```python
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:
```python
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//
/vm/
/vm//
/vm//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.
Contributor guide
Research direction
Inspect rest_framework_docs/api_docs.py around line 27, focusing on how the recursive endpoint generator carries the parent pattern. Verify the generated documentation using the nested nestor/urls.py and nestor/v1/urls.py configuration shown in the issue. Done means endpoints under the v1 include are documented with the v1/ prefix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100