Add stringification for permissions #7931
Unanswered
MarkusH
asked this question in
Ideas & Suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to document the required permissions for an API endpoint as part of the OpenAPI schema. Since OpenAPI doesn't seem to provide a way to add the permissions (understandable, it's out of context) I'm adding the permissions to a view's description.
But in order to turn a list of permissions into a string, the permissions need to be stringifiable. So, let's say I set
permission_classes = [Perm1 | Perm2, Perm3 & Perm4]
I would like to get something like this out:"Perm1 or Perm2, Perm3 and Perm4"
.The core I have right now is this:
Additionally, I have a custom
Schema
that extends the description:Looking at the Swagger UI, this looks like this:
What I'm proposing is to add the stringification of the
AND
,OR
,NOT
, andBasePermission
. Adjusting the schema is not part of the proposal, as that is easily extendible. However ,monkey-patching the classes with__str__
is ugly and should be avoided if possible.Beta Was this translation helpful? Give feedback.
All reactions