Skip to content

Commit fe1e877

Browse files
committed
Add link to old Tutorial 7 from CoreAPI index page.
1 parent 1d3a3ee commit fe1e877

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

docs/api-guide/schemas.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Schema
2+
3+
## Generating an OpenAPI Schema
4+
5+
### Static
6+
7+
If your schema is static, you can use the `generateschema` management command:
8+
9+
```bash
10+
./manage.py generateschema > openapi-schema.yml
11+
```
12+
13+
### Dynamic
14+
15+
If you require a dynamic schema, because foreign key choices depend on database values, for example, you can route a `SchemaView` that will generate and serve you schema on demand.
16+
17+
In `urls.py`:
18+
19+
```python
20+
from rest_framework.schemas import get_schema_view()
21+
22+
urlpatterns = [
23+
# ...
24+
# Use the `get_schema_view()` helper to add a `SchemaView` to project URLs.
25+
# * `title` and `description` parameters are passed to `SchemaGenerator`.
26+
# * Provide view name for use with `reverse()`.
27+
path('openapi', get_schema_view(
28+
title="Your Project",
29+
description="API for all things …"
30+
), name='openapi-schema'),
31+
# ...
32+
]
33+
```
34+
35+
#### `get_schema_view()`
36+
37+
* ...
38+
39+
* ...
40+
41+
* ...
42+
43+
44+
45+
## Customizing Schema Generation
46+
47+
### Schema Level Customization
48+
49+
### Per-View Customization
50+
51+
* Subclass `rest_framework.schemas.openapi.AutoSchema`.
52+
* Override `get_operations()`.

docs/coreapi/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ All CoreAPI related code will be removed in Django REST Framework v3.12. Switch
2424

2525
For reference this folder contains the old CoreAPI related documentation:
2626

27+
* [Tutorial 7: Schemas & client libraries](/coreapi/7-schemas-and-client-libraries.md).
2728
* [Excerpts from _Documenting your API_ topic page](/coreapi/from-documenting-your-api.md).
2829
* [`rest_framework.schemas` API Reference](/coreapi/schemas.md).
29-
* [Tutorial 7: Schemas & client libraries](/coreapi/7-schemas-and-client-libraries.md)

0 commit comments

Comments
 (0)