Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Commit

Permalink
improve versioning schemes support
Browse files Browse the repository at this point in the history
close #98
close #71
  • Loading branch information
trik committed Feb 2, 2018
1 parent c0b773d commit cd28c39
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions drf_openapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def decorator(view_method):
view_method.response_serializer = response_serializer

@wraps(view_method)
def wrapper(instance, request, version=None, *args, **kwargs):
def wrapper(instance, request, *args, **kwargs):
version, _ = instance.determine_version(request, *args, **kwargs)

if request_serializer and issubclass(request_serializer, VersionedSerializers):
instance.request_serializer = request_serializer.get(version)
else:
Expand All @@ -24,7 +26,7 @@ def wrapper(instance, request, version=None, *args, **kwargs):
else:
instance.response_serializer = response_serializer

response = view_method(instance, request, version=version, *args, **kwargs)
response = view_method(instance, request, *args, **kwargs)
if validate_response:
response_validator = instance.response_serializer(data=response.data)
response_validator.is_valid(raise_exception=True)
Expand Down
3 changes: 2 additions & 1 deletion drf_openapi/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class SchemaView(APIView):
url = ''
title = 'API Documentation'

def get(self, request, version):
def get(self, request, *args, **kwargs):
version, _ = self.determine_version(request, *args, **kwargs)
generator = OpenApiSchemaGenerator(
version=version,
url=self.url,
Expand Down
2 changes: 1 addition & 1 deletion examples/snippets/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SnippetList(APIView):
"""

@view_config(response_serializer=SnippetSerializer)
def get(self, request, version, format=None):
def get(self, request, version=None, format=None):
res = self.response_serializer(data=_FAKE_SNIPPETS, many=True)
res.is_valid(raise_exception=True)
return Response(res.validated_data)
Expand Down

0 comments on commit cd28c39

Please sign in to comment.