diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
index 60b573e1a6c..bf6b5a3cc74 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
@@ -241,16 +241,10 @@ namespace {{packageName}}.Client
/// Object representation of the JSON string.
public object Deserialize(IRestResponse response, Type type)
{
- byte[] data = response.RawBytes;
- string content = response.Content;
IList headers = response.Headers;
- if (type == typeof(Object)) // return an object
+ if (type == typeof(byte[])) // return byte array
{
- return content;
- }
- else if (type == typeof(byte[])) // return byte array
- {
- return data;
+ return response.RawBytes;
}
if (type == typeof(Stream))
@@ -267,29 +261,29 @@ namespace {{packageName}}.Client
if (match.Success)
{
string fileName = filePath + SanitizeFilename(match.Groups[1].Value.Replace("\"", "").Replace("'", ""));
- File.WriteAllBytes(fileName, data);
+ File.WriteAllBytes(fileName, response.RawBytes);
return new FileStream(fileName, FileMode.Open);
}
}
}
- var stream = new MemoryStream(data);
+ var stream = new MemoryStream(response.RawBytes);
return stream;
}
if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
{
- return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
+ return DateTime.Parse(response.Content, null, System.Globalization.DateTimeStyles.RoundtripKind);
}
if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type
{
- return ConvertType(content, type);
+ return ConvertType(response.Content, type);
}
// at this point, it must be a model (json)
try
{
- return JsonConvert.DeserializeObject(content, type);
+ return JsonConvert.DeserializeObject(response.Content, type);
}
catch (Exception e)
{
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs
index 104911520a6..ac2c7eda793 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs
@@ -241,16 +241,10 @@ namespace IO.Swagger.Client
/// Object representation of the JSON string.
public object Deserialize(IRestResponse response, Type type)
{
- byte[] data = response.RawBytes;
- string content = response.Content;
IList headers = response.Headers;
- if (type == typeof(Object)) // return an object
+ if (type == typeof(byte[])) // return byte array
{
- return content;
- }
- else if (type == typeof(byte[])) // return byte array
- {
- return data;
+ return response.RawBytes;
}
if (type == typeof(Stream))
@@ -267,29 +261,29 @@ namespace IO.Swagger.Client
if (match.Success)
{
string fileName = filePath + SanitizeFilename(match.Groups[1].Value.Replace("\"", "").Replace("'", ""));
- File.WriteAllBytes(fileName, data);
+ File.WriteAllBytes(fileName, response.RawBytes);
return new FileStream(fileName, FileMode.Open);
}
}
}
- var stream = new MemoryStream(data);
+ var stream = new MemoryStream(response.RawBytes);
return stream;
}
if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
{
- return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
+ return DateTime.Parse(response.Content, null, System.Globalization.DateTimeStyles.RoundtripKind);
}
if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type
{
- return ConvertType(content, type);
+ return ConvertType(response.Content, type);
}
// at this point, it must be a model (json)
try
{
- return JsonConvert.DeserializeObject(content, type);
+ return JsonConvert.DeserializeObject(response.Content, type);
}
catch (Exception e)
{
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/InlineResponse200.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/InlineResponse200.cs
index d575b7e46a8..53d161c1ab6 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/InlineResponse200.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/InlineResponse200.cs
@@ -18,15 +18,38 @@ namespace IO.Swagger.Model
public partial class InlineResponse200 : IEquatable
{
+ [JsonConverter(typeof(StringEnumConverter))]
+ public enum StatusEnum {
+
+ [EnumMember(Value = "available")]
+ Available,
+
+ [EnumMember(Value = "pending")]
+ Pending,
+
+ [EnumMember(Value = "sold")]
+ Sold
+ }
+
+ ///
+ /// pet status in the store
+ ///
+ /// pet status in the store
+ [DataMember(Name="status", EmitDefaultValue=false)]
+ public StatusEnum? Status { get; set; }
+
///
/// Initializes a new instance of the class.
/// Initializes a new instance of the class.
///
+ /// Tags.
/// Id (required).
/// Category.
+ /// pet status in the store.
/// Name.
+ /// PhotoUrls.
- public InlineResponse200(long? Id = null, Object Category = null, string Name = null)
+ public InlineResponse200(List Tags = null, long? Id = null, Object Category = null, StatusEnum? Status = null, string Name = null, List PhotoUrls = null)
{
// to ensure "Id" is required (not null)
if (Id == null)
@@ -37,12 +60,21 @@ namespace IO.Swagger.Model
{
this.Id = Id;
}
+ this.Tags = Tags;
this.Category = Category;
+ this.Status = Status;
this.Name = Name;
+ this.PhotoUrls = PhotoUrls;
}
+ ///
+ /// Gets or Sets Tags
+ ///
+ [DataMember(Name="tags", EmitDefaultValue=false)]
+ public List Tags { get; set; }
+
///
/// Gets or Sets Id
///
@@ -61,6 +93,12 @@ namespace IO.Swagger.Model
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
+ ///
+ /// Gets or Sets PhotoUrls
+ ///
+ [DataMember(Name="photoUrls", EmitDefaultValue=false)]
+ public List PhotoUrls { get; set; }
+
///
/// Returns the string presentation of the object
///
@@ -69,9 +107,12 @@ namespace IO.Swagger.Model
{
var sb = new StringBuilder();
sb.Append("class InlineResponse200 {\n");
+ sb.Append(" Tags: ").Append(Tags).Append("\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Category: ").Append(Category).Append("\n");
+ sb.Append(" Status: ").Append(Status).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
+ sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n");
sb.Append("}\n");
return sb.ToString();
@@ -109,6 +150,11 @@ namespace IO.Swagger.Model
return false;
return
+ (
+ this.Tags == other.Tags ||
+ this.Tags != null &&
+ this.Tags.SequenceEqual(other.Tags)
+ ) &&
(
this.Id == other.Id ||
this.Id != null &&
@@ -119,10 +165,20 @@ namespace IO.Swagger.Model
this.Category != null &&
this.Category.Equals(other.Category)
) &&
+ (
+ this.Status == other.Status ||
+ this.Status != null &&
+ this.Status.Equals(other.Status)
+ ) &&
(
this.Name == other.Name ||
this.Name != null &&
this.Name.Equals(other.Name)
+ ) &&
+ (
+ this.PhotoUrls == other.PhotoUrls ||
+ this.PhotoUrls != null &&
+ this.PhotoUrls.SequenceEqual(other.PhotoUrls)
);
}
@@ -138,15 +194,24 @@ namespace IO.Swagger.Model
int hash = 41;
// Suitable nullity checks etc, of course :)
+ if (this.Tags != null)
+ hash = hash * 59 + this.Tags.GetHashCode();
+
if (this.Id != null)
hash = hash * 59 + this.Id.GetHashCode();
if (this.Category != null)
hash = hash * 59 + this.Category.GetHashCode();
+ if (this.Status != null)
+ hash = hash * 59 + this.Status.GetHashCode();
+
if (this.Name != null)
hash = hash * 59 + this.Name.GetHashCode();
+ if (this.PhotoUrls != null)
+ hash = hash * 59 + this.PhotoUrls.GetHashCode();
+
return hash;
}
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs
index 2e3f974728e..e6c1146e4f5 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs
@@ -1,11 +1,17 @@
-
+
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestOrder.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestOrder.cs
index 3fde9520e07..f66e34a5e9e 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/TestOrder.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/TestOrder.cs
@@ -10,7 +10,7 @@ using System.Reflection;
using Newtonsoft.Json;
-namespace SwaggerClientTest.TestORder
+namespace SwaggerClientTest.TestOrder
{
[TestFixture ()]
public class TestOrder
@@ -53,6 +53,48 @@ namespace SwaggerClientTest.TestORder
Assert.AreEqual (true, o.Complete);
}
+
+ ///
+ /// Test GetInvetory
+ ///
+ [Test ()]
+ public void TestGetInventory ()
+ {
+ // set timeout to 10 seconds
+ Configuration c1 = new Configuration (timeout: 10000);
+
+ StoreApi storeApi = new StoreApi (c1);
+ Dictionary response = storeApi.GetInventory ();
+
+ foreach(KeyValuePair entry in response)
+ {
+ Assert.IsInstanceOf (typeof(int?), entry.Value);
+ }
+
+ }
+
+ ///
+ /// Test GetInvetoryInObject
+ ///
+ [Test ()]
+ public void TestGetInventoryInObject ()
+ {
+ // set timeout to 10 seconds
+ Configuration c1 = new Configuration (timeout: 10000);
+
+ StoreApi storeApi = new StoreApi (c1);
+ Newtonsoft.Json.Linq.JObject response = (Newtonsoft.Json.Linq.JObject)storeApi.GetInventoryInObject ();
+
+ // should be a Newtonsoft.Json.Linq.JObject since type is object
+ Assert.IsInstanceOf (typeof(Newtonsoft.Json.Linq.JObject), response);
+
+ foreach(KeyValuePair entry in response.ToObject>())
+ {
+ Assert.IsInstanceOf (typeof(int?), Int32.Parse(entry.Value));
+ }
+
+ }
+
}
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs
index 1a8f953755d..5c30360ee0f 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs
@@ -158,6 +158,37 @@ namespace SwaggerClientTest.TestPet
}
+ ///
+ /// Test GetPetByIdInObject
+ ///
+ [Test ()]
+ public void TestGetPetByIdInObject ()
+ {
+ // set timeout to 10 seconds
+ Configuration c1 = new Configuration (timeout: 10000);
+
+ PetApi petApi = new PetApi (c1);
+ InlineResponse200 response = petApi.GetPetByIdInObject (petId);
+ Assert.IsInstanceOf (response, "Response is a Pet");
+
+ Assert.AreEqual ("Csharp test", response.Name);
+ Assert.AreEqual (InlineResponse200.StatusEnum.Available, response.Status);
+
+ Assert.IsInstanceOf> (response.Tags, "Response.Tags is a Array");
+ Assert.AreEqual (petId, response.Tags [0].Id);
+ Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
+
+ Assert.IsInstanceOf> (response.PhotoUrls, "Response.PhotoUrls is a Array");
+ Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
+
+ Assert.IsInstanceOf (response.Category, "Response.Category is a Newtonsoft.Json.Linq.JObject");
+
+ Newtonsoft.Json.Linq.JObject category = (Newtonsoft.Json.Linq.JObject)response.Category;
+ Assert.AreEqual (56, (int)category ["id"]);
+ Assert.AreEqual ("sample category name2", (string) category["name"]);
+
+ }
+
///
/// Test GetPetByIdWithByteArray
///