Skip to content

Commit

Permalink
feat(generic): add a get_openapi_tags class method
Browse files Browse the repository at this point in the history
This method is used by the GenericAutoSchema to retreive tags for the
OpenAPI schema
  • Loading branch information
b1rger committed Dec 18, 2024
1 parent 3270307 commit 58e8f85
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apis_core/generic/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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])
Expand Down

0 comments on commit 58e8f85

Please sign in to comment.