forked from loafle/openapi-generator-original
Merge pull request #775 from wing328/csharp_fix_object_type
[C#] Fix "object' type for response
This commit is contained in:
commit
f4aee62fb4
@ -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");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user