mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 19:33:55 +00:00
Ruby client: handle reserved words for model names
This commit is contained in:
parent
52c9d67025
commit
748c032d41
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user