From 6b85416f47a583aaf5b661515c3e5f5bde5f6818 Mon Sep 17 00:00:00 2001 From: Pierre Lamot Date: Wed, 19 Jul 2017 10:04:27 +0200 Subject: [PATCH 1/2] [Flask] self and None are reserved words (#6111) * setReservedWordsLowerCase was called twice, the second time without self and None * True, False and nonlocal are python3 reserved words --- .../codegen/languages/FlaskConnexionCodegen.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlaskConnexionCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlaskConnexionCodegen.java index bf1d638bc5e..efaee9eb05f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlaskConnexionCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlaskConnexionCodegen.java @@ -69,7 +69,7 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf typeMapping.put("file", "file"); typeMapping.put("UUID", "str"); - // from https://docs.python.org/release/2.5.4/ref/keywords.html + // from https://docs.python.org/3/reference/lexical_analysis.html#keywords setReservedWordsLowerCase( Arrays.asList( // @property @@ -78,7 +78,7 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf "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")); + "return", "def", "for", "lambda", "try", "self", "None", "True", "False", "nonlocal")); // set the output folder here outputFolder = "generated-code/connexion"; @@ -93,14 +93,6 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf */ embeddedTemplateDir = templateDir = "flaskConnexion"; - // from https://docs.python.org/release/2.5.4/ref/keywords.html - setReservedWordsLowerCase( - Arrays.asList( - "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")); - /* * Additional Properties. These values can be passed to the templates and * are available in models, apis, and supporting files From 9e51c45dd2dd1b011147428765c0b7c14a38d411 Mon Sep 17 00:00:00 2001 From: Pierre Lamot Date: Wed, 19 Jul 2017 11:16:20 +0200 Subject: [PATCH 2/2] [Python] True, False, nonlocal are python3 reserved words (#6111) --- .../io/swagger/codegen/languages/PythonClientCodegen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index ca0f59ec76b..a5c69c7a4b8 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -90,7 +90,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig // map uuid to string for the time being typeMapping.put("UUID", "str"); - // from https://docs.python.org/release/2.5.4/ref/keywords.html + // from https://docs.python.org/3/reference/lexical_analysis.html#keywords setReservedWordsLowerCase( Arrays.asList( // local variable name used in API methods (endpoints) @@ -102,7 +102,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig "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")); + "return", "def", "for", "lambda", "try", "self", "nonlocal", "None", "True", "False")); regexModifiers = new HashMap(); regexModifiers.put('i', "IGNORECASE");