Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Getting TypeError from AutoSchema.get_operation()#9490

Discussion options

Added APItally to a working DRF back-end. FWIW, it also usesdrf_spectacular andReDoc (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 schemaTraceback (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 adev 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.

You must be logged in to vote

This typically happens when the generating the open API schema using DRF methods on endpoints where DRF-spectacular AutoSchema is set. The stack trace points at this line:

https://github.com/apitally/apitally-py/blob/4fe5298e7cd7892f5368e29acb1a86e0593dcacd/apitally/django.py#L260

They use DRF SchemaGenerator, but spectacular has its own onehttps://github.com/tfranzel/drf-spectacular/blob/cc916372a0e3fafc3af48f94dd1a985f5fc466e9/drf_spectacular/generators.py#L102

IMO this is more an issue for APItally than DRF, they could detect whether spectacular is installed and use the appropriate generator if needed.

Replies: 3 comments

Comment options

This typically happens when the generating the open API schema using DRF methods on endpoints where DRF-spectacular AutoSchema is set. The stack trace points at this line:

https://github.com/apitally/apitally-py/blob/4fe5298e7cd7892f5368e29acb1a86e0593dcacd/apitally/django.py#L260

They use DRF SchemaGenerator, but spectacular has its own onehttps://github.com/tfranzel/drf-spectacular/blob/cc916372a0e3fafc3af48f94dd1a985f5fc466e9/drf_spectacular/generators.py#L102

IMO this is more an issue for APItally than DRF, they could detect whether spectacular is installed and use the appropriate generator if needed.

You must be logged in to vote
0 replies
Answer selected bytomchristie
Comment options

its better to usehttps://drf-yasg.readthedocs.io/en/stable/readme.html

You must be logged in to vote
0 replies
Comment options

I'm the founder of Apitally and just stumbled upon this. This has been fixed in the Apitally SDK now! ✅

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
4 participants
@raminf@browniebroke@itssimon@rubyazz
Converted from issue

This discussion was converted from issue #9481 on August 06, 2024 10:51.


[8]ページ先頭

©2009-2025 Movatter.jp