Update 3.10 release docs

This commit is contained in:
Tom Christie 2019-07-15 11:50:06 +01:00
parent b239a1becd
commit e60dd2ba43

View File

@ -1,18 +1,45 @@
# Django REST framework 3.10 # Django REST framework 3.10
## Python 3 Only.
* Reworked OpenAPI schema generation. The 3.10 release is our first to drop support for Python 2.
* Python 3 only.
Our supported Python versions are currently 3.5, 3.6, and 3.7.
Our support Django versions are currently 1.11, 2.0, 2.1, and 2.2.
## OpenAPI Schema Generation. ## OpenAPI Schema Generation.
Since we first introduced schema support in Django REST Framework 3.5, OpenAPI has emerged as the widely adopted standard for modelling Web APIs. Since we first introduced schema support in Django REST Framework 3.5, OpenAPI has emerged as the widely adopted standard for modeling Web APIs.
This release deprecates the old CoreAPI based schema generation, and introduces improved OpenAPI schema generation in its place. This release begins the deprecation process for the CoreAPI based schema generation, and introduces OpenAPI schema generation in its place.
---- ---
## Continuing to use CoreAPI
If you're currently using the CoreAPI schemas, you'll need to make sure to
update your REST framework settings to include `DEFAULT_SCHEMA_CLASS` explicitly.
**settings.py**:
```python
REST_FRAMEWORK = {
...
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
}
```
You'll still be able to keep using CoreAPI schemas, API docs, and client for the
foreseeable future. We'll aim to ensure that the CoreAPI schema generator remains
available as a third party package, even once it has eventually been removed
from REST framework, scheduled for version 3.12.
We have removed the old documentation for the CoreAPI based schema generation.
You may view the [Legacy CoreAPI documentation here][legacy-core-api-docs].
---
**Switching mode between `CoreAPI` and `OpenAPI`** **Switching mode between `CoreAPI` and `OpenAPI`**
@ -40,9 +67,13 @@ REST_FRAMEWORK = {
---- ----
### Quickstart ## Quickstart
To get going with `OpenAPI` schemas, use the `get_schema_view()` shortcut. You can generate a static OpenAPI schema, using the `generateschema` management
command.
Alternately, to have the project serve an API schema, use the `get_schema_view()`
shortcut.
In your `urls.py`: In your `urls.py`:
@ -62,43 +93,41 @@ urlpatterns = [
] ]
``` ```
See the Schemas documentation for more details. ### Customization
### Feature Roadmap For customizations that you want to apply across the the entire API, you can subclass `rest_framework.schemas.openapi.SchemaGenerator` and provide it as an argument
to the `generateschema` command or `get_schema_view()` helper function.
For v3.7 (with `CoreAPI`) we tried to anticipate customizations that people For specific per-view customizations, you can subclass `AutoSchema`,
were likely to need. (Introducing `manual_fields` and `ManaualSchema`, for making sure to set `schema = <YourCustomClass>` on the view.
example.) These were under-utilised. They weren't the right abstractions.
So, for a fresh start with `OpenAPI`, customizing schema generation has two For more details, see the [API Schema documentation](../api-guide/schemas.md).
simple rules:
* Subclass `SchemaGenerator` for schema-level cusomizations. ### API Documentation
* Subclass `AutoSchema` for view-level customizations.
We'll wait to see what subclasses people actually come up with, for the There are some great third party options for documenting your API, based on the
customizations they actually need, before trying to bring that back into the OpenAPI schema.
core framework.
There are two kinds of changes that easily predictable: See the [Documenting you API](../topics/documenting-your-api.md) section for more details.
* General improvements which fill in gaps in the automatic schema generation. ---
* More use-case specific adjustments, which adjust the API of `SchemaGenerator`
or `AutoSchema` ## Feature Roadmap
Given that our OpenAPI schema generation is a new feature, it's likely that there
will still be some iterative improvements for us to make. There will be two
main cases here:
* Expanding the supported range of OpenAPI schemas that are generated by default.
* Improving the ability for developers to customize the output.
We'll aim to bring the first type of change quickly in point releases. For the We'll aim to bring the first type of change quickly in point releases. For the
second kind we'd like to adopt a slower approach, to make sure we keep the API second kind we'd like to adopt a slower approach, to make sure we keep the API
simple, and as widely applicable as possible, before we bring in API changes. simple, and as widely applicable as possible, before we bring in API changes.
We trust that approach makes sense. It's also possible that we'll end up implementing API documentation and API client
tooling that are driven by the OpenAPI schema. The `apistar` project has a
### Deprecating CoreAPI Schema Generation. significant amount of work towards this. However, if we do so, we'll plan
on keeping any tooling outside of the core framework.
The in-built docs that were introduced in Django REST Framework v3.5 were built on CoreAPI. These are now deprecated. You may continue to use them but they will be **removed in Django REST Framework v 3.12**.
You should migrate to using the new OpenAPI based schema generation as soon as you can.
We have removed the old documentation for the CoreAPI based schema generation.
You may view the [Legacy CoreAPI documentation here][legacy-core-api-docs].
[legacy-core-api-docs]:https://github.com/encode/django-rest-framework/blob/master/docs/coreapi/index.md [legacy-core-api-docs]:https://github.com/encode/django-rest-framework/blob/master/docs/coreapi/index.md