Skip to content

Added root_renderers argument #4323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/api-guide/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
6 changes: 5 additions & 1 deletion rest_framework/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ def __init__(self, *args, **kwargs):
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):
Expand All @@ -294,7 +298,7 @@ def get_api_root_view(self, api_urls=None):
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:
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy