First at all, I want to clarify that I use swagger-codegen
to autogenerate code for a Play Framework
based service.
I currently using the same swagger API description replicated in several projects that implements the same API but have different internal implementation.
I think that it would be better to create an independent JAR that contains all autogenerated code (models and controllers) according to the API defined in the swagger.json
file and then add it to each project for both to reduce duplication and to improve mantainance and save compilation time.
My doubd is if it is posible to bind routes to the independent JAR controllers or not.
Yes, it is possible. You can simply add a dependency to your jar file. The jar file must contain a routes file with a unique name (e.g. api.routes) . In every project you can include the routes file like this:
conf/routes
-> /api api.Routes