Skip to content

Getting TypeError from AutoSchema.get_operation() #9481

@raminf

Description

@raminf

Added APItally to a working DRF back-end. FWIW, it also uses drf_spectacular and ReDoc (which all work fine).

  • Added APItally via Poetry: poetry add "apitally[django_rest_framework]"
  • Added middleware:
MIDDLEWARE = [
    "apitally.django.ApitallyMiddleware",
    # Other middleware ...
]
  • Created the App on the APItally back-end and got the settings:
APITALLY_MIDDLEWARE = {
    "client_id": "{client-id}",
    "env": "dev"
}
  • Reset the whole application, just to be safe (re-creates all database settings, migrations, etc.)
  • Went to bring up the app and got these errors (path's edited):
Failed to get OpenAPI schema
Traceback (most recent call last):
  File ".../.venv/lib/python3.12/site-packages/apitally/django.py", line 198, in _get_startup_data
    data["openapi"] = _get_openapi(urlconfs)
                      ^^^^^^^^^^^^^^^^^^^^^^
  File ".../.venv/lib/python3.12/site-packages/apitally/django.py", line 210, in _get_openapi
    drf_schema = _get_drf_schema(urlconfs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../.venv/lib/python3.12/site-packages/apitally/django.py", line 260, in _get_drf_schema
    schema = generator.get_schema()
             ^^^^^^^^^^^^^^^^^^^^^^
  File .../.venv/lib/python3.12/site-packages/rest_framework/schemas/openapi.py", line 80, in get_schema
    operation = view.schema.get_operation(path, method)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AutoSchema.get_operation() missing 3 required positional arguments: 'path_prefix', 'method', and 'registry'
  • The schema seems to partly show up in the APItally dashboard, but it's hard to tell from error messages where it stops.
  • Commenting out APItally from the MIDDLEWARE settings, then re-running again. The errors go away and everything works.
  • This is for a dev environment. Everything is running locally on top of SQLite. Also have variations that run inside Docker, and another that pushes everything out to AWS serverless, but would like to get APItally to run locally before moving on to others.

This is with:

  • Python 3.12.2 on a Mac. Also:
django = "^5.0.7"
djangorestframework = "^3.15.2"
drf-spectacular = "^0.27.2"
sentry-sdk = {extras = ["django"], version = "^2.11.0"}
apitally = {extras = ["django-rest-framework"], version = "^0.11.1"}
...

Any suggestions appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions