Skip to content

Commit

Permalink
Fix inconsistency between model name and file name in python client (#…
Browse files Browse the repository at this point in the history
…7684)

Fixes issue #7357 using the same fix as #4958
  • Loading branch information
banh-gao authored and wing328 committed Feb 22, 2018
1 parent 92117b8 commit b39c35c
Showing 1 changed file with 1 addition and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -456,33 +456,9 @@ public String toModelName(String name) {

@Override
public String toModelFilename(String name) {
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
// remove dollar sign
name = name.replaceAll("$", "");

// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + underscore(dropDots("model_" + name)));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}

// model name starts with number
if (name.matches("^\\d.*")) {
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + underscore("model_" + name));
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}

if (!StringUtils.isEmpty(modelNamePrefix)) {
name = modelNamePrefix + "_" + name;
}

if (!StringUtils.isEmpty(modelNameSuffix)) {
name = name + "_" + modelNameSuffix;
}

// underscore the model file name
// PhoneNumber => phone_number
return underscore(dropDots(name));
return underscore(dropDots(toModelName(name)));
}

@Override
Expand Down

0 comments on commit b39c35c

Please sign in to comment.