Merge master.

This commit is contained in:
Xavier Ordoquy 2017-04-19 07:56:39 +02:00
commit 778aee1bb3
6 changed files with 25 additions and 10 deletions

View File

@ -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

View File

@ -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:

View File

@ -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'),

View File

@ -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

View File

@ -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,

View File

@ -95,6 +95,7 @@ setup(
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',