Skip to content

Commit f4aee62

Browse files
committed
Merge pull request #775 from wing328/csharp_fix_object_type
[C#] Fix "object' type for response
2 parents 864f0f5 + df4b952 commit f4aee62

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/CSharpClientCodegen.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public CSharpClientCodegen() {
8383
typeMapping.put("file", "string"); // path to file
8484
typeMapping.put("array", "List");
8585
typeMapping.put("map", "Dictionary");
86+
typeMapping.put("object", "Object");
8687

8788
}
8889

modules/swagger-codegen/src/main/resources/csharp/apiInvoker.mustache

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ namespace {{invokerPackage}} {
5353
/// <param name="json"> JSON string
5454
/// <param name="type"> Object type
5555
/// <returns>Object representation of the JSON string</returns>
56-
public static object Deserialize(string json, Type type) {
56+
public static object Deserialize(string content, Type type) {
57+
if (type.GetType() == typeof(Object))
58+
return (Object)content;
59+
5760
try
5861
{
59-
return JsonConvert.DeserializeObject(json, type);
62+
return JsonConvert.DeserializeObject(content, type);
6063
}
6164
catch (IOException e) {
6265
throw new ApiException(500, e.Message);

samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiInvoker.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ public static string ParameterToString(object obj)
5353
/// <param name="json"> JSON string
5454
/// <param name="type"> Object type
5555
/// <returns>Object representation of the JSON string</returns>
56-
public static object Deserialize(string json, Type type) {
56+
public static object Deserialize(string content, Type type) {
57+
if (type.GetType() == typeof(Object))
58+
return (Object)content;
59+
5760
try
5861
{
59-
return JsonConvert.DeserializeObject(json, type);
62+
return JsonConvert.DeserializeObject(content, type);
6063
}
6164
catch (IOException e) {
6265
throw new ApiException(500, e.Message);

0 commit comments

Comments
 (0)