Skip to content

Document how to override DRF generateschema generator_class. #1084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ any parts of the framework not mentioned in the documentation should generally b
* Added support for Django 4.1.
* Expanded JSONParser API with `parse_data` method

### Changed

* Improved documentation of how to override DRF's generateschema `--generator_class` to generate a proper DJA OAS schema.

### Removed

* Removed support for Django 2.2.
Expand Down
5 changes: 2 additions & 3 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -1085,11 +1085,10 @@ class MySchemaGenerator(JSONAPISchemaGenerator):
### Generate a Static Schema on Command Line

See [DRF documentation for generateschema](https://www.django-rest-framework.org/api-guide/schemas/#generating-a-static-schema-with-the-generateschema-management-command)
To generate an OAS schema document, use something like:
To generate a static OAS schema document, using the `generateschema` management command, you **must override DRF's default** `generator_class` with the DJA-specific version:

```text
$ django-admin generateschema --settings=example.settings \
--generator_class myapp.views.MySchemaGenerator >myschema.yaml
$ ./manage.py generateschema --generator_class rest_framework_json_api.schemas.openapi.SchemaGenerator
```

You can then use any number of OAS tools such as
Expand Down