-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tags to Swagger OpenAPI schemas #7104
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @phuongtai. This looks like a nice improvement.
Can you rebase on master
and add a test case asserting that the tags are generated correctly?
@@ -47,11 +47,13 @@ def get_paths(self, request=None): | |||
operation = view.schema.get_operation(path, method) | |||
# Normalise path for any provided mount url. | |||
if path.startswith('/'): | |||
tags = [path.split('/')[1]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phuongtai @carltongibson This will not work for nested resources.
Let's assume a restaurant management system. We have restaurants. Each restaurant has branches and each branch has inspections. To retrieve single inspection for a branch, following might be a URL:
/restaurants/{restaurant_id}/branches/{branch_id}/inspections/{inspection_id}
Ideally, tags for this path will be inspections
but your code will generate restaurants
Realtime Example: Retrieve billing information for a sub-account by zoom.us
In case, the path is /accounts/{accountId}/billing
and schema tag is billing
not accounts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understood your problem, I've just resolved the problem which is putting all of APIs by tags default
. I removed it and get default tags is a top level of each APIs. So we have to find the better solutions which may be automatically or manually generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My Idea is to extract the tags from the view-set. Spring Framework is doing the same.
@phuongtai Are you working on it? We also need this feature.
Hello to everyone! I was looking for this feature either. We can try next:
** Edit: What do you think? |
Thanks for your solution. That sound good but are you sure about working fine with ViewSet? |
This is a good start but isn't quite right. I've added an outline of how I think it should go on the issue: #7103 (comment) |
Description
My solution is find the first element of a specific path that proper with tags
Example:
PUT, PATCH, PUT, DELETE: /task/{id} -> tags=[task]
POST, GET: /task -> tags=[task]
Please read more at this issue #7103