-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SchemaGenerator doesn't pass request attribute #4278
Comments
I was trying to write a test case for #4265 and ended up here. |
Worth adding this also applies to the kwargs attribute. |
Happening for me as well for 'kwargs'. |
@tomchristie Following is my view code for UserDetailView
Schema generation is failing with following stacktrace...
I think this may be related with issue described above. Schema generation is not working for me even if request attribute is not passed. I did checked with latest build i.e 3.4.3. |
I'm getting the same issue as @geekashu about not having |
To be slightly more specific as to what the issue is (we're now running into it)... The schema generator is attempting to create a view which it can use for introspection, but the view is missing some of the attributes that we've come to expect when using generic method. One of those attributes is It's also been noted that |
My issue is partially related to this one.
Is there a correct/supported way to show those endpoints in generated documentation? |
@Alexx-G From the sound of it, it looks like you'd need to be providing a manual specified schema, or at least create an Maybe you could override In general, it's difficult to see how we can take out the path parameters (say). Whatever logic you have for schema generation is going to need to be handle that. |
@carltongibson Thank you for the answer. |
You’ll need to create a base view class (or mixin maybe) if you want to use it universally |
Steps to reproduce
Override
get_serializer_class
for any view that inherits fromGenericAPIView
and attempt to access therequest
attribute when using the newSchemaGenerator
, or going throughDefaultRouter
.Expected behavior
The
request
attribute is passed intoSchemaGenerator
initialisation and subsequent methods have access to it.Actual behavior
AttributeError: '<view-name>' object has no attribute 'request'
The text was updated successfully, but these errors were encountered: