bihealth / sodar-core

SODAR Core: A Django-based framework for building scientific data management web apps
MIT License
9 stars 1 forks source link

Incompatibility with DRF `manage.py generateschema` #1440

Closed holtgrewe closed 2 months ago

holtgrewe commented 2 months ago

Describe the Bug

When trying to run manage.py generateschema from DRF, the exception from below is triggered.

How to Reproduce

Run manage.py generateschema in a sodar-core app that uses projectroles.

Expected Behavior

We should be able to run generateschema.

I have a patch to circumvent the problem.

Screenshots

N/A

System Information

Additional Context

Traceback (most recent call last):
  File "/home/holtgrem_c/Development/varfish-server/backend/manage.py", line 29, in <module>
    execute_from_command_line(sys.argv)
  File "/home/holtgrem_c/.local/share/virtualenvs/backend-_vbeNn7h/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/home/holtgrem_c/.local/share/virtualenvs/backend-_vbeNn7h/lib/python3.10/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/holtgrem_c/.local/share/virtualenvs/backend-_vbeNn7h/lib/python3.10/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/holtgrem_c/.local/share/virtualenvs/backend-_vbeNn7h/lib/python3.10/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/home/holtgrem_c/.local/share/virtualenvs/backend-_vbeNn7h/lib/python3.10/site-packages/rest_framework/management/commands/generateschema.py", line 43, in handle
    schema = generator.get_schema(request=None, public=True)
  File "/home/holtgrem_c/.local/share/virtualenvs/backend-_vbeNn7h/lib/python3.10/site-packages/rest_framework/schemas/openapi.py", line 81, in get_schema
    operation = view.schema.get_operation(path, method)
  File "/home/holtgrem_c/.local/share/virtualenvs/backend-_vbeNn7h/lib/python3.10/site-packages/rest_framework/schemas/openapi.py", line 147, in get_operation
    operation['operationId'] = self.get_operation_id(path, method)
  File "/home/holtgrem_c/.local/share/virtualenvs/backend-_vbeNn7h/lib/python3.10/site-packages/rest_framework/schemas/openapi.py", line 267, in get_operation_id
    name = self.get_operation_id_base(path, method, action)
  File "/home/holtgrem_c/.local/share/virtualenvs/backend-_vbeNn7h/lib/python3.10/site-packages/rest_framework/schemas/openapi.py", line 232, in get_operation_id_base
    elif self.get_serializer(path, method) is not None:
  File "/home/holtgrem_c/.local/share/virtualenvs/backend-_vbeNn7h/lib/python3.10/site-packages/rest_framework/schemas/openapi.py", line 617, in get_serializer
    return view.get_serializer()
  File "/home/holtgrem_c/.local/share/virtualenvs/backend-_vbeNn7h/lib/python3.10/site-packages/rest_framework/generics.py", line 109, in get_serializer
    kwargs.setdefault('context', self.get_serializer_context())
  File "/home/holtgrem_c/.local/share/virtualenvs/backend-_vbeNn7h/lib/python3.10/site-packages/projectroles/views_api.py", line 260, in get_serializer_context
    context['project'] = self.get_project(request=context['request'])
  File "/home/holtgrem_c/.local/share/virtualenvs/backend-_vbeNn7h/lib/python3.10/site-packages/projectroles/views.py", line 233, in get_project
    raise ImproperlyConfigured('Current HTTP request is not accessible')
django.core.exceptions.ImproperlyConfigured: Current HTTP request is not accessible
mikkonie commented 2 months ago

Fixed by @holtgrewe and merged.