Skip to content

Commit f7c3220

Browse files
al-muammartomchristie
authored andcommitted
Ability to specify urlconf in include_docs_urls added (encode#6824)
There is a problem in the current implementation that if one exports docs via `include_docs_urls` he will be using `ROOT_URLCONF` (https://github.com/encode/django-rest-framework/blob/master/rest_framework/schemas/generators.py#L73), which is a big problem, if one is working with subdomains and he has sets of disjoint URLs. This simple fix allows to pass through forgotten `urlconf` parameter.
1 parent ea2ebf6 commit f7c3220

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

rest_framework/documentation.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99

1010
def get_docs_view(
11-
title=None, description=None, schema_url=None, public=True,
12-
patterns=None, generator_class=SchemaGenerator,
11+
title=None, description=None, schema_url=None, urlconf=None,
12+
public=True, patterns=None, generator_class=SchemaGenerator,
1313
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
1414
permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES,
1515
renderer_classes=None):
@@ -20,6 +20,7 @@ def get_docs_view(
2020
return get_schema_view(
2121
title=title,
2222
url=schema_url,
23+
urlconf=urlconf,
2324
description=description,
2425
renderer_classes=renderer_classes,
2526
public=public,
@@ -31,15 +32,16 @@ def get_docs_view(
3132

3233

3334
def get_schemajs_view(
34-
title=None, description=None, schema_url=None, public=True,
35-
patterns=None, generator_class=SchemaGenerator,
35+
title=None, description=None, schema_url=None, urlconf=None,
36+
public=True, patterns=None, generator_class=SchemaGenerator,
3637
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
3738
permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES):
3839
renderer_classes = [SchemaJSRenderer]
3940

4041
return get_schema_view(
4142
title=title,
4243
url=schema_url,
44+
urlconf=urlconf,
4345
description=description,
4446
renderer_classes=renderer_classes,
4547
public=public,
@@ -51,15 +53,16 @@ def get_schemajs_view(
5153

5254

5355
def include_docs_urls(
54-
title=None, description=None, schema_url=None, public=True,
55-
patterns=None, generator_class=SchemaGenerator,
56+
title=None, description=None, schema_url=None, urlconf=None,
57+
public=True, patterns=None, generator_class=SchemaGenerator,
5658
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
5759
permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES,
5860
renderer_classes=None):
5961
docs_view = get_docs_view(
6062
title=title,
6163
description=description,
6264
schema_url=schema_url,
65+
urlconf=urlconf,
6366
public=public,
6467
patterns=patterns,
6568
generator_class=generator_class,
@@ -71,6 +74,7 @@ def include_docs_urls(
7174
title=title,
7275
description=description,
7376
schema_url=schema_url,
77+
urlconf=urlconf,
7478
public=public,
7579
patterns=patterns,
7680
generator_class=generator_class,

0 commit comments

Comments
 (0)