forked from loafle/openapi-generator-original
Remove dots and dashes from model names
This commit is contained in:
parent
569d458bc9
commit
c49b22bcdd
@ -249,7 +249,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
Property inner = mp.getAdditionalProperties();
|
Property inner = mp.getAdditionalProperties();
|
||||||
return "Map.Map String " + getTypeDeclaration(inner);
|
return "Map.Map String " + getTypeDeclaration(inner);
|
||||||
}
|
}
|
||||||
return super.getTypeDeclaration(p);
|
return fixModelChars(super.getTypeDeclaration(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -459,11 +459,19 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove characters from a string that do not belong in a model classname
|
||||||
|
private String fixModelChars(String string) {
|
||||||
|
return string.replace(".", "").replace("-", "");
|
||||||
|
}
|
||||||
|
|
||||||
// Override fromModel to create the appropriate model namings
|
// Override fromModel to create the appropriate model namings
|
||||||
@Override
|
@Override
|
||||||
public CodegenModel fromModel(String name, Model mod, Map<String, Model> allDefinitions) {
|
public CodegenModel fromModel(String name, Model mod, Map<String, Model> allDefinitions) {
|
||||||
CodegenModel model = super.fromModel(name, mod, allDefinitions);
|
CodegenModel model = super.fromModel(name, mod, allDefinitions);
|
||||||
|
|
||||||
|
// Clean up the class name to remove invalid characters
|
||||||
|
model.classname = fixModelChars(model.classname);
|
||||||
|
|
||||||
// From the model name, compute the prefix for the fields.
|
// From the model name, compute the prefix for the fields.
|
||||||
String prefix = camelize(model.classname, true);
|
String prefix = camelize(model.classname, true);
|
||||||
for(CodegenProperty prop : model.vars) {
|
for(CodegenProperty prop : model.vars) {
|
||||||
@ -491,5 +499,4 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
p.vendorExtensions.put("x-formParamName", camelize(p.baseName));
|
p.vendorExtensions.put("x-formParamName", camelize(p.baseName));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user