diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java
index 78b5560d53d..ea396618db9 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java
@@ -276,14 +276,15 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
@Override
public String toOperationId(String operationId) {
- // throw exception if method name is empty
+ // throw exception if method name is empty (should not occur as an auto-generated method name will be used)
if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method name (operationId) not allowed");
}
// method name cannot use reserved keyword, e.g. return
if (reservedWords.contains(operationId)) {
- throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
+ LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
+ operationId = "call_" + operationId;
}
return camelize(sanitizeName(operationId));
@@ -471,7 +472,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
// 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");
+ LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("object_" + name));
+ name = "object_" + name; // e.g. return => ObjectReturn (after camelize)
}
// camelize the model name
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetApiTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetApiTests.cs
index a7caec2f54c..7e3566eb04b 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetApiTests.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetApiTests.cs
@@ -156,15 +156,15 @@ namespace IO.Swagger.Test
}
///
- /// Test GetPetByIdWithByteArray
+ /// Test PetPetIdtestingByteArraytrueGet
///
[Test]
- public void GetPetByIdWithByteArrayTest()
+ public void PetPetIdtestingByteArraytrueGetTest()
{
- // TODO: add unit test for the method 'GetPetByIdWithByteArray'
+ // TODO: add unit test for the method 'PetPetIdtestingByteArraytrueGet'
long? petId = null; // TODO: replace null with proper value
- var response = instance.GetPetByIdWithByteArray(petId);
+ var response = instance.PetPetIdtestingByteArraytrueGet(petId);
Assert.IsInstanceOf (response, "response is byte[]");
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs
index 5ef6e286a8d..2b44e177625 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs
@@ -212,7 +212,7 @@ namespace IO.Swagger.Api
/// Thrown when fails to make API call
/// ID of pet that needs to be fetched
/// byte[]
- byte[] GetPetByIdWithByteArray (long? petId);
+ byte[] PetPetIdtestingByteArraytrueGet (long? petId);
///
/// Fake endpoint to test byte array return by 'Find pet by ID'
@@ -223,7 +223,7 @@ namespace IO.Swagger.Api
/// Thrown when fails to make API call
/// ID of pet that needs to be fetched
/// ApiResponse of byte[]
- ApiResponse GetPetByIdWithByteArrayWithHttpInfo (long? petId);
+ ApiResponse PetPetIdtestingByteArraytrueGetWithHttpInfo (long? petId);
///
/// Fake endpoint to test byte array in body parameter for adding a new pet to the store
@@ -446,7 +446,7 @@ namespace IO.Swagger.Api
/// Thrown when fails to make API call
/// ID of pet that needs to be fetched
/// Task of byte[]
- System.Threading.Tasks.Task GetPetByIdWithByteArrayAsync (long? petId);
+ System.Threading.Tasks.Task PetPetIdtestingByteArraytrueGetAsync (long? petId);
///
/// Fake endpoint to test byte array return by 'Find pet by ID'
@@ -457,7 +457,7 @@ namespace IO.Swagger.Api
/// Thrown when fails to make API call
/// ID of pet that needs to be fetched
/// Task of ApiResponse (byte[])
- System.Threading.Tasks.Task> GetPetByIdWithByteArrayAsyncWithHttpInfo (long? petId);
+ System.Threading.Tasks.Task> PetPetIdtestingByteArraytrueGetAsyncWithHttpInfo (long? petId);
///
/// Fake endpoint to test byte array in body parameter for adding a new pet to the store
@@ -1972,9 +1972,9 @@ namespace IO.Swagger.Api
/// Thrown when fails to make API call
/// ID of pet that needs to be fetched
/// byte[]
- public byte[] GetPetByIdWithByteArray (long? petId)
+ public byte[] PetPetIdtestingByteArraytrueGet (long? petId)
{
- ApiResponse response = GetPetByIdWithByteArrayWithHttpInfo(petId);
+ ApiResponse response = PetPetIdtestingByteArraytrueGetWithHttpInfo(petId);
return response.Data;
}
@@ -1984,12 +1984,12 @@ namespace IO.Swagger.Api
/// Thrown when fails to make API call
/// ID of pet that needs to be fetched
/// ApiResponse of byte[]
- public ApiResponse< byte[] > GetPetByIdWithByteArrayWithHttpInfo (long? petId)
+ public ApiResponse< byte[] > PetPetIdtestingByteArraytrueGetWithHttpInfo (long? petId)
{
// verify the required parameter 'petId' is set
if (petId == null)
- throw new ApiException(400, "Missing required parameter 'petId' when calling PetApi->GetPetByIdWithByteArray");
+ throw new ApiException(400, "Missing required parameter 'petId' when calling PetApi->PetPetIdtestingByteArraytrueGet");
var path_ = "/pet/{petId}?testing_byte_array=true";
@@ -2048,9 +2048,9 @@ namespace IO.Swagger.Api
int statusCode = (int) response.StatusCode;
if (statusCode >= 400)
- throw new ApiException (statusCode, "Error calling GetPetByIdWithByteArray: " + response.Content, response.Content);
+ throw new ApiException (statusCode, "Error calling PetPetIdtestingByteArraytrueGet: " + response.Content, response.Content);
else if (statusCode == 0)
- throw new ApiException (statusCode, "Error calling GetPetByIdWithByteArray: " + response.ErrorMessage, response.ErrorMessage);
+ throw new ApiException (statusCode, "Error calling PetPetIdtestingByteArraytrueGet: " + response.ErrorMessage, response.ErrorMessage);
return new ApiResponse(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
@@ -2065,9 +2065,9 @@ namespace IO.Swagger.Api
/// Thrown when fails to make API call
/// ID of pet that needs to be fetched
/// Task of byte[]
- public async System.Threading.Tasks.Task GetPetByIdWithByteArrayAsync (long? petId)
+ public async System.Threading.Tasks.Task PetPetIdtestingByteArraytrueGetAsync (long? petId)
{
- ApiResponse response = await GetPetByIdWithByteArrayAsyncWithHttpInfo(petId);
+ ApiResponse response = await PetPetIdtestingByteArraytrueGetAsyncWithHttpInfo(petId);
return response.Data;
}
@@ -2078,10 +2078,10 @@ namespace IO.Swagger.Api
/// Thrown when fails to make API call
/// ID of pet that needs to be fetched
/// Task of ApiResponse (byte[])
- public async System.Threading.Tasks.Task> GetPetByIdWithByteArrayAsyncWithHttpInfo (long? petId)
+ public async System.Threading.Tasks.Task> PetPetIdtestingByteArraytrueGetAsyncWithHttpInfo (long? petId)
{
// verify the required parameter 'petId' is set
- if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetByIdWithByteArray");
+ if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling PetPetIdtestingByteArraytrueGet");
var path_ = "/pet/{petId}?testing_byte_array=true";
@@ -2142,9 +2142,9 @@ namespace IO.Swagger.Api
int statusCode = (int) response.StatusCode;
if (statusCode >= 400)
- throw new ApiException (statusCode, "Error calling GetPetByIdWithByteArray: " + response.Content, response.Content);
+ throw new ApiException (statusCode, "Error calling PetPetIdtestingByteArraytrueGet: " + response.Content, response.Content);
else if (statusCode == 0)
- throw new ApiException (statusCode, "Error calling GetPetByIdWithByteArray: " + response.ErrorMessage, response.ErrorMessage);
+ throw new ApiException (statusCode, "Error calling PetPetIdtestingByteArraytrueGet: " + response.ErrorMessage, response.ErrorMessage);
return new ApiResponse(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs
index 98bc9083d66..23716351001 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs
@@ -1,8 +1,8 @@
-
+
-
+
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs
index 640d24250d9..24934702118 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs
@@ -168,7 +168,7 @@ namespace SwaggerClientTest.TestPet
Configuration c1 = new Configuration (timeout: 10000);
PetApi petApi = new PetApi (c1);
- byte[] response = petApi.GetPetByIdWithByteArray (petId);
+ byte[] response = petApi.PetPetIdtestingByteArraytrueGet (petId);
Assert.IsInstanceOf (response, "Response is byte array");
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt
index f115c595d6a..323cad108c6 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt
+++ b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt
@@ -1,9 +1,9 @@
-/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
-/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.swagger-logo.png
-/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb
-/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll
-/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll
-/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb
-/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
-/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
-/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll
+/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
+/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.swagger-logo.png
+/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb
+/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll
+/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll
+/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb
+/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
+/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
+/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll