mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Merge master.
This commit is contained in:
commit
778aee1bb3
|
@ -54,7 +54,7 @@ There is a live example API for testing purposes, [available here][sandbox].
|
|||
# Requirements
|
||||
|
||||
* Python (2.7, 3.2, 3.3, 3.4, 3.5)
|
||||
* Django (1.8, 1.9, 1.10)
|
||||
* Django (1.8, 1.9, 1.10, 1.11)
|
||||
|
||||
# Installation
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ continued development by **[signing up for a paid plan][funding]**.
|
|||
REST framework requires the following:
|
||||
|
||||
* Python (2.7, 3.2, 3.3, 3.4, 3.5)
|
||||
* Django (1.8, 1.9, 1.10)
|
||||
* Django (1.8, 1.9, 1.10, 1.11)
|
||||
|
||||
The following packages are optional:
|
||||
|
||||
|
|
|
@ -3,10 +3,12 @@ from django.conf.urls import include, url
|
|||
from rest_framework.renderers import (
|
||||
CoreJSONRenderer, DocumentationRenderer, SchemaJSRenderer
|
||||
)
|
||||
from rest_framework.schemas import get_schema_view
|
||||
from rest_framework.schemas import SchemaGenerator, get_schema_view
|
||||
|
||||
|
||||
def get_docs_view(title=None, description=None, schema_url=None, public=True, patterns=None):
|
||||
def get_docs_view(
|
||||
title=None, description=None, schema_url=None, public=True,
|
||||
patterns=None, generator_class=SchemaGenerator):
|
||||
renderer_classes = [DocumentationRenderer, CoreJSONRenderer]
|
||||
|
||||
return get_schema_view(
|
||||
|
@ -16,10 +18,13 @@ def get_docs_view(title=None, description=None, schema_url=None, public=True, pa
|
|||
renderer_classes=renderer_classes,
|
||||
public=public,
|
||||
patterns=patterns,
|
||||
generator_class=generator_class,
|
||||
)
|
||||
|
||||
|
||||
def get_schemajs_view(title=None, description=None, schema_url=None, public=True, patterns=None):
|
||||
def get_schemajs_view(
|
||||
title=None, description=None, schema_url=None, public=True,
|
||||
patterns=None, generator_class=SchemaGenerator):
|
||||
renderer_classes = [SchemaJSRenderer]
|
||||
|
||||
return get_schema_view(
|
||||
|
@ -29,16 +34,20 @@ def get_schemajs_view(title=None, description=None, schema_url=None, public=True
|
|||
renderer_classes=renderer_classes,
|
||||
public=public,
|
||||
patterns=patterns,
|
||||
generator_class=generator_class,
|
||||
)
|
||||
|
||||
|
||||
def include_docs_urls(title=None, description=None, schema_url=None, public=True, patterns=None):
|
||||
def include_docs_urls(
|
||||
title=None, description=None, schema_url=None, public=True,
|
||||
patterns=None, generator_class=SchemaGenerator):
|
||||
docs_view = get_docs_view(
|
||||
title=title,
|
||||
description=description,
|
||||
schema_url=schema_url,
|
||||
public=public,
|
||||
patterns=patterns,
|
||||
generator_class=generator_class,
|
||||
)
|
||||
schema_js_view = get_schemajs_view(
|
||||
title=title,
|
||||
|
@ -46,6 +55,7 @@ def include_docs_urls(title=None, description=None, schema_url=None, public=True
|
|||
schema_url=schema_url,
|
||||
public=public,
|
||||
patterns=patterns,
|
||||
generator_class=generator_class,
|
||||
)
|
||||
urls = [
|
||||
url(r'^$', docs_view, name='docs-index'),
|
||||
|
|
|
@ -316,6 +316,7 @@ class DefaultRouter(SimpleRouter):
|
|||
default_schema_renderers = None
|
||||
APIRootView = APIRootView
|
||||
APISchemaView = SchemaView
|
||||
SchemaGenerator = SchemaGenerator
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if 'schema_title' in kwargs:
|
||||
|
@ -342,7 +343,7 @@ class DefaultRouter(SimpleRouter):
|
|||
"""
|
||||
Return a schema root view.
|
||||
"""
|
||||
schema_generator = SchemaGenerator(
|
||||
schema_generator = self.SchemaGenerator(
|
||||
title=self.schema_title,
|
||||
url=self.schema_url,
|
||||
patterns=api_urls
|
||||
|
|
|
@ -695,12 +695,15 @@ class SchemaView(APIView):
|
|||
|
||||
|
||||
def get_schema_view(
|
||||
title=None, url=None, description=None, urlconf=None,
|
||||
renderer_classes=None, public=False, patterns=None):
|
||||
title=None, url=None, description=None, urlconf=None, renderer_classes=None,
|
||||
public=False, patterns=None, generator_class=SchemaGenerator):
|
||||
"""
|
||||
Return a schema view.
|
||||
"""
|
||||
generator = SchemaGenerator(title=title, url=url, description=description, urlconf=urlconf, patterns=patterns)
|
||||
generator = generator_class(
|
||||
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