add null/nil as reserved keyword (#5647)

This commit is contained in:
wing328 2017-05-16 00:02:27 +08:00 committed by GitHub
parent 5b250aa18f
commit 63facc0b0b
5 changed files with 17 additions and 4 deletions

View File

@ -64,7 +64,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient", "import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static", "catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float", "void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
"native", "super", "while") "native", "super", "while", "null")
); );
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<String>(

View File

@ -69,6 +69,17 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
typeMapping.put("file", "file"); typeMapping.put("file", "file");
typeMapping.put("UUID", "str"); typeMapping.put("UUID", "str");
// from https://docs.python.org/release/2.5.4/ref/keywords.html
setReservedWordsLowerCase(
Arrays.asList(
// @property
"property",
// python reserved words
"and", "del", "from", "not", "while", "as", "elif", "global", "or", "with",
"assert", "else", "if", "pass", "yield", "break", "except", "import",
"print", "class", "exec", "in", "raise", "continue", "finally", "is",
"return", "def", "for", "lambda", "try", "self", "None"));
// set the output folder here // set the output folder here
outputFolder = "generated-code/connexion"; outputFolder = "generated-code/connexion";

View File

@ -56,7 +56,8 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
"case", "defer", "go", "map", "struct", "case", "defer", "go", "map", "struct",
"chan", "else", "goto", "package", "switch", "chan", "else", "goto", "package", "switch",
"const", "fallthrough", "if", "range", "type", "const", "fallthrough", "if", "range", "type",
"continue", "for", "import", "return", "var", "error", "ApiResponse") "continue", "for", "import", "return", "var", "error", "ApiResponse",
"nil")
// Added "error" as it's used so frequently that it may as well be a keyword // Added "error" as it's used so frequently that it may as well be a keyword
); );

View File

@ -68,7 +68,8 @@ public class GoServerCodegen extends DefaultCodegen implements CodegenConfig {
"case", "defer", "go", "map", "struct", "case", "defer", "go", "map", "struct",
"chan", "else", "goto", "package", "switch", "chan", "else", "goto", "package", "switch",
"const", "fallthrough", "if", "range", "type", "const", "fallthrough", "if", "range", "type",
"continue", "for", "import", "return", "var", "error", "ApiResponse") "continue", "for", "import", "return", "var", "error", "ApiResponse",
"nil")
// Added "error" as it's used so frequently that it may as well be a keyword // Added "error" as it's used so frequently that it may as well be a keyword
); );

View File

@ -101,7 +101,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
"and", "del", "from", "not", "while", "as", "elif", "global", "or", "with", "and", "del", "from", "not", "while", "as", "elif", "global", "or", "with",
"assert", "else", "if", "pass", "yield", "break", "except", "import", "assert", "else", "if", "pass", "yield", "break", "except", "import",
"print", "class", "exec", "in", "raise", "continue", "finally", "is", "print", "class", "exec", "in", "raise", "continue", "finally", "is",
"return", "def", "for", "lambda", "try", "self")); "return", "def", "for", "lambda", "try", "self", "None"));
regexModifiers = new HashMap<Character, String>(); regexModifiers = new HashMap<Character, String>();
regexModifiers.put('i', "IGNORECASE"); regexModifiers.put('i', "IGNORECASE");