-
Notifications
You must be signed in to change notification settings - Fork 270
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
ViewSet inheritance issue #218
Comments
hi @konkab, yes this is a bug in the the tests only covered the base class case like: @extend_schema_view(list=..., ...)
class XViewset(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet)::
.... i'll have to investigate how to fix this. |
@tfranzel Any updates on this issue? I am also trying to extend a parent class and a child class, but only the parent extension is applied to both. |
hi @elvirTatarevic! i have not gotten around investigating this further. its a tricky issue. i'll have to deal with 3-4 other issues first. after that i will have a look at it again. |
@tfranzel No problem man. We all appreciate everything that is being done. For now, a base class kind of seems to do the trick. |
Just adding my vote for a fix here. Ran into this today and thought I was losing what little sanity I can claim |
When creating a copy of a method from a parent class we now: - Ensure that `__qualname__` is defined correctly - i.e. `Child.method` instead of `Parent.method`. - This isn't essential but helps diagnosing issues when debugging. - Move application of the decorator to the last moment. - Deep copy the existing schema extensions before applying decorator. This fixes tfranzel#218 where two child classes with @extend_schema_view affect each other - schema extensions are applied to the parent such that the second child overwrites the changes applied to the first child. This also fixes my case where a child with @extend_schema_view clobbered the schema extensions of the parent which also used @extend_schema_view.
When creating a copy of a method from a parent class we now: - Ensure that `__qualname__` is defined correctly - i.e. `Child.method` instead of `Parent.method`. - This isn't essential but helps diagnosing issues when debugging. - Move application of the decorator to the last moment. - Deep copy the existing schema extensions before applying decorator. This fixes tfranzel#218 where two child classes with @extend_schema_view affect each other - schema extensions are applied to the parent such that the second child overwrites the changes applied to the first child. This also fixes my case where a child with @extend_schema_view clobbered the schema extensions of the parent which also used @extend_schema_view.
@filipemir please reclaim your valuable sanity by checking out the current master branch. @elvirTatarevic @konkab, would be great if you do that too. This bug was actually a rather small oversight, but I was unable to see the forest for the trees there. Many thanks to @ngnpope. In #554, we addressed at least 3 different issues regarding isolation/inheritance. I'm not aware of any remaining issues in that regard, which is why I ask you kindly to test those fixes. let me know if anything is still not behaving as expected! |
Hey @tfranzel. Works for me! With the latest version I was able to erase a bunch of duplicated annotations all over our code which was just the sort of satisfying work I needed at this stage in the day. Thank you! |
Upgrade drf-spectacular to v0.21.0 to make the fix for <tfranzel/drf-spectacular#218> available to our code. Change-Id: If0b94e35e9a04964983f1f819eab8644c582ddda
I have two ViewSets subclassed from another ViewSet. Subclasses are decorated with @extend_view_schema with identical method names, but different extend_schema values (different tag names).
The subclasses are located in different apps.
appointments/views.py:
doctors/views.py:
patients/views.py:
One ViewSet is registered in doctors.urls, the other in patient.urls.
"app".urls:
The issue is that "doctors" tags get overriden by "patients" tags. Basically all parameters get overriden by last added path.
It seems like the extend_schema decorators stick to superclass only.
The text was updated successfully, but these errors were encountered: