mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 13:00:12 +03:00
Merge branch 'master' into localizedfloatfield
This commit is contained in:
commit
377279816b
|
@ -54,7 +54,7 @@ There is a live example API for testing purposes, [available here][sandbox].
|
||||||
# Requirements
|
# Requirements
|
||||||
|
|
||||||
* Python (2.7, 3.2, 3.3, 3.4, 3.5)
|
* 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
|
# Installation
|
||||||
|
|
||||||
|
|
|
@ -432,8 +432,11 @@ The method should return a rendered HTML string.
|
||||||
## Pagination & schemas
|
## Pagination & schemas
|
||||||
|
|
||||||
You can also make the filter controls available to the schema autogeneration
|
You can also make the filter controls available to the schema autogeneration
|
||||||
that REST framework provides, by implementing a `get_schema_fields()` method,
|
that REST framework provides, by implementing a `get_schema_fields()` method. This method should have the following signature:
|
||||||
which should return a list of `coreapi.Field` instances.
|
|
||||||
|
`get_schema_fields(self, view)`
|
||||||
|
|
||||||
|
The method should return a list of `coreapi.Field` instances.
|
||||||
|
|
||||||
# Third party packages
|
# Third party packages
|
||||||
|
|
||||||
|
|
|
@ -279,8 +279,11 @@ API responses for list endpoints will now include a `Link` header, instead of in
|
||||||
## Pagination & schemas
|
## Pagination & schemas
|
||||||
|
|
||||||
You can also make the pagination controls available to the schema autogeneration
|
You can also make the pagination controls available to the schema autogeneration
|
||||||
that REST framework provides, by implementing a `get_schema_fields()` method,
|
that REST framework provides, by implementing a `get_schema_fields()` method. This method should have the following signature:
|
||||||
which should return a list of `coreapi.Field` instances.
|
|
||||||
|
`get_schema_fields(self, view)`
|
||||||
|
|
||||||
|
The method should return a list of `coreapi.Field` instances.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ continued development by **[signing up for a paid plan][funding]**.
|
||||||
REST framework requires the following:
|
REST framework requires the following:
|
||||||
|
|
||||||
* Python (2.7, 3.2, 3.3, 3.4, 3.5)
|
* 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:
|
The following packages are optional:
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
[markdown]: http://pypi.python.org/pypi/Markdown/
|
[markdown]: http://pypi.python.org/pypi/Markdown/
|
||||||
[django-filter]: http://pypi.python.org/pypi/django-filter
|
[django-filter]: http://pypi.python.org/pypi/django-filter
|
||||||
[django-crispy-forms]: https://github.com/maraujop/django-crispy-forms
|
[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
|
[0.4]: https://github.com/encode/django-rest-framework/tree/0.4.X
|
||||||
[image]: img/quickstart.png
|
[image]: img/quickstart.png
|
||||||
[index]: .
|
[index]: .
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Optional packages which may be used with REST framework.
|
# Optional packages which may be used with REST framework.
|
||||||
markdown==2.6.4
|
markdown==2.6.4
|
||||||
django-guardian==1.4.6
|
django-guardian==1.4.8
|
||||||
django-filter==1.0.0
|
django-filter==1.0.0
|
||||||
coreapi==2.2.4
|
coreapi==2.2.4
|
||||||
coreschema==0.0.4
|
coreschema==0.0.4
|
||||||
|
|
|
@ -3,10 +3,10 @@ from django.conf.urls import include, url
|
||||||
from rest_framework.renderers import (
|
from rest_framework.renderers import (
|
||||||
CoreJSONRenderer, DocumentationRenderer, SchemaJSRenderer
|
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]
|
renderer_classes = [DocumentationRenderer, CoreJSONRenderer]
|
||||||
|
|
||||||
return get_schema_view(
|
return get_schema_view(
|
||||||
|
@ -14,11 +14,12 @@ def get_docs_view(title=None, description=None, schema_url=None, public=True):
|
||||||
url=schema_url,
|
url=schema_url,
|
||||||
description=description,
|
description=description,
|
||||||
renderer_classes=renderer_classes,
|
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]
|
renderer_classes = [SchemaJSRenderer]
|
||||||
|
|
||||||
return get_schema_view(
|
return get_schema_view(
|
||||||
|
@ -26,22 +27,25 @@ def get_schemajs_view(title=None, description=None, schema_url=None, public=True
|
||||||
url=schema_url,
|
url=schema_url,
|
||||||
description=description,
|
description=description,
|
||||||
renderer_classes=renderer_classes,
|
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(
|
docs_view = get_docs_view(
|
||||||
title=title,
|
title=title,
|
||||||
description=description,
|
description=description,
|
||||||
schema_url=schema_url,
|
schema_url=schema_url,
|
||||||
public=public
|
public=public,
|
||||||
|
generator_class=generator_class,
|
||||||
)
|
)
|
||||||
schema_js_view = get_schemajs_view(
|
schema_js_view = get_schemajs_view(
|
||||||
title=title,
|
title=title,
|
||||||
description=description,
|
description=description,
|
||||||
schema_url=schema_url,
|
schema_url=schema_url,
|
||||||
public=public
|
public=public,
|
||||||
|
generator_class=generator_class,
|
||||||
)
|
)
|
||||||
urls = [
|
urls = [
|
||||||
url(r'^$', docs_view, name='docs-index'),
|
url(r'^$', docs_view, name='docs-index'),
|
||||||
|
|
|
@ -316,6 +316,7 @@ class DefaultRouter(SimpleRouter):
|
||||||
default_schema_renderers = None
|
default_schema_renderers = None
|
||||||
APIRootView = APIRootView
|
APIRootView = APIRootView
|
||||||
APISchemaView = SchemaView
|
APISchemaView = SchemaView
|
||||||
|
SchemaGenerator = SchemaGenerator
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if 'schema_title' in kwargs:
|
if 'schema_title' in kwargs:
|
||||||
|
@ -342,7 +343,7 @@ class DefaultRouter(SimpleRouter):
|
||||||
"""
|
"""
|
||||||
Return a schema root view.
|
Return a schema root view.
|
||||||
"""
|
"""
|
||||||
schema_generator = SchemaGenerator(
|
schema_generator = self.SchemaGenerator(
|
||||||
title=self.schema_title,
|
title=self.schema_title,
|
||||||
url=self.schema_url,
|
url=self.schema_url,
|
||||||
patterns=api_urls
|
patterns=api_urls
|
||||||
|
|
|
@ -694,11 +694,19 @@ class SchemaView(APIView):
|
||||||
return Response(schema)
|
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.
|
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(
|
return SchemaView.as_view(
|
||||||
renderer_classes=renderer_classes,
|
renderer_classes=renderer_classes,
|
||||||
schema_generator=generator,
|
schema_generator=generator,
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -95,6 +95,7 @@ setup(
|
||||||
'Framework :: Django :: 1.8',
|
'Framework :: Django :: 1.8',
|
||||||
'Framework :: Django :: 1.9',
|
'Framework :: Django :: 1.9',
|
||||||
'Framework :: Django :: 1.10',
|
'Framework :: Django :: 1.10',
|
||||||
|
'Framework :: Django :: 1.11',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'License :: OSI Approved :: BSD License',
|
'License :: OSI Approved :: BSD License',
|
||||||
'Operating System :: OS Independent',
|
'Operating System :: OS Independent',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user