Sadly all endpoints have the same name and schema in the swagger.yml file generated with generate_swagger command.
After digging in the code, I found that for all classes, we have the same object in memory for callback.cls.post (with callback been the objects that we can find here and here).
It's the same object with the same memory allocation, so whenever the code set the _swagger_auto_schema attribute to on callback.cls.post, it's set on all callbacks.cls.post.
So all endpoints will have the swagger schema of the last class found in the url pattern.
I think it's possible to fix this issue by changing where drf_yasg sets the _swagger_auto_schema attribute.
I'm interested in submitting a PR (or at least to try)
My questions are :
Is it really worth it ? I couldn't find a related issue so I would say probably not...
Is there something I missed and that would fixe my issue in a more in a more satisfactory manner (without the post override in each sub-class)
Hello.
I'm having an issue that seems to be related with CPython memory allocation. I am wondering if there's a way to work around my issue with drf_yasg.
I have a series of APIViews that all have the same template :
Since it's a bit painfull to always duplicate the post/swagger_auto_schema within each class. I tried so create a common mixin :
Sadly all endpoints have the same name and schema in the swagger.yml file generated with generate_swagger command. After digging in the code, I found that for all classes, we have the same object in memory for
callback.cls.post
(with callback been the objects that we can find here and here).It's the same object with the same memory allocation, so whenever the code set the
_swagger_auto_schema
attribute to on callback.cls.post, it's set on all callbacks.cls.post. So all endpoints will have the swagger schema of the last class found in the url pattern.I found a work around :
I think it's possible to fix this issue by changing where drf_yasg sets the _swagger_auto_schema attribute. I'm interested in submitting a PR (or at least to try)
My questions are :