Skip to content

Commit eeaf832

Browse files
committed
update csharp reserved words with local variable names in api methods
1 parent 22b5f02 commit eeaf832

File tree

13 files changed

+31
-179
lines changed

13 files changed

+31
-179
lines changed

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

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

Lines changed: 0 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -307,42 +307,6 @@ public interface IPetApi
307307
/// <returns>Task of ApiResponse</returns>
308308
System.Threading.Tasks.Task<ApiResponse<Object>> DeletePetAsyncWithHttpInfo (long? petId, string apiKey = null);
309309

310-
/// <summary>
311-
/// downloads an image
312-
/// </summary>
313-
/// <remarks>
314-
///
315-
/// </remarks>
316-
/// <returns>Stream</returns>
317-
Stream DownloadFile ();
318-
319-
/// <summary>
320-
/// downloads an image
321-
/// </summary>
322-
/// <remarks>
323-
///
324-
/// </remarks>
325-
/// <returns>ApiResponse of Stream</returns>
326-
ApiResponse<Stream> DownloadFileWithHttpInfo ();
327-
328-
/// <summary>
329-
/// downloads an image
330-
/// </summary>
331-
/// <remarks>
332-
///
333-
/// </remarks>
334-
/// <returns>Task of Stream</returns>
335-
System.Threading.Tasks.Task<Stream> DownloadFileAsync ();
336-
337-
/// <summary>
338-
/// downloads an image
339-
/// </summary>
340-
/// <remarks>
341-
///
342-
/// </remarks>
343-
/// <returns>Task of ApiResponse (Stream)</returns>
344-
System.Threading.Tasks.Task<ApiResponse<Stream>> DownloadFileAsyncWithHttpInfo ();
345-
346310
/// <summary>
347311
/// uploads an image
348312
/// </summary>
@@ -1523,131 +1487,6 @@ public async System.Threading.Tasks.Task<ApiResponse<Object>> DeletePetAsyncWith
15231487
null);
15241488
}
15251489

1526-
/// <summary>
1527-
/// downloads an image
1528-
/// </summary>
1529-
/// <returns>Stream</returns>
1530-
public Stream DownloadFile ()
1531-
{
1532-
ApiResponse<Stream> response = DownloadFileWithHttpInfo();
1533-
return response.Data;
1534-
}
1535-
1536-
/// <summary>
1537-
/// downloads an image
1538-
/// </summary>
1539-
/// <returns>ApiResponse of Stream</returns>
1540-
public ApiResponse< Stream > DownloadFileWithHttpInfo ()
1541-
{
1542-
1543-
1544-
var path_ = "/pet/{petId}/downloadImage";
1545-
1546-
var pathParams = new Dictionary<String, String>();
1547-
var queryParams = new Dictionary<String, String>();
1548-
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
1549-
var formParams = new Dictionary<String, String>();
1550-
var fileParams = new Dictionary<String, FileParameter>();
1551-
String postBody = null;
1552-
1553-
// to determine the Accept header
1554-
String[] http_header_accepts = new String[] {
1555-
"application/octet-stream"
1556-
};
1557-
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts);
1558-
if (http_header_accept != null)
1559-
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts));
1560-
1561-
// set "format" to json by default
1562-
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
1563-
pathParams.Add("format", "json");
1564-
1565-
1566-
1567-
1568-
1569-
1570-
1571-
1572-
// make the HTTP request
1573-
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
1574-
1575-
int statusCode = (int) response.StatusCode;
1576-
1577-
if (statusCode >= 400)
1578-
throw new ApiException (statusCode, "Error calling DownloadFile: " + response.Content, response.Content);
1579-
else if (statusCode == 0)
1580-
throw new ApiException (statusCode, "Error calling DownloadFile: " + response.ErrorMessage, response.ErrorMessage);
1581-
1582-
return new ApiResponse<Stream>(statusCode,
1583-
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
1584-
(Stream) Configuration.ApiClient.Deserialize(response, typeof(Stream)));
1585-
1586-
}
1587-
1588-
/// <summary>
1589-
/// downloads an image
1590-
/// </summary>
1591-
/// <returns>Task of Stream</returns>
1592-
public async System.Threading.Tasks.Task<Stream> DownloadFileAsync ()
1593-
{
1594-
ApiResponse<Stream> response = await DownloadFileAsyncWithHttpInfo();
1595-
return response.Data;
1596-
1597-
}
1598-
1599-
/// <summary>
1600-
/// downloads an image
1601-
/// </summary>
1602-
/// <returns>Task of ApiResponse (Stream)</returns>
1603-
public async System.Threading.Tasks.Task<ApiResponse<Stream>> DownloadFileAsyncWithHttpInfo ()
1604-
{
1605-
1606-
1607-
var path_ = "/pet/{petId}/downloadImage";
1608-
1609-
var pathParams = new Dictionary<String, String>();
1610-
var queryParams = new Dictionary<String, String>();
1611-
var headerParams = new Dictionary<String, String>();
1612-
var formParams = new Dictionary<String, String>();
1613-
var fileParams = new Dictionary<String, FileParameter>();
1614-
String postBody = null;
1615-
1616-
// to determine the Accept header
1617-
String[] http_header_accepts = new String[] {
1618-
"application/octet-stream"
1619-
};
1620-
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts);
1621-
if (http_header_accept != null)
1622-
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts));
1623-
1624-
// set "format" to json by default
1625-
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
1626-
pathParams.Add("format", "json");
1627-
1628-
1629-
1630-
1631-
1632-
1633-
1634-
1635-
// make the HTTP request
1636-
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
1637-
1638-
int statusCode = (int) response.StatusCode;
1639-
1640-
if (statusCode >= 400)
1641-
throw new ApiException (statusCode, "Error calling DownloadFile: " + response.Content, response.Content);
1642-
else if (statusCode == 0)
1643-
throw new ApiException (statusCode, "Error calling DownloadFile: " + response.ErrorMessage, response.ErrorMessage);
1644-
1645-
return new ApiResponse<Stream>(statusCode,
1646-
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
1647-
(Stream) Configuration.ApiClient.Deserialize(response, typeof(Stream)));
1648-
1649-
}
1650-
16511490
/// <summary>
16521491
/// uploads an image
16531492
/// </summary>

samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace IO.Swagger.Model
1414
///
1515
/// </summary>
1616
[DataContract]
17-
public class Category : IEquatable<Category>
17+
public class Category : IEquatable<Category>
1818
{
1919
/// <summary>
2020
/// Initializes a new instance of the <see cref="Category" /> class.

samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace IO.Swagger.Model
1414
///
1515
/// </summary>
1616
[DataContract]
17-
public class Order : IEquatable<Order>
17+
public class Order : IEquatable<Order>
1818
{
1919
/// <summary>
2020
/// Initializes a new instance of the <see cref="Order" /> class.

samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace IO.Swagger.Model
1414
///
1515
/// </summary>
1616
[DataContract]
17-
public class Pet : IEquatable<Pet>
17+
public class Pet : IEquatable<Pet>
1818
{
1919
/// <summary>
2020
/// Initializes a new instance of the <see cref="Pet" /> class.

samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace IO.Swagger.Model
1414
///
1515
/// </summary>
1616
[DataContract]
17-
public class Tag : IEquatable<Tag>
17+
public class Tag : IEquatable<Tag>
1818
{
1919
/// <summary>
2020
/// Initializes a new instance of the <see cref="Tag" /> class.

samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace IO.Swagger.Model
1414
///
1515
/// </summary>
1616
[DataContract]
17-
public class User : IEquatable<User>
17+
public class User : IEquatable<User>
1818
{
1919
/// <summary>
2020
/// Initializes a new instance of the <see cref="User" /> class.

samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
33
<MonoDevelop.Ide.Workbench ActiveDocument="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs">
44
<Files>
5-
<File FileName="TestConfiguration.cs" Line="17" Column="33" />
6-
<File FileName="TestPet.cs" Line="81" Column="17" />
7-
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs" Line="12" Column="18" />
5+
<File FileName="TestConfiguration.cs" Line="1" Column="1" />
6+
<File FileName="TestPet.cs" Line="1" Column="1" />
7+
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs" Line="15" Column="29" />
88
</Files>
99
</MonoDevelop.Ide.Workbench>
1010
<MonoDevelop.Ide.DebuggingService.Breakpoints>
-3 KB
Binary file not shown.
-678 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)