coursera / courier

Data interchange for the modern web + mobile stack.
http://coursera.github.io/courier/
Apache License 2.0
98 stars 24 forks source link

Adds generator mixin capability so that we can customize template generation for Coursera #74

Closed amory-coursera closed 6 years ago

amory-coursera commented 6 years ago

Wouldn't it be nice if our Coursera's courier records automatically included Coursera JSON format implicits? Now, they can! Scala generators now take a GeneratorMixin class that can append additional lines at the end of each generated class and companion object. Mixin methods are called with org.coursera.courier.generator.specs.Definition, so mixin behavior can be schema-aware.

This PR includes core changes and tests. I struggled somewhat trying to declare a custom generator (with mixins) for my tests. Ultimately it worked to add a new library solely for the test generator, but I'd be happy to learn of a better way to do this.

amory-coursera commented 6 years ago

Thanks for reviewing @mkovacs-coursera . Good point on scalafmt confusing things. Thanks for your tolerance there.