Merge pull request #775 from wing328/csharp_fix_object_type

[C#] Fix "object' type for response
This commit is contained in:
Tony Tam 2015-05-23 08:43:14 -07:00
commit f4aee62fb4
3 changed files with 11 additions and 4 deletions

View File

@ -83,6 +83,7 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("file", "string"); // path to file typeMapping.put("file", "string"); // path to file
typeMapping.put("array", "List"); typeMapping.put("array", "List");
typeMapping.put("map", "Dictionary"); typeMapping.put("map", "Dictionary");
typeMapping.put("object", "Object");
} }

View File

@ -53,10 +53,13 @@ namespace {{invokerPackage}} {
/// <param name="json"> JSON string /// <param name="json"> JSON string
/// <param name="type"> Object type /// <param name="type"> Object type
/// <returns>Object representation of the JSON string</returns> /// <returns>Object representation of the JSON string</returns>
public static object Deserialize(string json, Type type) { public static object Deserialize(string content, Type type) {
if (type.GetType() == typeof(Object))
return (Object)content;
try try
{ {
return JsonConvert.DeserializeObject(json, type); return JsonConvert.DeserializeObject(content, type);
} }
catch (IOException e) { catch (IOException e) {
throw new ApiException(500, e.Message); throw new ApiException(500, e.Message);

View File

@ -53,10 +53,13 @@ namespace IO.Swagger.Client {
/// <param name="json"> JSON string /// <param name="json"> JSON string
/// <param name="type"> Object type /// <param name="type"> Object type
/// <returns>Object representation of the JSON string</returns> /// <returns>Object representation of the JSON string</returns>
public static object Deserialize(string json, Type type) { public static object Deserialize(string content, Type type) {
if (type.GetType() == typeof(Object))
return (Object)content;
try try
{ {
return JsonConvert.DeserializeObject(json, type); return JsonConvert.DeserializeObject(content, type);
} }
catch (IOException e) { catch (IOException e) {
throw new ApiException(500, e.Message); throw new ApiException(500, e.Message);