You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/community/3.9-announcement.md
+77-10Lines changed: 77 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -29,12 +29,71 @@ If you use REST framework commercially and would like to see this work continue,
29
29
**[signing up for a paid plan][funding]**.
30
30
31
31
32
-
TODO: UPDATE SPONSORS.
33
-
34
-
*We'd like to say thanks in particular our premium backers, [Rover](http://jobs.rover.com/), [Sentry](https://getsentry.com/welcome/), [Stream](https://getstream.io/?utm_source=drf&utm_medium=banner&utm_campaign=drf), [Machinalis](https://hello.machinalis.co.uk/), and [Rollbar](https://rollbar.com).*
*Many thanks to all our [wonderful sponsors][sponsors], and in particular to our premium backers, [Rover](http://jobs.rover.com/), [Sentry](https://getsentry.com/welcome/), [Stream](https://getstream.io/?utm_source=drf&utm_medium=banner&utm_campaign=drf), [Auklet](https://auklet.io/), [Rollbar](https://rollbar.com), [Cadre](https://cadre.com), [Load Impact](https://loadimpact.com/?utm_campaign=Sponsorship%20links&utm_source=drf&utm_medium=drf), and [Kloudless](https://hubs.ly/H0f30Lf0).*
35
45
36
46
---
37
47
48
+
## In-built OpenAPI schema support
49
+
50
+
REST framework now has a first-pass at directly including OpenAPI schema support.
51
+
52
+
Specifically:
53
+
54
+
* There are now `OpenAPIRenderer`, and `JSONOpenAPIRenderer` classes that deal with encoding `coreapi.Document` instances into OpenAPI YAML or OpenAPI JSON.
55
+
* The `get_schema_view(...)` method now defaults to OpenAPI YAML, with CoreJSON as a secondary
56
+
option if it is selected via HTTP content negotiation.
57
+
* There is a new management command `generateschema`, which you can use to dump
58
+
the schema into your repository.
59
+
60
+
Here's an example of adding an OpenAPI schema to the URL conf:
61
+
62
+
```python
63
+
from rest_framework.schemas import get_schema_view
64
+
from rest_framework.renderers import JSONOpenAPIRenderer
65
+
66
+
schema_view = get_schema_view(
67
+
title='Server Monitoring API',
68
+
url='https://www.example.org/api/',
69
+
renderer_classes=[JSONOpenAPIRenderer]
70
+
)
71
+
72
+
urlpatterns = [
73
+
url('^schema.json$', schema_view),
74
+
...
75
+
]
76
+
```
77
+
78
+
And here's how you can use the `generateschema` management command:
0 commit comments