-
-
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
Possible solution for tags generation #7184
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.
In general I'm +0 on these changes. I've got one in-line review comment about being consistent in how we generate the default tag names.
Thanks for your suggestion. I have done given changes. Additionally, I have done the following changes:
|
@carltongibson I await your valuable reply at your earliest convenience. |
docs/api-guide/schemas.md
Outdated
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 replaced by a space. |
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 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.
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.
Sure. I will implement the path style as the default case.
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.
Yes, I think the default implementation should use the path. Folks can pass tags, or subclass for something cleverer.
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.
Looks like there's some great stuff here. I'd personally like to see it start slimmed down as much as possible.
Hi @dhaval-mehta. Yes, I can see that you like viewsets and want this particular implementation. But a lot of people don't use viewsets at all. And there are many different configurations and conventions. I'm just not convinced that favouring this one particular approach is correct. I will think on it. |
Seconded. 😃 |
Should I remove viewset specific implementation? |
Hey @dhaval-mehta. Yes, I think so, please. Let's just go with the path approach. Folks can create a subclass if they use viewsets heavily and set |
I have removed the viewset specific code. |
Hi @carltongibson, This is a nice idea. With your permission, I would like to add this idea in documentation with an example. |
Hi, @carltongibson I am working on the global tag object, where users can pass dict as a tag. I request the following you.
|
Hi @dhaval-mehta Slowly, slowly. 🙂 Let’s finish this off before moving on. I need time to review it finally and go over the docs changes. Sorry if that’s a bit slow for you, but you have to remember I do this in my free time, and alas I’m not going to review on the weekend. Then we should discuss further changes in an issue before spending time on code. Firstly, how much demand is there really for the dict format of tags? It might be that we choose to not support it. |
Sorry. I was unaware about this situation. I am working in start up where code is running on production just 2-3 days after PR. Anyway thank you so much for your efforts. |
No problem. Therein lies the difference between comercial software and open source. 🙂 Thank you for your efforts on this one. We will get it in. |
Looking great. @carltongibson let me know if you'd like my time on this too. |
It’s on my list for this week. |
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 @dhaval-mehta.
Good work on this one, thank you! 🥇
@dhaval-mehta where did you land on global tags generation. I'm currently looking to implement logic on this but don't want to re-invent the wheel if others have made good progress. |
@carltongibson I have 2 different approaches for global tag generation.
I am personally inclined with the approach: 1 |
Yep, currently you'd need to override Happy to add some args to SchemaGenerator in principle for the most common cases. Not sure if tags counts there or not. (Likely yes?) What I want to avoid is a argument for every possible option: that way lies madness. Keep the interface clean for the common cases that face most users. Subclassing isn't hard for the few that need the more exotic options. |
I believe only 2 fields For mid to big size of projects & for companies with multiple teams, the global tags are a must. I think adding tags as a parameter to |
Hey @dhaval-mehta. That sounds reasonable. Fancy doing a PR for those either of you? Thanks! |
@carltongibson I will pick this task today. |
@dhaval-mehta One issue is the inferface: you don't generally instantiate SchemaGenerator yourself. Tags I can see as a CLI option but security...? (Hence create a subclass for your project may still be needed there.) Let's see what you come up with. Thanks |
The following approach is just a thought: Tags are user-defined and vary user to user. On the other hand, security depends on authentication classes. I am thinking that let authentication classes to provide the schema related methods like paginator classes do( For any custom authentication class, the user/library needs to override those methods. |
This merge request adds logic to generate open API tags automatically. It also allows the user to override auto-generated tags as an argument to the constructor of
AutoSchema
. This solution will not break the encapsulation of schema generation. Inspiration: #7103 (comment)There is another merge request(#7182) with a possible solution. You can merge whichever solution is the best.
This Fixes: #7103
This closes: #7104 & #7177