-
Notifications
You must be signed in to change notification settings - Fork 422
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
Codegen: Add new useHeadTagForObjectNames
flag to permit splitting generated endpoint objects by tag
#3594
Codegen: Add new useHeadTagForObjectNames
flag to permit splitting generated endpoint objects by tag
#3594
Conversation
Thanks! Could you add documentation for this new flag to |
Sure. Will do that in a few mins & push up a test, too |
Done! (In case you can't tell, this is a feature I really want 😂) |
Yes, I can tell 😁 Sorry to push back some more, but could you also explain in the docs what the "first declared tag" mean? This could be added outside of the table with flags. |
@kciesielski I've updated the copy a little more, let me know what you think Edit: Happy to make changes, please do comment on anything you're not happy with. Meantime I've brewed another pr for ya 😄 |
Thanks! Looks good to me :) |
d1c1f2d
to
5a047c3
Compare
Pushed rebase to fix merge conflicts |
.map { case (name, definition) => | ||
s"""|lazy val $name = | ||
val geMap = | ||
doc.paths.flatMap(generatedEndpoints(components, useHeadTagForObjectNames)).groupBy(_._1).mapValues(_.map(_._2).reduce(_ ++ _)) |
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.
This would've been so much cleaner with groupMapReduce(_._1)(_._2)(_ ++ _)
😂 but, alas, scala 2.12...
I've been thinking about this for ages and finally got around to it. If autogenerating files for a very large spec, it's possible to hit the JVM limits on class size since all definitions go into the same object; so from a purely technical perspective, this does enable working with certain specs that would otherwise require some fudging (such as calling the codegen cli on multiple input files); although I confess to also just finding it a bit tidier. This pr adds a new flag
useHeadTagForObjectNames
(defaulting to false, to preserve existing behaviour). If this flag is true then the generated endpoints are grouped by the first tag, and each group put into a new file+object with the same name as that tag. All types/enums/classes generated from schemas remain in the default object model as before, and if an endpoint has no tags at all, it is placed into the default object (i.e. a spec with no tags would see no change as a result of this pr, regardless of whether the flag were set to true or not)