From 58e8f85602a64450d9c68ee2efceddc069246ecd Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Wed, 18 Dec 2024 10:16:49 +0100 Subject: [PATCH] feat(generic): add a `get_openapi_tags` class method This method is used by the GenericAutoSchema to retreive tags for the OpenAPI schema --- apis_core/generic/abc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apis_core/generic/abc.py b/apis_core/generic/abc.py index 7b7694d6c..243a7057f 100644 --- a/apis_core/generic/abc.py +++ b/apis_core/generic/abc.py @@ -2,7 +2,7 @@ from django.db.models import BooleanField, CharField, TextField from django.urls import reverse -from apis_core.generic.helpers import permission_fullname +from apis_core.generic.helpers import mro_paths, permission_fullname class GenericModel: @@ -24,6 +24,10 @@ def get_importview_url(cls): ct = ContentType.objects.get_for_model(cls) return reverse("apis_core:generic:import", args=[ct]) + @classmethod + def get_openapi_tags(cls): + return [item[-1] for item in mro_paths(cls)] + def get_edit_url(self): ct = ContentType.objects.get_for_model(self) return reverse("apis_core:generic:update", args=[ct, self.id])