Skip to content

Commit 4f4f26d

Browse files
committed
[OpenAPI] - Update Usage
1 parent 2bdbb23 commit 4f4f26d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/usage.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,26 @@ class MyViewSet(ModelViewSet):
954954
schema = AutoSchema(openapi_schema=openapi_schema)
955955
```
956956

957+
### Get Schema in View
958+
959+
Add the following to `urls.py`, to expose the schema at `/openapi`. This can be consumed by (Swagger UI)[https://swagger.io/tools/swagger-ui/] or other tools.
960+
```python
961+
from rest_framework.schemas import get_schema_view
962+
from rest_framework_json_api.schemas.openapi import SchemaGenerator
963+
964+
...
965+
966+
urlpatterns = [
967+
path('openapi', get_schema_view(
968+
title="Example API",
969+
description="API for all things …",
970+
version="1.0.0",
971+
generator_class=SchemaGenerator
972+
), name='openapi-schema'),
973+
...
974+
]
975+
```
976+
### Get Schema on Command Line
957977
To generate an OAS schema document, use something like:
958978

959979
```text

0 commit comments

Comments
 (0)