Skip to content

Commit

Permalink
Update to drf-spectacular==0.26.5
Browse files Browse the repository at this point in the history
Latest version without too much breaking changes
Fix `AutoSchema` subclass
Regenerate schemas
Add regression test
  • Loading branch information
Viicos committed Apr 9, 2024
1 parent a8ffb23 commit a23e004
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 5 deletions.
3 changes: 2 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ django==4.2.11
# django-relativedelta
# django-rest-framework-condition
# django-rosetta
# django-sendfile2
# django-simple-certmanager
# django-solo
# django-two-factor-auth
Expand Down Expand Up @@ -152,7 +153,7 @@ drf-nested-routers==0.93.4
# via
# -r requirements/base.in
# commonground-api-common
drf-spectacular==0.16.0
drf-spectacular==0.26.5
# via -r requirements/base.in
drf-yasg==1.21.7
# via commonground-api-common
Expand Down
3 changes: 2 additions & 1 deletion requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ django-solo==2.0.0
django-two-factor-auth[phonenumberslite,webauthn]==1.16.0
# via
# -r requirements/base.txt
# django-two-factor-auth
# maykin-2fa
django-webtest==1.9.10
# via -r requirements/test-tools.in
Expand All @@ -223,7 +224,7 @@ drf-nested-routers==0.93.4
# via
# -r requirements/base.txt
# commonground-api-common
drf-spectacular==0.16.0
drf-spectacular==0.26.5
# via -r requirements/base.txt
drf-yasg==1.21.7
# via
Expand Down
4 changes: 3 additions & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ django-solo==2.0.0
django-two-factor-auth[phonenumberslite,webauthn]==1.16.0
# via
# -r requirements/ci.txt
# django-two-factor-auth
# maykin-2fa
django-webtest==1.9.10
# via -r requirements/ci.txt
Expand All @@ -251,7 +252,7 @@ drf-nested-routers==0.93.4
# via
# -r requirements/ci.txt
# commonground-api-common
drf-spectacular==0.16.0
drf-spectacular==0.26.5
# via -r requirements/ci.txt
drf-yasg==1.21.7
# via
Expand Down Expand Up @@ -514,6 +515,7 @@ tomli==2.0.1
# via
# black
# build
# pyproject-hooks
uritemplate==4.1.1
# via
# -r requirements/ci.txt
Expand Down
10 changes: 10 additions & 0 deletions src/objecttypes/tests/v1/test_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from rest_framework import status
from rest_framework.test import APITestCase

from .utils import reverse


class APISchemaTest(APITestCase):
def test_schema_endoint(self):
response = self.client.get(reverse("schema-redoc"))
self.assertEqual(response.status_code, status.HTTP_200_OK)
10 changes: 10 additions & 0 deletions src/objecttypes/tests/v2/test_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from rest_framework import status
from rest_framework.test import APITestCase

from .utils import reverse


class APISchemaTest(APITestCase):
def test_schema_endoint(self):
response = self.client.get(reverse("schema-redoc"))
self.assertEqual(response.status_code, status.HTTP_200_OK)
8 changes: 6 additions & 2 deletions src/objecttypes/utils/autoschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ def get_override_parameters(self):
parent_path_headers = self.get_parent_path_headers()
return content_type_headers + parent_path_headers

def _get_response_for_code(self, serializer, status_code, media_types=None):
def _get_response_for_code(
self, serializer, status_code, media_types=None, direction="response"
):
"""add default description to the response"""
response = super()._get_response_for_code(serializer, status_code, media_types)
response = super()._get_response_for_code(
serializer, status_code, media_types, direction
)

if not response.get("description"):
response["description"] = HTTP_STATUS_CODE_TITLES.get(int(status_code))
Expand Down

0 comments on commit a23e004

Please sign in to comment.