-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
a problem with creating a schema with drf 3.10.3 #796
Comments
Hi, every time this comes up, it is a different REST_FRAMEWORK = {
# YOUR SETTINGS
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
} will 100% work. Just make sure you have the right settings file loaded. |
That is the usual fallacy. running |
Alas, it is not possible that we touch this variable. btw, we do not use runserver |
not sure what that means.
with Either you have some custom schema class on views OR your |
Thank you very much for another reply. By not touching I meant that we didn't change the DEFAULT_SCHEMA_CLASS - it was introduced very recently, to see if transitioning to drf-spectacular was possible in our project. meanwhile in version 3.13.1 version of drf, this code looks as follows: It seems that:
|
Thanks @fannyhub for digging in. Sorry that I nudged you in the wrong direction repeatedly. 99% of raised&resolved issues were indeed wrong configs. I was not aware of that SO question and apparently nobody raised it here. Your analysis is absolutely correct. It is indeed a bug in DRF < 3.12. I added an extension that fixes that bug for prior versions. It will be in the next release ( from drf_spectacular.openapi import AutoSchema
from rest_framework.authtoken.views import ObtainAuthToken
class FixedObtainAuthToken(ObtainAuthToken):
schema = AutoSchema() and using that in your |
mitigate DRF bug in ObtainAuthToken < 3.12.0 #796
Thank you, no more problems with creating schema :) |
AssertionError: Incompatible AutoSchema used on View <class 'Vendors.views.PurchaseOrderListCreateView'>. Is DRF's DEFAULT_SCHEMA_CLASS pointing to "drf_spectacular.openapi.AutoSchema" or any other drf-spectacular compatible AutoSchema? Still have this issue in Django reset 3.14.0 and drf_spectacular 0.27.0 . I have have configured everything right as discussed here and as per documentation but no solution: fork repo @: https://github.com/Taruna21/Vendor_Management_System |
this is an uncommon error and the message is exactly right. Some view, even from a library may set a custom schema class on a view and that provokes the error. If you are not doing it, some library does probably. This happened once before but I don't recall which lib. Maybe updating your libs will already fix the issue. |
This is a recent project and has all the latest packages in my
dependencies. Please run my code an see
*Kind Regards,*
*Kelvin Macharia*
…On Mon, Jan 15, 2024 at 1:33 PM T. Franzel ***@***.***> wrote:
this is an uncommon error and the message is exactly right. Some view,
even from a library may set a custom schema class on a view and that
provokes the error. If you are not doing it, some library does probably.
This happened once before but I don't recall which lib. Maybe updating your
libs will already fix the issue.
—
Reply to this email directly, view it on GitHub
<#796 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A6A3F6EGGTAJHXC4WJJEQF3YOUAWVAVCNFSM57VUII52U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBZGE4DEOJQGIYQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
please find a minimal reproduction (the offending view) including stacktrace and create a new issue. I have very limited time to look at this. |
Thanks, I will!
*Kind Regards,*
*Kelvin Macharia*
…On Mon, Jan 15, 2024 at 2:16 PM T. Franzel ***@***.***> wrote:
please find a minimal reproduction (the offending view) including
stacktrace and create a new issue. I have very limited time to look at this.
—
Reply to this email directly, view it on GitHub
<#796 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A6A3F6ANRFWQWCVBT7B7XKTYOUFXRAVCNFSM57VUII52U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBZGE4TKNRUHA4A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I am having this error with Django Rest Framework 3.15.2, Django 5.1.6 and Python 3.13.1 I have verified that I am setting: Only once in my settings.py file and I am currently not using environment variables (I moved away from it to help rule that out). I have also verified that when calling: in settings.py it shows the right value("drf_spectacular.openapi.AutoSchema") |
Describe the bug
I have used drf version 3.10.3 as suggested and my previous problem has been resolved.
Alas, the schema still does not get built, failing with:
AssertionError: Incompatible AutoSchema used on View <class 'view-name'>. Is DRF's DEFAULT_SCHEMA_CLASS pointing to "drf_spectacular.openapi.AutoSchema" or any other drf-spectacular compatible AutoSchema?
This happens although I have set DEFAULT_SCHEMA_CLASS in REST_FRAMEWORK settings to drf_spectacular.openapi.AutoSchema.
To Reproduce
create a project with drf 3.10.3 (Django 2.2, Python 3.8/3.9)
Execute ./manage.py spectacular --file schema.yml
Expected behavior
I would expect the schema to pass smoothly
The same applies to 3.11.2 drf version
The text was updated successfully, but these errors were encountered: