forked from loafle/openapi-generator-original
Avoid the importPath field
This commit is contained in:
parent
792059f195
commit
312f1c6f25
@ -7,7 +7,7 @@ import java.util.*;
|
||||
|
||||
public class CodegenModel {
|
||||
public String parent;
|
||||
public String name, classname, importPath, description, classVarName, modelJson;
|
||||
public String name, classname, description, classVarName, modelJson;
|
||||
public String defaultValue;
|
||||
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
|
||||
public Set<String> imports = new HashSet<String>();
|
||||
|
@ -61,7 +61,7 @@ public class DefaultCodegen {
|
||||
|
||||
// override with any special handling of the entire swagger spec
|
||||
public void processSwagger(Swagger swagger) {}
|
||||
|
||||
|
||||
// override with any special text escaping logic
|
||||
public String escapeText(String input) {
|
||||
if(input != null) {
|
||||
@ -428,7 +428,6 @@ public class DefaultCodegen {
|
||||
m.name = name;
|
||||
m.description = escapeText(model.getDescription());
|
||||
m.classname = toModelName(name);
|
||||
m.importPath = toModelImport(name);
|
||||
m.classVarName = toVarName(name);
|
||||
m.modelJson = Json.pretty(model);
|
||||
m.externalDocs = model.getExternalDocs();
|
||||
@ -503,18 +502,18 @@ public class DefaultCodegen {
|
||||
if(cp.isContainer != null) {
|
||||
String arrayImport = typeMapping.get("array");
|
||||
if(arrayImport != null &&
|
||||
!languageSpecificPrimitives.contains(arrayImport) &&
|
||||
!languageSpecificPrimitives.contains(arrayImport) &&
|
||||
!defaultIncludes.contains(arrayImport))
|
||||
m.imports.add(arrayImport);
|
||||
}
|
||||
|
||||
if(cp.complexType != null &&
|
||||
!languageSpecificPrimitives.contains(cp.complexType) &&
|
||||
!languageSpecificPrimitives.contains(cp.complexType) &&
|
||||
!defaultIncludes.contains(cp.complexType))
|
||||
m.imports.add(cp.complexType);
|
||||
|
||||
if(cp.baseType != null &&
|
||||
!languageSpecificPrimitives.contains(cp.baseType) &&
|
||||
!languageSpecificPrimitives.contains(cp.baseType) &&
|
||||
!defaultIncludes.contains(cp.baseType))
|
||||
m.imports.add(cp.baseType);
|
||||
}
|
||||
@ -842,7 +841,7 @@ public class DefaultCodegen {
|
||||
op.nickname = op.operationId;
|
||||
|
||||
|
||||
if(op.allParams.size() > 0)
|
||||
if(op.allParams.size() > 0)
|
||||
op.hasParams = true;
|
||||
op.externalDocs = operation.getExternalDocs();
|
||||
|
||||
@ -1081,7 +1080,7 @@ public class DefaultCodegen {
|
||||
operations.put(tag, opList);
|
||||
}
|
||||
opList.add(co);
|
||||
co.baseName = tag;
|
||||
co.baseName = tag;
|
||||
}
|
||||
|
||||
/* underscore and camelize are copied from Twitter elephant bird
|
||||
|
@ -428,6 +428,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
CodegenModel cm = config.fromModel(key, mm);
|
||||
Map<String, Object> mo = new HashMap<String, Object>();
|
||||
mo.put("model", cm);
|
||||
mo.put("importPath", config.toModelImport(key));
|
||||
models.add(mo);
|
||||
allImports.addAll(cm.imports);
|
||||
}
|
||||
|
@ -9,9 +9,7 @@ require '{{gemName}}/swagger/version'
|
||||
# Models
|
||||
require '{{modelPackage}}/base_object'
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
require '{{importPath}}'
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
||||
# APIs
|
||||
|
Loading…
x
Reference in New Issue
Block a user