mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 19:14:01 +03:00
Allow the documentation and schema shortcut functions to get a list of urls to introspect.
This commit is contained in:
parent
3b466fabe7
commit
b558c9ecc4
|
@ -6,7 +6,7 @@ from rest_framework.renderers import (
|
|||
from rest_framework.schemas import get_schema_view
|
||||
|
||||
|
||||
def get_docs_view(title=None, description=None, schema_url=None, public=True):
|
||||
def get_docs_view(title=None, description=None, schema_url=None, public=True, patterns=None):
|
||||
renderer_classes = [DocumentationRenderer, CoreJSONRenderer]
|
||||
|
||||
return get_schema_view(
|
||||
|
@ -14,11 +14,12 @@ def get_docs_view(title=None, description=None, schema_url=None, public=True):
|
|||
url=schema_url,
|
||||
description=description,
|
||||
renderer_classes=renderer_classes,
|
||||
public=public
|
||||
public=public,
|
||||
patterns=patterns,
|
||||
)
|
||||
|
||||
|
||||
def get_schemajs_view(title=None, description=None, schema_url=None, public=True):
|
||||
def get_schemajs_view(title=None, description=None, schema_url=None, public=True, patterns=None):
|
||||
renderer_classes = [SchemaJSRenderer]
|
||||
|
||||
return get_schema_view(
|
||||
|
@ -26,22 +27,25 @@ def get_schemajs_view(title=None, description=None, schema_url=None, public=True
|
|||
url=schema_url,
|
||||
description=description,
|
||||
renderer_classes=renderer_classes,
|
||||
public=public
|
||||
public=public,
|
||||
patterns=patterns,
|
||||
)
|
||||
|
||||
|
||||
def include_docs_urls(title=None, description=None, schema_url=None, public=True):
|
||||
def include_docs_urls(title=None, description=None, schema_url=None, public=True, patterns=None):
|
||||
docs_view = get_docs_view(
|
||||
title=title,
|
||||
description=description,
|
||||
schema_url=schema_url,
|
||||
public=public
|
||||
public=public,
|
||||
patterns=patterns,
|
||||
)
|
||||
schema_js_view = get_schemajs_view(
|
||||
title=title,
|
||||
description=description,
|
||||
schema_url=schema_url,
|
||||
public=public
|
||||
public=public,
|
||||
patterns=patterns,
|
||||
)
|
||||
urls = [
|
||||
url(r'^$', docs_view, name='docs-index'),
|
||||
|
|
|
@ -690,11 +690,13 @@ class SchemaView(APIView):
|
|||
return Response(schema)
|
||||
|
||||
|
||||
def get_schema_view(title=None, url=None, description=None, urlconf=None, renderer_classes=None, public=False):
|
||||
def get_schema_view(
|
||||
title=None, url=None, description=None, urlconf=None,
|
||||
renderer_classes=None, public=False, patterns=None):
|
||||
"""
|
||||
Return a schema view.
|
||||
"""
|
||||
generator = SchemaGenerator(title=title, url=url, description=description, urlconf=urlconf)
|
||||
generator = SchemaGenerator(title=title, url=url, description=description, urlconf=urlconf, patterns=patterns)
|
||||
return SchemaView.as_view(
|
||||
renderer_classes=renderer_classes,
|
||||
schema_generator=generator,
|
||||
|
|
Loading…
Reference in New Issue
Block a user