diff --git a/drf_spectacular/drainage.py b/drf_spectacular/drainage.py index 9b47dc3e..b25f2626 100644 --- a/drf_spectacular/drainage.py +++ b/drf_spectacular/drainage.py @@ -182,8 +182,12 @@ def get_view_method_names(view, schema=None) -> List[str]: return [ item for item in dir(view) if callable(getattr(view, item)) and ( item in view.http_method_names - or item in schema.method_mapping.values() - or item == 'list' + or ( + item in schema.async_method_mapping.values() + if view.view_is_async + else item in schema.method_mapping.values() + ) + or item == ('alist' if view.view_is_async else 'list') or hasattr(getattr(view, item), 'mapping') ) ] diff --git a/drf_spectacular/openapi.py b/drf_spectacular/openapi.py index 8258b532..78a6b0fa 100644 --- a/drf_spectacular/openapi.py +++ b/drf_spectacular/openapi.py @@ -57,6 +57,13 @@ class AutoSchema(ViewInspector): 'patch': 'partial_update', 'delete': 'destroy', } + async_method_mapping = { + 'get': 'aretrieve', + 'post': 'acreate', + 'put': 'aupdate', + 'patch': 'partial_aupdate', + 'delete': 'adestroy', + } def get_operation( self,