Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
e407dc7f
Commit
e407dc7f
authored
Jul 28, 2016
by
Tom Christie
Committed by
GitHub
Jul 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added root_renderers argument (#4323)
parent
306726d9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletions
+9
-1
docs/api-guide/schemas.md
+4
-0
rest_framework/routers.py
+5
-1
No files found.
docs/api-guide/schemas.md
View file @
e407dc7f
...
...
@@ -155,6 +155,10 @@ schema URLs include a path prefix.
If you want more flexibility over the schema output then you'll need to consider
using
`SchemaGenerator`
instead.
#### root_renderers
May be used to pass the set of renderer classes that can be used to render the API root endpoint.
## Using SchemaGenerator
The most common way to add a schema to your API is to use the
`SchemaGenerator`
...
...
rest_framework/routers.py
View file @
e407dc7f
...
...
@@ -283,6 +283,10 @@ class DefaultRouter(SimpleRouter):
self
.
schema_title
=
kwargs
.
pop
(
'schema_title'
,
None
)
self
.
schema_url
=
kwargs
.
pop
(
'schema_url'
,
None
)
self
.
schema_renderers
=
kwargs
.
pop
(
'schema_renderers'
,
self
.
default_schema_renderers
)
if
'root_renderers'
in
kwargs
:
self
.
root_renderers
=
kwargs
.
pop
(
'root_renderers'
)
else
:
self
.
root_renderers
=
list
(
api_settings
.
DEFAULT_RENDERER_CLASSES
)
super
(
DefaultRouter
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
get_api_root_view
(
self
,
api_urls
=
None
):
...
...
@@ -294,7 +298,7 @@ class DefaultRouter(SimpleRouter):
for
prefix
,
viewset
,
basename
in
self
.
registry
:
api_root_dict
[
prefix
]
=
list_name
.
format
(
basename
=
basename
)
view_renderers
=
list
(
api_settings
.
DEFAULT_RENDERER_CLASSES
)
view_renderers
=
list
(
self
.
root_renderers
)
schema_media_types
=
[]
if
api_urls
and
self
.
schema_title
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment