Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4ceee03

Browse files
authored
Deprecated built-in support for OpenAPI schema generation (#1253)
1 parent 5123a26 commit 4ceee03

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

‎CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ any parts of the framework not mentioned in the documentation should generally b
2020

2121
* Added support for Django 5.1
2222

23+
### Deprecated
24+
25+
* Deprecated built-in support for generating OpenAPI schema. Use [drf-spectacular-json-api](https://github.com/jokiefer/drf-spectacular-json-api/) instead.
26+
2327
## [7.0.2] - 2024年06月28日
2428

2529
### Fixed

‎docs/usage.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ REST_FRAMEWORK = {
3131
'rest_framework_json_api.renderers.BrowsableAPIRenderer'
3232
),
3333
'DEFAULT_METADATA_CLASS': 'rest_framework_json_api.metadata.JSONAPIMetadata',
34-
'DEFAULT_SCHEMA_CLASS': 'rest_framework_json_api.schemas.openapi.AutoSchema',
3534
'DEFAULT_FILTER_BACKENDS': (
3635
'rest_framework_json_api.filters.QueryParameterValidationFilter',
3736
'rest_framework_json_api.filters.OrderingFilter',
@@ -1062,6 +1061,20 @@ DRF has a [OAS schema functionality](https://www.django-rest-framework.org/api-g
10621061

10631062
DJA extends DRF's schema support to generate an OAS schema in the JSON:API format.
10641063

1064+
---
1065+
1066+
**Deprecation notice:**
1067+
1068+
REST framework's built-in support for generating OpenAPI schemas is
1069+
**deprecated** in favor of 3rd party packages that can provide this
1070+
functionality instead. Therefore we have also deprecated the schema support in
1071+
Django REST framework JSON:API. The built-in support will be retired over the
1072+
next releases.
1073+
1074+
As a full-fledged replacement, we recommend the [drf-spectacular-json-api] package.
1075+
1076+
---
1077+
10651078
### AutoSchema Settings
10661079

10671080
In order to produce an OAS schema that properly represents the JSON:API structure
@@ -1187,3 +1200,8 @@ We aim to make creating third party packages as easy as possible, whilst keeping
11871200
To submit new content, [open an issue](https://github.com/django-json-api/django-rest-framework-json-api/issues/new/choose) or [create a pull request](https://github.com/django-json-api/django-rest-framework-json-api/compare).
11881201

11891202
* [drf-yasg-json-api](https://github.com/glowka/drf-yasg-json-api) - Automated generation of Swagger/OpenAPI 2.0 from Django REST framework JSON:API endpoints.
1203+
* [drf-spectacular-json-api] - OpenAPI 3 schema generator for Django REST framework JSON:API based on drf-spectacular.
1204+
1205+
1206+
1207+
[drf-spectacular-json-api]: https://github.com/jokiefer/drf-spectacular-json-api/

‎example/tests/test_openapi.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# largely based on DRF's test_openapi
22
import json
33

4+
import pytest
45
from django.test import RequestFactory, override_settings
56
from django.urls import re_path
67
from rest_framework.request import Request
@@ -9,6 +10,8 @@
910

1011
from example import views
1112

13+
pytestmark = pytest.mark.filterwarnings("ignore:Built-in support")
14+
1215

1316
def create_request(path):
1417
factory = RequestFactory()

‎rest_framework_json_api/schemas/openapi.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,16 @@ def get_operation(self, path, method):
423423
- collections
424424
- special handling for POST, PATCH, DELETE
425425
"""
426+
427+
warnings.warn(
428+
DeprecationWarning(
429+
"Built-in support for generating OpenAPI schema is deprecated. "
430+
"Use drf-spectacular-json-api instead see "
431+
"https://github.com/jokiefer/drf-spectacular-json-api/"
432+
),
433+
stacklevel=2,
434+
)
435+
426436
operation = {}
427437
operation["operationId"] = self.get_operation_id(path, method)
428438
operation["description"] = self.get_description(path, method)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /