From e70b920d2e6bfc2dd5c6eb7917c33e315c719287 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Sun, 9 Apr 2017 22:21:42 +0200 Subject: [PATCH 1/5] Bumped django-guardian version. --- docs/index.md | 2 +- requirements/requirements-optionals.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 4883f0505..306e4f782 100644 --- a/docs/index.md +++ b/docs/index.md @@ -310,7 +310,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [markdown]: http://pypi.python.org/pypi/Markdown/ [django-filter]: http://pypi.python.org/pypi/django-filter [django-crispy-forms]: https://github.com/maraujop/django-crispy-forms -[django-guardian]: https://github.com/lukaszb/django-guardian +[django-guardian]: https://github.com/django-guardian/django-guardian [0.4]: https://github.com/encode/django-rest-framework/tree/0.4.X [image]: img/quickstart.png [index]: . diff --git a/requirements/requirements-optionals.txt b/requirements/requirements-optionals.txt index c4882fead..5a0eb9cb2 100644 --- a/requirements/requirements-optionals.txt +++ b/requirements/requirements-optionals.txt @@ -1,6 +1,6 @@ # Optional packages which may be used with REST framework. markdown==2.6.4 -django-guardian==1.4.6 +django-guardian==1.4.8 django-filter==1.0.0 coreapi==2.2.4 coreschema==0.0.4 From 613aa61adad5459f1ba304ecda25de10e404ce86 Mon Sep 17 00:00:00 2001 From: Azim Khakulov Date: Wed, 12 Apr 2017 12:25:27 +0200 Subject: [PATCH 2/5] Clarify get_schema_fields signature I had to look for the signature of `get_schema_fields()`in source code. --- docs/api-guide/filtering.md | 7 +++++-- docs/api-guide/pagination.md | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/api-guide/filtering.md b/docs/api-guide/filtering.md index bc1cc710d..461f3c5ba 100644 --- a/docs/api-guide/filtering.md +++ b/docs/api-guide/filtering.md @@ -432,8 +432,11 @@ The method should return a rendered HTML string. ## Pagination & schemas You can also make the filter controls available to the schema autogeneration -that REST framework provides, by implementing a `get_schema_fields()` method, -which should return a list of `coreapi.Field` instances. +that REST framework provides, by implementing a `get_schema_fields()` method. This method should have the following signature: + +`get_schema_fields(self, view)` + +The method should return a list of `coreapi.Field` instances. # Third party packages diff --git a/docs/api-guide/pagination.md b/docs/api-guide/pagination.md index bc7a5602d..888390018 100644 --- a/docs/api-guide/pagination.md +++ b/docs/api-guide/pagination.md @@ -279,8 +279,11 @@ API responses for list endpoints will now include a `Link` header, instead of in ## Pagination & schemas You can also make the pagination controls available to the schema autogeneration -that REST framework provides, by implementing a `get_schema_fields()` method, -which should return a list of `coreapi.Field` instances. +that REST framework provides, by implementing a `get_schema_fields()` method. This method should have the following signature: + +`get_schema_fields(self, view)` + +The method should return a list of `coreapi.Field` instances. --- From 34f88dc3f8c3a03e4e02537d519636d66f9a9cfd Mon Sep 17 00:00:00 2001 From: Sergey Smirnov Date: Mon, 17 Apr 2017 19:42:50 +0200 Subject: [PATCH 3/5] Add Django 1.11 into *.md and setup.py --- README.md | 2 +- docs/index.md | 2 +- setup.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0056af58d..02a20aff2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/index.md b/docs/index.md index 306e4f782..9bf36cce7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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: diff --git a/setup.py b/setup.py index 5d14ddf6a..36227938b 100755 --- a/setup.py +++ b/setup.py @@ -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', From 51a6c076e27931c89a37d76301975e7e548e3324 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Tue, 18 Apr 2017 13:44:43 +0300 Subject: [PATCH 4/5] Allow customizing the SchemaGenerator class for docs --- rest_framework/documentation.py | 20 ++++++++++++-------- rest_framework/schemas.py | 12 ++++++++++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/rest_framework/documentation.py b/rest_framework/documentation.py index 3a56b7cb1..a95259ddc 100644 --- a/rest_framework/documentation.py +++ b/rest_framework/documentation.py @@ -3,10 +3,10 @@ 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): +def get_docs_view(title=None, description=None, schema_url=None, public=True, generator_class=SchemaGenerator): renderer_classes = [DocumentationRenderer, CoreJSONRenderer] return get_schema_view( @@ -14,11 +14,12 @@ def get_docs_view(title=None, description=None, schema_url=None, public=True): url=schema_url, description=description, renderer_classes=renderer_classes, - public=public + public=public, + generator_class=generator_class, ) -def get_schemajs_view(title=None, description=None, schema_url=None, public=True): +def get_schemajs_view(title=None, description=None, schema_url=None, public=True, generator_class=SchemaGenerator): renderer_classes = [SchemaJSRenderer] return get_schema_view( @@ -26,22 +27,25 @@ def get_schemajs_view(title=None, description=None, schema_url=None, public=True url=schema_url, description=description, renderer_classes=renderer_classes, - public=public + public=public, + generator_class=generator_class, ) -def include_docs_urls(title=None, description=None, schema_url=None, public=True): +def include_docs_urls(title=None, description=None, schema_url=None, public=True, generator_class=SchemaGenerator): docs_view = get_docs_view( title=title, description=description, schema_url=schema_url, - public=public + public=public, + generator_class=generator_class, ) schema_js_view = get_schemajs_view( title=title, description=description, schema_url=schema_url, - public=public + public=public, + generator_class=generator_class, ) urls = [ url(r'^$', docs_view, name='docs-index'), diff --git a/rest_framework/schemas.py b/rest_framework/schemas.py index ec6d7f3c3..859a6c9bd 100644 --- a/rest_framework/schemas.py +++ b/rest_framework/schemas.py @@ -694,11 +694,19 @@ class SchemaView(APIView): return Response(schema) -def get_schema_view(title=None, url=None, description=None, urlconf=None, renderer_classes=None, public=False): +def get_schema_view( + title=None, + url=None, + description=None, + urlconf=None, + renderer_classes=None, + public=False, + generator_class=SchemaGenerator, +): """ Return a schema view. """ - generator = SchemaGenerator(title=title, url=url, description=description, urlconf=urlconf) + generator = generator_class(title=title, url=url, description=description, urlconf=urlconf) return SchemaView.as_view( renderer_classes=renderer_classes, schema_generator=generator, From 53f48d15641573eec189aa1102a4735206149d44 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Tue, 18 Apr 2017 13:46:47 +0300 Subject: [PATCH 5/5] Allow customizing DefaultRouter's schema generator class --- rest_framework/routers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rest_framework/routers.py b/rest_framework/routers.py index 3d2649727..fce968aa0 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -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