Closed
Description
This issue occurs when using the updated OpenAPI schema generation by @carltongibson (#6532).
Checklist
- I have verified that that issue exists against the
master
branch of Django REST framework. - I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- This is not a usage question. (Those should be directed to the discussion group instead.)
- This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
- I have reduced the issue to the simplest possible case.
- I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)
Steps to reproduce
Run ./manage.py generateschema
on any project that has an API endpoint that inherits from GenericAPIView
and does not have a serializer_class
.
Expected behavior
A normal OpenAPI schema, except the request and response parameters should be empty? Maybe with a warning. I am not sure whether this should raise an exception or handle those cases.
Actual behavior
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/lucidiot/.virtualenvs/backend/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/lucidiot/.virtualenvs/backend/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/lucidiot/.virtualenvs/backend/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/lucidiot/.virtualenvs/backend/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/lucidiot/Prog/django-rest-framework/rest_framework/management/commands/generateschema.py", line 24, in handle
schema = generator.get_schema(request=None, public=True)
File "/home/lucidiot/Prog/django-rest-framework/rest_framework/schemas/generators.py", line 519, in get_schema
paths = self.get_paths(None if public else request)
File "/home/lucidiot/Prog/django-rest-framework/rest_framework/schemas/generators.py", line 506, in get_paths
operation = view.schema.get_operation(path, method)
File "/home/lucidiot/Prog/django-rest-framework/rest_framework/schemas/inspectors.py", line 527, in get_operation
operation['responses'] = self._get_responses(path, method)
File "/home/lucidiot/Prog/django-rest-framework/rest_framework/schemas/inspectors.py", line 734, in _get_responses
serializer = view.get_serializer()
File "/home/lucidiot/Prog/django-rest-framework/rest_framework/generics.py", line 110, in get_serializer
serializer_class = self.get_serializer_class()
File "/home/lucidiot/Prog/django-rest-framework/rest_framework/generics.py", line 127, in get_serializer_class
% self.__class__.__name__
AssertionError: 'SomeAPIView' should either include a `serializer_class` attribute, or override the `get_serializer_class()` method.
Metadata
Metadata
Assignees
Labels
No labels