From 748c032d4115a71a17f83765dd67da9d592886c2 Mon Sep 17 00:00:00 2001 From: xhh Date: Thu, 25 Feb 2016 14:36:47 +0800 Subject: [PATCH] Ruby client: handle reserved words for model names --- .../io/swagger/codegen/languages/RubyClientCodegen.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index 62e387a4a5..83cecabfbb 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -360,7 +360,9 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { // model name cannot use reserved keyword, e.g. return if (reservedWords.contains(name)) { - throw new RuntimeException(name + " (reserved word) cannot be used as a model name"); + String modelName = camelize("object_" + name); + LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName); + return modelName; } // camelize the model name @@ -372,7 +374,9 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { public String toModelFilename(String name) { // model name cannot use reserved keyword, e.g. return if (reservedWords.contains(name)) { - throw new RuntimeException(name + " (reserved word) cannot be used as a model name"); + String filename = underscore("object_" + name); + LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + filename); + return filename; } // underscore the model file name