diff --git a/modules/swagger-codegen/src/main/resources/csharp/model.mustache b/modules/swagger-codegen/src/main/resources/csharp/model.mustache
index d7f38218dcd..d386e37c084 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/model.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/model.mustache
@@ -23,11 +23,11 @@ namespace {{packageName}}.Model
/// Initializes a new instance of the class.
///
/// Thrown when required property is null
-{{#vars}} /// {{#description}}{{description}}{{/description}}{{^description}}{{name}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{defaultValue}}){{/defaultValue}}.
-{{/vars}}
- public {{classname}}({{#vars}}{{{datatype}}} {{name}} = null{{#hasMore}}, {{/hasMore}}{{/vars}})
+{{#vars}}{{^isReadOnly}} /// {{#description}}{{description}}{{/description}}{{^description}}{{name}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{defaultValue}}){{/defaultValue}}.
+{{/isReadOnly}}{{/vars}}
+ public {{classname}}({{#vars}}{{^isReadOnly}}{{{datatype}}} {{name}} = null{{#hasMore}}, {{/hasMore}}{{/isReadOnly}}{{/vars}})
{
- {{#vars}}{{#required}}// to ensure "{{name}}" is required (not null)
+ {{#vars}}{{^isReadOnly}}{{#required}}// to ensure "{{name}}" is required (not null)
if ({{name}} == null)
{
throw new InvalidDataException("{{name}} is a required property for {{classname}} and cannot be null");
@@ -36,7 +36,7 @@ namespace {{packageName}}.Model
{
this.{{name}} = {{name}};
}
- {{/required}}{{/vars}}{{#vars}}{{^required}}{{#defaultValue}}// use default value if no "{{name}}" provided
+ {{/required}}{{/isReadOnly}}{{/vars}}{{#vars}}{{^isReadOnly}}{{^required}}{{#defaultValue}}// use default value if no "{{name}}" provided
if ({{name}} == null)
{
this.{{name}} = {{{defaultValue}}};
@@ -46,7 +46,7 @@ namespace {{packageName}}.Model
this.{{name}} = {{name}};
}
{{/defaultValue}}{{^defaultValue}}this.{{name}} = {{name}};
- {{/defaultValue}}{{/required}}{{/vars}}
+ {{/defaultValue}}{{/required}}{{/isReadOnly}}{{/vars}}
}
{{#vars}}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs
index 9b534f83c15..4696acc2647 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs
@@ -23,6 +23,7 @@ namespace IO.Swagger.Model
/// Thrown when required property is null
/// Id.
/// Name.
+
public Category(long? Id = null, string Name = null)
{
this.Id = Id;
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs
index 040b348f1fd..576056ca29c 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs
@@ -21,15 +21,14 @@ namespace IO.Swagger.Model
/// Initializes a new instance of the class.
///
/// Thrown when required property is null
- /// Id.
/// PetId.
/// Quantity.
/// ShipDate.
/// Order Status.
/// Complete.
- public Order(long? Id = null, long? PetId = null, int? Quantity = null, DateTime? ShipDate = null, string Status = null, bool? Complete = null)
+
+ public Order(long? PetId = null, int? Quantity = null, DateTime? ShipDate = null, string Status = null, bool? Complete = null)
{
- this.Id = Id;
this.PetId = PetId;
this.Quantity = Quantity;
this.ShipDate = ShipDate;
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs
index 3b96481fdfa..b760206b88d 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs
@@ -27,6 +27,7 @@ namespace IO.Swagger.Model
/// PhotoUrls (required).
/// Tags.
/// pet status in the store.
+
public Pet(long? Id = null, Category Category = null, string Name = null, List PhotoUrls = null, List Tags = null, string Status = null)
{
// to ensure "Name" is required (not null)
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs
index bb98f1b646f..13505e9dc26 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs
@@ -23,6 +23,7 @@ namespace IO.Swagger.Model
/// Thrown when required property is null
/// Id.
/// Name.
+
public Tag(long? Id = null, string Name = null)
{
this.Id = Id;
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs
index e182b3f9183..95a3bd26362 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs
@@ -29,6 +29,7 @@ namespace IO.Swagger.Model
/// Password.
/// Phone.
/// User Status.
+
public User(long? Id = null, string Username = null, string FirstName = null, string LastName = null, string Email = null, string Password = null, string Phone = null, int? UserStatus = null)
{
this.Id = Id;
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj
index 5556641ea1f..0b5c3d9a952 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj
+++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj
@@ -58,6 +58,7 @@
+
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs
index 85aa051f2b1..98bc9083d66 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs
@@ -1,18 +1,10 @@
-
+
-
-
-
+
+
-
-
-
-
-
-
-
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestOrder.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestOrder.cs
new file mode 100644
index 00000000000..278cc964b18
--- /dev/null
+++ b/samples/client/petstore/csharp/SwaggerClientTest/TestOrder.cs
@@ -0,0 +1,58 @@
+using NUnit.Framework;
+using System;
+using System.Linq;
+using System.IO;
+using System.Collections.Generic;
+using IO.Swagger.Api;
+using IO.Swagger.Model;
+using IO.Swagger.Client;
+using System.Reflection;
+using Newtonsoft.Json;
+
+
+namespace SwaggerClientTest.TestORder
+{
+ [TestFixture ()]
+ public class TestOrder
+ {
+ public TestOrder ()
+ {
+
+ }
+
+ ///
+ /// Test creating a new instance of Order
+ ///
+ [Test ()]
+ public void TestNewOrder()
+ {
+ Order o = new Order ();
+
+ Assert.IsNull (o.Id);
+
+ }
+
+ ///
+ /// Test deserialization of JSON to Order and its readonly property
+ ///
+ [Test ()]
+ public void TesOrderDeserialization()
+ {
+ string json = @"{
+'id': 1982,
+'petId': 1020,
+'quantity': 1,
+'status': 'placed',
+'complete': true,
+}";
+ var o = JsonConvert.DeserializeObject(json);
+ Assert.AreEqual (1982, o.Id);
+ Assert.AreEqual (1020, o.PetId);
+ Assert.AreEqual (1, o.Quantity);
+ Assert.AreEqual ("placed", o.Status);
+ Assert.AreEqual (true, o.Complete);
+
+ }
+ }
+}
+
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 323cad108c6..f115c595d6a 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/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
+/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