Allow package/folder overrides per language
#5,081 opened on Mar 15, 2017
Description
Right now codegen allows configuration of a model package for java, which is usually left blank for other implementations. This works well but we would like to give the ability to better organize models. For example, in java we may want to introduce some package structure. In C++ we may want a folder structure.
These options are language-specific, and therefore should be configurable (or left out) for each language type. In addition, we'll need to standardize on how they're referenced, since "java" can cover many generators.
I propose that we first introduce an extension that looks roughly like this:
definitions:
MyModel:
x-codegen-class:
# explicitly set the package/filename for this model
java: io.swagger.client.mymodels.MyModel
cpp: client/MyModel
where the key of the extension value will be specific to the programming language as opposed to the framework. Note, no suffix is supplied.
Next, when the model is processed, it will create the file in the appropriate location. This would need to be handled in the language-specific processing. For java, the io.swagger.client.mymodels will translate to src/*/java/io/swagger/client/mymodels/MyModel.java. For the C++ example, the .h and .cpp files will live in a client folder.
Finally, the import mappings (and includes) will need to be updated as well.
My guess is that this will change some of the CodegenConfig interfaces (many of the methods to get import mappings take a string, where you need a CodegenModel) so we should target 2.3.0 for this work.