Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

exclude_namespaces is ignored for related endpoints #348

Closed
Laughing-Man opened this issue Aug 19, 2015 · 4 comments
Closed

exclude_namespaces is ignored for related endpoints #348

Laughing-Man opened this issue Aug 19, 2015 · 4 comments

Comments

@Laughing-Man
Copy link

Issue occurs in views.SwaggerApiView.get_apis_for_resource()

If an excluded url shares a resource path with another api that isn't excluded, it will still get picked up by the above method and displayed. A 2 line change fixes this, but I can't tell if there's some reason why this would be otherwise desirable.

Example:
/api/things/{group}/
/api/things/{group}/paged/{page}/

If I put the second url in an excluded namespace, it will still get picked up and included in the docs, because the aforementioned method only uses a filter_path to assemble its list of apis, and doesn't check the excluded list.

This is what fixed it for me.

<views.py line 158>
-        apis = urlparser.get_apis(urlconf=urlconf, filter_path=filter_path)
+        exclude_namespaces = rfs.SWAGGER_SETTINGS.get('exclude_namespaces')
+        apis = urlparser.get_apis(urlconf=urlconf, filter_path=filter_path, exclude_namespaces=exclude_namespaces)

This change makes everything behave in the way I intended, but will this have unexpected consequences for me later? Also, is this situation idiosyncratic to my use case or something that should be corrected?

@cjhenck
Copy link

cjhenck commented Sep 3, 2015

I had the exact same problem just now - there's a recursion in a URL completely unrelated to our API, which crashes the swagger doc generator.

tiagovanderlei added a commit to Mobillers/django-rest-swagger that referenced this issue Dec 18, 2015
… appropriately.

Issue: "exclude_namespaces is ignored for related endpoints marcgibbons#348"
@tiagovanderlei
Copy link

@Laughing-Man, i came to the same solution as you, once Swagger actually ignores the exclude namespaces variable when looks for the endpoints content. When i debug i realized that the group is retrieved properly because exclude_namespaces is checked, but when it looks for the apis to be listed for each group, it doesnt check directly their namespaces and all of group apis are shown.

@tiagovanderlei
Copy link

have you created a branch and/or a pull request ?

@marcgibbons
Copy link
Owner

urlpatterns may explicitly be listed now in DRF 3.4 on the schema generator.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants