forked from loafle/openapi-generator-original
Swagr code-gen: Making base class in models generated configurable
This commit is contained in:
parent
4e7fdd9e5c
commit
590abe83f7
@ -14,7 +14,7 @@ import $import$;
|
|||||||
* @author ramesh
|
* @author ramesh
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class $className$ extends WordnikObject {
|
public class $className$ extends $extends$ {
|
||||||
|
|
||||||
$fields:{ field |
|
$fields:{ field |
|
||||||
//$field.description$
|
//$field.description$
|
||||||
|
@ -252,6 +252,7 @@ public class DriverCodeGenerator {
|
|||||||
StringTemplate template = templateGroup.getInstanceOf(MODEL_OBJECT_TEMPLATE);
|
StringTemplate template = templateGroup.getInstanceOf(MODEL_OBJECT_TEMPLATE);
|
||||||
template.setAttribute("fields", model.getFields());
|
template.setAttribute("fields", model.getFields());
|
||||||
template.setAttribute("imports", imports);
|
template.setAttribute("imports", imports);
|
||||||
|
template.setAttribute("extends", config.getCodeGenOverridingRules().getModelExtendingClass());
|
||||||
template.setAttribute("className", model.getGenratedClassName());
|
template.setAttribute("className", model.getGenratedClassName());
|
||||||
File aFile = new File(config.getModelClassLocation()+model.getGenratedClassName()+config.getClassFileExtension());
|
File aFile = new File(config.getModelClassLocation()+model.getGenratedClassName()+config.getClassFileExtension());
|
||||||
writeFile(aFile, template.toString(), "Model class");
|
writeFile(aFile, template.toString(), "Model class");
|
||||||
@ -291,6 +292,7 @@ public class DriverCodeGenerator {
|
|||||||
StringTemplate template = templateGroup.getInstanceOf(MODEL_OBJECT_TEMPLATE);
|
StringTemplate template = templateGroup.getInstanceOf(MODEL_OBJECT_TEMPLATE);
|
||||||
template.setAttribute("fields", model.getFields());
|
template.setAttribute("fields", model.getFields());
|
||||||
template.setAttribute("imports", imports);
|
template.setAttribute("imports", imports);
|
||||||
|
template.setAttribute("extends", config.getCodeGenOverridingRules().getModelExtendingClass());
|
||||||
template.setAttribute("className", model.getGenratedClassName());
|
template.setAttribute("className", model.getGenratedClassName());
|
||||||
File aFile = new File(config.getModelClassLocation()+model.getGenratedClassName()+config.getClassFileExtension());
|
File aFile = new File(config.getModelClassLocation()+model.getGenratedClassName()+config.getClassFileExtension());
|
||||||
writeFile(aFile, template.toString(), "Assemble class");
|
writeFile(aFile, template.toString(), "Assemble class");
|
||||||
@ -334,6 +336,7 @@ public class DriverCodeGenerator {
|
|||||||
|
|
||||||
template.setAttribute("fields", model.getFields());
|
template.setAttribute("fields", model.getFields());
|
||||||
template.setAttribute("imports", imports);
|
template.setAttribute("imports", imports);
|
||||||
|
template.setAttribute("extends", config.getCodeGenOverridingRules().getModelExtendingClass());
|
||||||
template.setAttribute("className", model.getGenratedClassName());
|
template.setAttribute("className", model.getGenratedClassName());
|
||||||
File aFile = new File(config.getModelClassLocation()+model.getGenratedClassName()+config.getClassFileExtension());
|
File aFile = new File(config.getModelClassLocation()+model.getGenratedClassName()+config.getClassFileExtension());
|
||||||
writeFile(aFile, template.toString(), "Input model class");
|
writeFile(aFile, template.toString(), "Input model class");
|
||||||
@ -414,6 +417,7 @@ public class DriverCodeGenerator {
|
|||||||
StringTemplate template = templateGroup.getInstanceOf(MODEL_OBJECT_TEMPLATE);
|
StringTemplate template = templateGroup.getInstanceOf(MODEL_OBJECT_TEMPLATE);
|
||||||
template.setAttribute("fields", model.getFields());
|
template.setAttribute("fields", model.getFields());
|
||||||
template.setAttribute("imports", imports);
|
template.setAttribute("imports", imports);
|
||||||
|
template.setAttribute("extends", config.getCodeGenOverridingRules().getModelExtendingClass());
|
||||||
template.setAttribute("className", model.getGenratedClassName());
|
template.setAttribute("className", model.getGenratedClassName());
|
||||||
File aFile = new File(config.getModelClassLocation()+model.getGenratedClassName()+config.getClassFileExtension());
|
File aFile = new File(config.getModelClassLocation()+model.getGenratedClassName()+config.getClassFileExtension());
|
||||||
writeFile(aFile, template.toString(), "Wrapper class for test data file");
|
writeFile(aFile, template.toString(), "Wrapper class for test data file");
|
||||||
|
@ -19,6 +19,8 @@ public interface CodeGenOverridingRules {
|
|||||||
|
|
||||||
public String getServiceExtendingClass(String serviceName);
|
public String getServiceExtendingClass(String serviceName);
|
||||||
|
|
||||||
|
public String getModelExtendingClass();
|
||||||
|
|
||||||
public boolean isMethodIgnored(String serviceName, String methodName);
|
public boolean isMethodIgnored(String serviceName, String methodName);
|
||||||
|
|
||||||
public boolean isModelIgnored(String modelName);
|
public boolean isModelIgnored(String modelName);
|
||||||
|
@ -33,6 +33,10 @@ public class JavaCodeGenPverridingRules implements CodeGenOverridingRules {
|
|||||||
return "WordnikAPI";
|
return "WordnikAPI";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getModelExtendingClass() {
|
||||||
|
return "WordnikObject";
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isMethodIgnored(String serviceName, String methodName){
|
public boolean isMethodIgnored(String serviceName, String methodName){
|
||||||
return (ignoreMethods.contains(serviceName+"."+methodName));
|
return (ignoreMethods.contains(serviceName+"."+methodName));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user