mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 08:14:16 +03:00
Added root_renderers argument (#4323)
This commit is contained in:
parent
306726d9e8
commit
e407dc7f01
|
@ -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
|
If you want more flexibility over the schema output then you'll need to consider
|
||||||
using `SchemaGenerator` instead.
|
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
|
## Using SchemaGenerator
|
||||||
|
|
||||||
The most common way to add a schema to your API is to use the `SchemaGenerator`
|
The most common way to add a schema to your API is to use the `SchemaGenerator`
|
||||||
|
|
|
@ -283,6 +283,10 @@ class DefaultRouter(SimpleRouter):
|
||||||
self.schema_title = kwargs.pop('schema_title', None)
|
self.schema_title = kwargs.pop('schema_title', None)
|
||||||
self.schema_url = kwargs.pop('schema_url', None)
|
self.schema_url = kwargs.pop('schema_url', None)
|
||||||
self.schema_renderers = kwargs.pop('schema_renderers', self.default_schema_renderers)
|
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)
|
super(DefaultRouter, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def get_api_root_view(self, api_urls=None):
|
def get_api_root_view(self, api_urls=None):
|
||||||
|
@ -294,7 +298,7 @@ class DefaultRouter(SimpleRouter):
|
||||||
for prefix, viewset, basename in self.registry:
|
for prefix, viewset, basename in self.registry:
|
||||||
api_root_dict[prefix] = list_name.format(basename=basename)
|
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 = []
|
schema_media_types = []
|
||||||
|
|
||||||
if api_urls and self.schema_title:
|
if api_urls and self.schema_title:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user