You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have verified that that issue exists against the master branch of Django REST framework.
I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
This is not a usage question. (It sort of isn't...)
This cannot be dealt with as a third party library.
I have reduced the issue to the simplest possible case.
I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)
Description
Following an upgrade DRF 3.11.2 -> 3.12.2, in order to avoid the warning about duplicate OpenAPI Operation IDs (implemented in #7207), I had to refactor extra ViewSet actions such as
that generates two OpenAPI operations, called SomethingEditMember and SomethingDeleteMember and doesn't warn about things.
However, this screws up routing, since both views have the same URL path, and as such one of them gets selected by Django when dispatching the request, which naturally leads to Method Not Alloweds when attempting to use the one not selected.
Resolutions
I suppose it could be possible to rework the Router to have an internal per-method dispatch when it notices an URL regex is used by two "destinations" with different methods? (This admittedly sounds brittle and complex.)
The easier way might be to somehow easily allow setting an operation_id for @actions too (which is what I'll be looking into next, probably by way of hacking the Schema generator somehow since there's no official support I can see).
The text was updated successfully, but these errors were encountered:
defaction_operation_id_suffixes(method_map: Dict[str, str]):
""" Anoint the given `@action` function with a mapping of method -> OpenAPI operation ID. """defdecorator(fn):
fn.operation_id_suffixes= {
method.lower(): suffixfor (method, suffix)
inmethod_map.items()
}
returnfnreturndecorator
Checklist
master
branch of Django REST framework.Description
Following an upgrade DRF 3.11.2 -> 3.12.2, in order to avoid the warning about duplicate OpenAPI Operation IDs (implemented in #7207), I had to refactor extra ViewSet actions such as
that generates two OpenAPI operations, both called
SomethingMembers
, tothat generates two OpenAPI operations, called
SomethingEditMember
andSomethingDeleteMember
and doesn't warn about things.However, this screws up routing, since both views have the same URL path, and as such one of them gets selected by Django when dispatching the request, which naturally leads to Method Not Alloweds when attempting to use the one not selected.
Resolutions
operation_id
for@action
s too (which is what I'll be looking into next, probably by way of hacking the Schema generator somehow since there's no official support I can see).The text was updated successfully, but these errors were encountered: