Debian Codegraph @

docs/community/3.6-announcement.md

raw ◀ ▶
1 Debian patch touch this file
1 <style>
2 .promo li a {
3 float: left;
4 width: 130px;
5 height: 20px;
6 text-align: center;
7 margin: 10px 30px;
8 padding: 150px 0 0 0;
9 background-position: 0 50%;
10 background-size: 130px auto;
11 background-repeat: no-repeat;
12 font-size: 120%;
13 color: black;
14 }
15 .promo li {
16 list-style: none;
17 }
18 </style>
19
20 # Django REST framework 3.6
21
22 The 3.6 release adds two major new features to REST framework.
23
24 1. Built-in interactive API documentation support.
25 2. A new JavaScript client&nbsp;library.
26
27 ![API Documentation](/img/api-docs.gif)
28
29 *Above: The interactive API documentation.*
30
31 ---
32
33 ## Funding
34
35 The 3.6 release would not have been possible without our [backing from Mozilla](mozilla-grant.md) to the project, and our [collaborative funding&nbsp;model][funding].
36
37 If you use REST framework commercially and would like to see this work continue,
38 we strongly encourage you to invest in its continued development by
39 **[signing up for a paid&nbsp;plan][funding]**.
40
41 *Many thanks to all our [sponsors][sponsors], and in particular to our premium backers, [Rover](https://www.rover.com/careers/), [Sentry](https://sentry.io/welcome/), [Stream](https://getstream.io/?utm_source=drf&utm_medium=banner&utm_campaign=drf), [Machinalis](https://machinalis.com/), [Rollbar](https://rollbar.com), and [MicroPyramid](https://micropyramid.com/django-rest-framework-development-services/).*
42
43 ---
44
45 ## Interactive API documentation
46
47 REST framework's new API documentation supports a number of features:
48
49 * Live API interaction.
50 * Support for various authentication schemes.
51 * Code snippets for the Python, JavaScript, and Command Line clients.
52
53 The `coreapi` library is required as a dependency for the API docs. Make sure
54 to install the latest version (2.3.0 or above). The `pygments` and `markdown`
55 libraries are optional but recommended.
56
57 To install the API documentation, you'll need to include it in your projects URLconf:
58
59 from rest_framework.documentation import include_docs_urls
60
61 API_TITLE = 'API title'
62 API_DESCRIPTION = '...'
63
64 urlpatterns = [
65 ...
66 path('docs/', include_docs_urls(title=API_TITLE, description=API_DESCRIPTION))
67 ]
68
69 Once installed you should see something a little like this:
70
71 ![API Documentation](/img/api-docs.png)
72
73 We'll likely be making further refinements to the API documentation over the
74 coming weeks. Keep in mind that this is a new feature, and please do give
75 us feedback if you run into any issues or limitations.
76
77 For more information on documenting your API endpoints see the ["Documenting your API"][api-docs] section.
78
79 ---
80
81 ## JavaScript client library
82
83 The JavaScript client library allows you to load an API schema, and then interact
84 with that API at an application layer interface, rather than constructing fetch
85 requests explicitly.
86
87 Here's a brief example that demonstrates:
88
89 * Loading the client library and schema.
90 * Instantiating an authenticated client.
91 * Making an API request using the client.
92
93 **index.html**
94
95 <html>
96 <head>
97 <script src="/static/rest_framework/js/coreapi-0.1.0.js"></script>
98 <script src="/docs/schema.js"></script>
99 <script>
100 const coreapi = window.coreapi
101 const schema = window.schema
102
103 // Instantiate a client...
104 let auth = coreapi.auth.TokenAuthentication({scheme: 'JWT', token: 'xxx'})
105 let client = coreapi.Client({auth: auth})
106
107 // Make an API request...
108 client.action(schema, ['projects', 'list']).then(function(result) {
109 alert(result)
110 })
111 </script>
112 </head>
113 </html>
114
115 The JavaScript client library supports various authentication schemes, and can be
116 used by your project itself, or as an external client interacting with your API.
117
118 The client is not limited to usage with REST framework APIs, although it does
119 currently only support loading CoreJSON API schemas. Support for Swagger and
120 other API schemas is planned.
121
122 For more details see the [JavaScript client library documentation][js-docs].
123
124 ## Authentication classes for the Python client library
125
126 Previous authentication support in the Python client library was limited to
127 allowing users to provide explicit header values.
128
129 We now have better support for handling the details of authentication, with
130 the introduction of the `BasicAuthentication`, `TokenAuthentication`, and
131 `SessionAuthentication` schemes.
132
133 You can include the authentication scheme when instantiating a new client.
134
135 auth = coreapi.auth.TokenAuthentication(scheme='JWT', token='xxx-xxx-xxx')
136 client = coreapi.Client(auth=auth)
137
138 For more information see the [Python client library documentation][py-docs].
139
140 ---
141
142 ## Deprecations
143
144 ### Updating coreapi
145
146 If you're using REST framework's schema generation, or want to use the API docs,
147 then you'll need to update to the latest version of coreapi. (2.3.0)
148
149 ### Generating schemas from Router
150
151 The 3.5 "pending deprecation" of router arguments for generating a schema view, such as `schema_title`, `schema_url` and `schema_renderers`, have now been escalated to a
152 "deprecated" warning.
153
154 Instead of using `DefaultRouter(schema_title='Example API')`, you should use the `get_schema_view()` function, and include the view explicitly in your URL conf.
155
156 ### DjangoFilterBackend
157
158 The 3.5 "pending deprecation" warning of the built-in `DjangoFilterBackend` has now
159 been escalated to a "deprecated" warning.
160
161 You should change your imports and REST framework filter settings as follows:
162
163 * `rest_framework.filters.DjangoFilterBackend` becomes `django_filters.rest_framework.DjangoFilterBackend`.
164 * `rest_framework.filters.FilterSet` becomes `django_filters.rest_framework.FilterSet`.
165
166 ---
167
168 ## What's next
169
170 There are likely to be a number of refinements to the API documentation and
171 JavaScript client library over the coming weeks, which could include some of the following:
172
173 * Support for private API docs, requiring login.
174 * File upload and download support in the JavaScript client & API docs.
175 * Comprehensive documentation for the JavaScript client library.
176 * Automatically including authentication details in the API doc code snippets.
177 * Adding authentication support in the command line client.
178 * Support for loading Swagger and other schemas in the JavaScript client.
179 * Improved support for documenting parameter schemas and response schemas.
180 * Refining the API documentation interaction modal.
181
182 Once work on those refinements is complete, we'll be starting feature work
183 on realtime support, for the 3.7 release.
184
185 [sponsors]: https://fund.django-rest-framework.org/topics/funding/#our-sponsors
186 [funding]: https://opencollective.com/django-rest-framework
187 [api-docs]: ../topics/documenting-your-api.md
188 [js-docs]: https://github.com/encode/django-rest-framework/blob/3.14.0/docs/topics/api-clients.md#javascript-client-library
189 [py-docs]: https://github.com/encode/django-rest-framework/blob/3.14.0/docs/topics/api-clients.md#python-client-library