Skip to content

Commit ab91fc8

Browse files
committed
Merge pull request #1824 from wing328/php_update_reserved_wrod
Update reserved word list to include local variable names in API methods
2 parents 19ff7dc + 61bf45b commit ab91fc8

File tree

29 files changed

+144
-221
lines changed

29 files changed

+144
-221
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ public CodegenType getTag() {
1717
public AbstractTypeScriptClientCodegen() {
1818
super();
1919
supportsInheritance = true;
20-
reservedWords = new HashSet<String>(Arrays.asList("abstract", "await", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "yield"));
20+
reservedWords = new HashSet<String>(Arrays.asList(
21+
// local variable names used in API methods (endpoints)
22+
"path", "queryParameters", "headerParams", "formParams", "useFormData", "deferred",
23+
"requestOptions",
24+
// Typescript reserved words
25+
"abstract", "await", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "yield"));
2126

2227
languageSpecificPrimitives = new HashSet<String>(Arrays.asList(
2328
"String",

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,20 @@ public CSharpClientCodegen() {
4545

4646
reservedWords = new HashSet<String>(
4747
Arrays.asList(
48-
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while")
48+
// local variable names in API methods (endpoints)
49+
"path_", "pathParams", "queryParams", "headerParams", "formParams", "fileParams",
50+
"postBody", "http_header_accepts", "http_header_accept", "apiKeyValue", "response",
51+
"statusCode",
52+
// C# reserved words
53+
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked",
54+
"class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else",
55+
"enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for",
56+
"foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock",
57+
"long", "namespace", "new", "null", "object", "operator", "out", "override", "params",
58+
"private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed",
59+
"short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw",
60+
"true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using",
61+
"virtual", "void", "volatile", "while")
4962
);
5063

5164

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CsharpDotNet2ClientCodegen.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ public CsharpDotNet2ClientCodegen() {
3333

3434
reservedWords = new HashSet<String>(
3535
Arrays.asList(
36-
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while")
36+
// local variable names in API methods (endpoints)
37+
"path", "queryParams", "headerParams", "formParams", "fileParams", "postBody",
38+
"authSettings", "response", "StatusCode",
39+
// C# reserved word
40+
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while")
3741
);
3842

3943

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,24 @@ public ObjcClientCodegen() {
8989
// ref: http://www.tutorialspoint.com/objective_c/objective_c_basic_syntax.htm
9090
reservedWords = new HashSet<String>(
9191
Arrays.asList(
92-
"auto", "else", "long", "switch",
93-
"break", "enum", "register", "typedef",
94-
"case", "extern", "return", "union",
95-
"char", "float", "short", "unsigned",
96-
"const", "for", "signed", "void",
97-
"continue", "goto", "sizeof", "volatile",
98-
"default", "if", "id", "static", "while",
99-
"do", "int", "struct", "_Packed",
100-
"double", "protocol", "interface", "implementation",
101-
"NSObject", "NSInteger", "NSNumber", "CGFloat",
102-
"property", "nonatomic", "retain", "strong",
103-
"weak", "unsafe_unretained", "readwrite", "readonly",
104-
"description"
92+
// local variable names in API methods (endpoints)
93+
"resourcePath", "pathParams", "queryParams", "headerParams",
94+
"responseContentType", "requestContentType", "authSettings",
95+
"formParams", "files", "bodyParam",
96+
// objc reserved words
97+
"auto", "else", "long", "switch",
98+
"break", "enum", "register", "typedef",
99+
"case", "extern", "return", "union",
100+
"char", "float", "short", "unsigned",
101+
"const", "for", "signed", "void",
102+
"continue", "goto", "sizeof", "volatile",
103+
"default", "if", "id", "static", "while",
104+
"do", "int", "struct", "_Packed",
105+
"double", "protocol", "interface", "implementation",
106+
"NSObject", "NSInteger", "NSNumber", "CGFloat",
107+
"property", "nonatomic", "retain", "strong",
108+
"weak", "unsafe_unretained", "readwrite", "readonly",
109+
"description"
105110
));
106111

107112
importMapping = new HashMap<String, String>();

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ public PhpClientCodegen() {
4747

4848
reservedWords = new HashSet<String>(
4949
Arrays.asList(
50-
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor")
50+
// local variables used in api methods (endpoints)
51+
"resourcePath", "method", "httpBody", "queryParams", "headerParams",
52+
"formParams", "_header_accept", "_tempBody",
53+
54+
// PHP reserved words
55+
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor")
5156
);
5257

5358
// ref: http://php.net/manual/en/language.types.intro.php

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ public PythonClientCodegen() {
5555
// from https://docs.python.org/release/2.5.4/ref/keywords.html
5656
reservedWords = new HashSet<String>(
5757
Arrays.asList(
58-
"and", "del", "from", "not", "while", "as", "elif", "global", "or", "with",
59-
"assert", "else", "if", "pass", "yield", "break", "except", "import",
60-
"print", "class", "exec", "in", "raise", "continue", "finally", "is",
61-
"return", "def", "for", "lambda", "try", "self"));
58+
// local variable name used in API methods (endpoints)
59+
"all_params", "resource_path", "method", "path_params", "query_params",
60+
"header_params", "form_params", "files", "body_params", "auth_settings",
61+
// python reserved words
62+
"and", "del", "from", "not", "while", "as", "elif", "global", "or", "with",
63+
"assert", "else", "if", "pass", "yield", "break", "except", "import",
64+
"print", "class", "exec", "in", "raise", "continue", "finally", "is",
65+
"return", "def", "for", "lambda", "try", "self"));
6266

6367
cliOptions.clear();
6468
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "python package name (convention: snake_case).")

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@ public RubyClientCodegen() {
3838

3939
reservedWords = new HashSet<String>(
4040
Arrays.asList(
41-
"__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",
42-
"begin", "defined?", "ensure", "module", "redo", "super", "until", "BEGIN",
43-
"break", "do", "false", "next", "rescue", "then", "when", "END", "case",
44-
"else", "for", "nil", "retry", "true", "while", "alias", "class", "elsif",
45-
"if", "not", "return", "undef", "yield")
41+
// local variable names used in API methods (endpoints)
42+
"path", "query_params", "header_params", "_header_accept", "_header_accept_result",
43+
"_header_content_type", "form_params", "post_body", "auth_names",
44+
// ruby reserved keywords
45+
"__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",
46+
"begin", "defined?", "ensure", "module", "redo", "super", "until", "BEGIN",
47+
"break", "do", "false", "next", "rescue", "then", "when", "END", "case",
48+
"else", "for", "nil", "retry", "true", "while", "alias", "class", "elsif",
49+
"if", "not", "return", "undef", "yield")
4650
);
4751

4852
languageSpecificPrimitives.add("int");

samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Api/PetApi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public Pet GetPetById (long? petId)
317317

318318

319319
// authentication setting, if any
320-
String[] authSettings = new String[] { "api_key", "petstore_auth" };
320+
String[] authSettings = new String[] { "api_key" };
321321

322322
// make the HTTP request
323323
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Api/UserApi.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public interface IUserApi
4949
/// <summary>
5050
/// Get user by user name
5151
/// </summary>
52-
/// <param name="username">The name that needs to be fetched. Use user1 for testing. </param>
52+
/// <param name="username">The name that needs to be fetched. Use user1 for testing.</param>
5353
/// <returns>User</returns>
5454
User GetUserByName (string username);
5555

@@ -327,7 +327,7 @@ public void LogoutUser ()
327327
/// <summary>
328328
/// Get user by user name
329329
/// </summary>
330-
/// <param name="username">The name that needs to be fetched. Use user1 for testing. </param>
330+
/// <param name="username">The name that needs to be fetched. Use user1 for testing.</param>
331331
/// <returns>User</returns>
332332
public User GetUserByName (string username)
333333
{

samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Client/ApiClient.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public FileParameter ParameterToFile(string name, Stream stream)
134134
}
135135

136136
/// <summary>
137-
/// If parameter is DateTime, output in ISO8601 format.
137+
/// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime.
138138
/// If parameter is a list of string, join the list with ",".
139139
/// Otherwise just return the string.
140140
/// </summary>
@@ -143,7 +143,11 @@ public FileParameter ParameterToFile(string name, Stream stream)
143143
public string ParameterToString(object obj)
144144
{
145145
if (obj is DateTime)
146-
return ((DateTime)obj).ToString ("u");
146+
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
147+
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
148+
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
149+
// For example: 2009-06-15T13:45:30.0000000
150+
return ((DateTime)obj).ToString (Configuration.DateTimeFormat);
147151
else if (obj is List<string>)
148152
return String.Join(",", (obj as List<string>).ToArray());
149153
else

0 commit comments

Comments
 (0)