Support model prefix/suffix in Android client

This commit is contained in:
xhh 2016-03-01 12:30:24 +08:00
parent 8e937bd0a8
commit b7280d0af8

View File

@ -73,6 +73,8 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
); );
instantiationTypes.put("array", "ArrayList"); instantiationTypes.put("array", "ArrayList");
instantiationTypes.put("map", "HashMap"); instantiationTypes.put("map", "HashMap");
typeMapping.put("date", "Date");
typeMapping.put("file", "File");
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
@ -143,7 +145,8 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
if (typeMapping.containsKey(swaggerType)) { if (typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType); type = typeMapping.get(swaggerType);
if (languageSpecificPrimitives.contains(type) || type.indexOf(".") >= 0 || if (languageSpecificPrimitives.contains(type) || type.indexOf(".") >= 0 ||
type.equals("Map") || type.equals("List")) { type.equals("Map") || type.equals("List") ||
type.equals("File") || type.equals("Date")) {
return type; return type;
} }
} else { } else {
@ -184,7 +187,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
public String toModelName(String name) { public String toModelName(String name) {
// camelize the model name // camelize the model name
// phone_number => PhoneNumber // phone_number => PhoneNumber
name = camelize(sanitizeName(name)); name = camelize(sanitizeName(modelNamePrefix + name + modelNameSuffix));
// model name cannot use reserved keyword, e.g. return // model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) { if (isReservedWord(name)) {