Skip to content
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

Possible solution for tags generation #7184

Merged
merged 26 commits into from
Feb 28, 2020
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d4e9b6e
add tag generation logic
dhaval-mehta Feb 6, 2020
bb339f4
FIX existing test cases
dhaval-mehta Feb 6, 2020
44c1c25
add support for tag objects
dhaval-mehta Feb 9, 2020
a5eec91
improve tag generation from viewset name
dhaval-mehta Feb 9, 2020
ac145a4
add documentation for tags
dhaval-mehta Feb 9, 2020
1baeb24
fix grammatical error
dhaval-mehta Feb 9, 2020
8744470
remove extra line
dhaval-mehta Feb 9, 2020
25f1425
remove APIView name check
dhaval-mehta Feb 9, 2020
05d8a7b
add ExampleTagsViewSet view
dhaval-mehta Feb 9, 2020
4b4f1c1
add test cases for tag generation
dhaval-mehta Feb 9, 2020
9c3a632
minor improvement in documentation
dhaval-mehta Feb 9, 2020
b0f11cd
fix changes given by kevin-brown
dhaval-mehta Feb 12, 2020
10cdd2b
improve documentation
dhaval-mehta Feb 12, 2020
ee97de3
improve documentation
dhaval-mehta Feb 12, 2020
31a1eb1
add test case for tag generation from view-set
dhaval-mehta Feb 12, 2020
56178ed
remove support for dict tags
dhaval-mehta Feb 18, 2020
912f22a
change tag name style to url path style
dhaval-mehta Feb 18, 2020
cc2a8a5
remove test cases for tag objects
dhaval-mehta Feb 18, 2020
8d3051d
add better example in comments
dhaval-mehta Feb 19, 2020
4229234
sync documentation with implementation.
dhaval-mehta Feb 19, 2020
d77afd5
improve documentation
dhaval-mehta Feb 19, 2020
22da477
change _get_tags to get_tags
dhaval-mehta Feb 19, 2020
95831b5
add guidance for overriding get_tags method
dhaval-mehta Feb 19, 2020
f438f14
add test case for method override use case
dhaval-mehta Feb 19, 2020
48c02dd
improve error message
dhaval-mehta Feb 19, 2020
64a4828
remove tag generation from viewset
dhaval-mehta Feb 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve documentation
  • Loading branch information
dhaval-mehta committed Feb 12, 2020
commit ee97de3269461b805faebea1c37a5bfbcdb60a82
4 changes: 2 additions & 2 deletions docs/api-guide/schemas.md
Original file line number Diff line number Diff line change
@@ -224,7 +224,7 @@ Tags can be used to group logical operations. Each tag name in the list MUST be
**Django REST Framework generates tags automatically with following logic:**
1. Extract tag from `ViewSet`.
1. If `ViewSet` name ends with `ViewSet`, or `View`; remove it.
2. Convert class name into lowercase words & join each word with a space.
2. Convert class name into lowercase words & join each word using a space.

Examples:

@@ -236,7 +236,7 @@ Tags can be used to group logical operations. Each tag name in the list MUST be
PascalCaseXYZ | ['pascal case xyz']
IPAddressView | ['ip address']

2. If View is not an instance of ViewSet, tag name will be first element from the path. Also, any `-` or `_` in path name will be converted as a space.
2. If View is not an instance of ViewSet, tag name will be first element from the path. Also, any `-` or `_` in path name will be replaced by a space.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we ought to just use the path style as the default case?

I think that'd be more obvious, more consistent across a code base, and a little more simple.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I will implement the path style as the default case.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think the default implementation should use the path. Folks can pass tags, or subclass for something cleverer.

Consider below examples.

Example 1: Consider a user management system. The following table will illustrate the tag generation logic.