前提・実現したいこと
https://akiyoko.hatenablog.jp/entry/2020/12/08/120230
こちらのブログを参考に、DRFの初期構築をしています。
OpenAPIの情報を出力したいのですが、失敗しています。
発生している問題・エラーメッセージ
bash
1$ python manage.py generateschema --file schema.yml 2usage: manage.py generateschema [-h] [--title TITLE] [--url URL] [--description DESCRIPTION] [--format {openapi,openapi-json}] 3 [--urlconf URLCONF] [--generator_class GENERATOR_CLASS] [--version] [-v {0,1,2,3}] [--settings SETTINGS] 4 [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color] [--skip-checks] 5manage.py generateschema: error: unrecognized arguments: --file schema.yml 6 7 8$ python manage.py generateschema 9Traceback (most recent call last): 10 File "manage.py", line 10, in <module> 11 execute_from_command_line(sys.argv) 12 File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line 13 utility.execute() 14 File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute 15 self.fetch_command(subcommand).run_from_argv(self.argv) 16 File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv 17 self.execute(*args, **cmd_options) 18 File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 369, in execute 19 output = self.handle(*args, **options) 20 File "/usr/local/lib/python3.8/site-packages/rest_framework/management/commands/generateschema.py", line 40, in handle 21 schema = generator.get_schema(request=None, public=True) 22 File "/usr/local/lib/python3.8/site-packages/rest_framework/schemas/openapi.py", line 64, in get_schema 23 paths = self.get_paths(None if public else request) 24 File "/usr/local/lib/python3.8/site-packages/rest_framework/schemas/openapi.py", line 47, in get_paths 25 operation = view.schema.get_operation(path, method) 26 File "/usr/local/lib/python3.8/site-packages/rest_framework/schemas/openapi.py", line 95, in get_operation 27 operation['operationId'] = self._get_operation_id(path, method) 28 File "/usr/local/lib/python3.8/site-packages/rest_framework/schemas/openapi.py", line 130, in _get_operation_id 29 name = self.view.get_serializer_class().__name__ 30 File "/usr/local/lib/python3.8/site-packages/rest_framework/generics.py", line 122, in get_serializer_class 31 assert self.serializer_class is not None, ( 32AssertionError: 'ValidateAuthTokenView' should either include a `serializer_class` attribute, or override the `get_serializer_class()` method.
該当のソースコード
python
1cat manage.py 2#!/usr/bin/env python 3import os 4import sys 5 6if __name__ == "__main__": 7 os.environ.setdefault("DJANGO_SETTINGS_MODULE", 'settings') 8 9 from django.core.management import execute_from_command_line 10 11 execute_from_command_line(sys.argv)
試したこと
コマンドのチェックや検索をしましたが、わかりませんでした。
あなたの回答
tips
プレビュー