fix reserved word handling in model name (sinatra)

This commit is contained in:
wing328 2016-10-18 18:51:08 +08:00
parent 702344ed75
commit b50b33e891

View File

@ -195,7 +195,8 @@ public class SinatraServerCodegen extends DefaultCodegen implements CodegenConfi
public String toModelFilename(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + underscore("model_" + name));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// underscore the model file name