diff --git a/bin/jaxrs-resteasy-petstore-server.sh b/bin/jaxrs-resteasy-petstore-server.sh
old mode 100644
new mode 100755
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java
index d80bc38a4c..2808c9dcc2 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java
@@ -177,6 +177,9 @@ public class CodegenProperty {
if (this.isEnum != other.isEnum) {
return false;
}
+ if (this.isReadOnly != other.isReadOnly && (this.isReadOnly == null || !this.isReadOnly.equals(other.isReadOnly))) {
+ return false;
+ }
if (this._enum != other._enum && (this._enum == null || !this._enum.equals(other._enum))) {
return false;
}
diff --git a/modules/swagger-codegen/src/main/resources/csharp/model.mustache b/modules/swagger-codegen/src/main/resources/csharp/model.mustache
index 6abd76ce9d..d7f38218dc 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/model.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/model.mustache
@@ -20,12 +20,33 @@ namespace {{packageName}}.Model
public partial class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}} IEquatable<{{classname}}>
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- public {{classname}}()
+ /// 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}}{{#defaultValue}}this.{{name}} = {{{defaultValue}}};
- {{/defaultValue}}{{/vars}}
+ {{#vars}}{{#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");
+ }
+ else
+ {
+ this.{{name}} = {{name}};
+ }
+ {{/required}}{{/vars}}{{#vars}}{{^required}}{{#defaultValue}}// use default value if no "{{name}}" provided
+ if ({{name}} == null)
+ {
+ this.{{name}} = {{{defaultValue}}};
+ }
+ else
+ {
+ this.{{name}} = {{name}};
+ }
+ {{/defaultValue}}{{^defaultValue}}this.{{name}} = {{name}};
+ {{/defaultValue}}{{/required}}{{/vars}}
}
{{#vars}}
@@ -34,7 +55,7 @@ namespace {{packageName}}.Model
/// {{#description}}
/// {{{description}}}{{/description}}
[DataMember(Name="{{baseName}}", EmitDefaultValue=false)]
- public {{{datatype}}} {{name}} { get; set; }
+ public {{{datatype}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; }
{{/vars}}
diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore.json b/modules/swagger-codegen/src/test/resources/2_0/petstore.json
index b49bd81631..6df7d079a1 100644
--- a/modules/swagger-codegen/src/test/resources/2_0/petstore.json
+++ b/modules/swagger-codegen/src/test/resources/2_0/petstore.json
@@ -1069,7 +1069,8 @@
"properties": {
"id": {
"type": "integer",
- "format": "int64"
+ "format": "int64",
+ "readOnly": true
},
"petId": {
"type": "integer",
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 73cb6dfecf..9b534f83c1 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
@@ -18,10 +18,15 @@ namespace IO.Swagger.Model
public partial class Category : IEquatable
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- public Category()
+ /// Thrown when required property is null
+ /// Id.
+ /// Name.
+ public Category(long? Id = null, string Name = null)
{
+ this.Id = Id;
+ this.Name = Name;
}
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 81533a1a58..040b348f1f 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
@@ -18,10 +18,23 @@ namespace IO.Swagger.Model
public partial class Order : IEquatable
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- public Order()
+ /// 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)
{
+ this.Id = Id;
+ this.PetId = PetId;
+ this.Quantity = Quantity;
+ this.ShipDate = ShipDate;
+ this.Status = Status;
+ this.Complete = Complete;
}
@@ -30,7 +43,7 @@ namespace IO.Swagger.Model
/// Gets or Sets Id
///
[DataMember(Name="id", EmitDefaultValue=false)]
- public long? Id { get; set; }
+ public long? Id { get; private set; }
///
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 2cb33cbf9e..3b96481fdf 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
@@ -18,10 +18,39 @@ namespace IO.Swagger.Model
public partial class Pet : IEquatable
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- public Pet()
+ /// Thrown when required property is null
+ /// Id.
+ /// Category.
+ /// Name (required).
+ /// 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)
+ if (Name == null)
+ {
+ throw new InvalidDataException("Name is a required property for Pet and cannot be null");
+ }
+ else
+ {
+ this.Name = Name;
+ }
+ // to ensure "PhotoUrls" is required (not null)
+ if (PhotoUrls == null)
+ {
+ throw new InvalidDataException("PhotoUrls is a required property for Pet and cannot be null");
+ }
+ else
+ {
+ this.PhotoUrls = PhotoUrls;
+ }
+ this.Id = Id;
+ this.Category = Category;
+ this.Tags = Tags;
+ this.Status = Status;
}
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 f0fbe098cc..bb98f1b646 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
@@ -18,10 +18,15 @@ namespace IO.Swagger.Model
public partial class Tag : IEquatable
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- public Tag()
+ /// Thrown when required property is null
+ /// Id.
+ /// Name.
+ public Tag(long? Id = null, string Name = null)
{
+ this.Id = Id;
+ this.Name = Name;
}
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 8960576097..e182b3f918 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
@@ -18,10 +18,27 @@ namespace IO.Swagger.Model
public partial class User : IEquatable
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- public User()
+ /// Thrown when required property is null
+ /// Id.
+ /// Username.
+ /// FirstName.
+ /// LastName.
+ /// Email.
+ /// 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;
+ this.Username = Username;
+ this.FirstName = FirstName;
+ this.LastName = LastName;
+ this.Email = Email;
+ this.Password = Password;
+ this.Phone = Phone;
+ this.UserStatus = UserStatus;
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs
index a66bf7badf..85aa051f2b 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs
@@ -1,14 +1,18 @@
-
+
-
+
+
-
-
-
-
+
+
+
+
+
+
+
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs
index 3ee63f1e92..640d24250d 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs
@@ -21,9 +21,9 @@ namespace SwaggerClientTest.TestPet
private Pet createPet()
{
// create pet
- Pet p = new Pet();
+ Pet p = new Pet(Name: "Csharp test", PhotoUrls: new List { "http://petstore.com/csharp_test" });
p.Id = petId;
- p.Name = "Csharp test";
+ //p.Name = "Csharp test";
p.Status = "available";
// create Category object
Category category = new Category();
@@ -33,7 +33,7 @@ namespace SwaggerClientTest.TestPet
// create Tag object
Tag tag = new Tag();
tag.Id = petId;
- tag.Name = "sample tag name1";
+ tag.Name = "csharp sample tag name1";
List tags = new List(new Tag[] {tag});
p.Tags = tags;
p.Category = category;
@@ -86,7 +86,7 @@ namespace SwaggerClientTest.TestPet
Assert.IsInstanceOf> (response.Tags, "Response.Tags is a Array");
Assert.AreEqual (petId, response.Tags [0].Id);
- Assert.AreEqual ("sample tag name1", response.Tags [0].Name);
+ 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]);
@@ -118,7 +118,7 @@ namespace SwaggerClientTest.TestPet
Assert.IsInstanceOf> (response.Tags, "Response.Tags is a Array");
Assert.AreEqual (petId, response.Tags [0].Id);
- Assert.AreEqual ("sample tag name1", response.Tags [0].Name);
+ 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]);
@@ -147,7 +147,7 @@ namespace SwaggerClientTest.TestPet
Assert.IsInstanceOf> (response.Tags, "Response.Tags is a Array");
Assert.AreEqual (petId, response.Tags [0].Id);
- Assert.AreEqual ("sample tag name1", response.Tags [0].Name);
+ 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]);
@@ -235,16 +235,16 @@ namespace SwaggerClientTest.TestPet
/// Test FindPetByStatus
///
[Test ()]
- public void TestFindPetByStatus ()
+ public void TestFindPetByTags ()
{
PetApi petApi = new PetApi ();
- List statusList = new List(new String[] {"available"});
+ List tagsList = new List(new String[] {"available"});
- List listPet = petApi.FindPetsByStatus (statusList);
+ List listPet = petApi.FindPetsByTags (tagsList);
foreach (Pet pet in listPet) // Loop through List with foreach.
{
Assert.IsInstanceOf (pet, "Response is a Pet");
- Assert.AreEqual ("available", pet.Status);
+ Assert.AreEqual ("csharp sample tag name1", pet.Tags[0]);
}
}
@@ -256,9 +256,9 @@ namespace SwaggerClientTest.TestPet
public void TestEqual()
{
// create pet
- Pet p1 = new Pet();
+ Pet p1 = new Pet(Name: "Csharp test", PhotoUrls: new List { "http://petstore.com/csharp_test"} );
p1.Id = petId;
- p1.Name = "Csharp test";
+ //p1.Name = "Csharp test";
p1.Status = "available";
// create Category object
Category category1 = new Category();
@@ -268,14 +268,14 @@ namespace SwaggerClientTest.TestPet
// create Tag object
Tag tag1 = new Tag();
tag1.Id = petId;
- tag1.Name = "sample tag name1";
+ tag1.Name = "csharp sample tag name1";
List tags1 = new List(new Tag[] {tag1});
p1.Tags = tags1;
p1.Category = category1;
p1.PhotoUrls = photoUrls1;
// create pet 2
- Pet p2 = new Pet();
+ Pet p2 = new Pet(Name: "Csharp test", PhotoUrls: new List { "http://petstore.com/csharp_test"} );
p2.Id = petId;
p2.Name = "Csharp test";
p2.Status = "available";
@@ -287,7 +287,7 @@ namespace SwaggerClientTest.TestPet
// create Tag object
Tag tag2 = new Tag();
tag2.Id = petId;
- tag2.Name = "sample tag name1";
+ tag2.Name = "csharp sample tag name1";
List tags2 = new List(new Tag[] {tag2});
p2.Tags = tags2;
p2.Category = category2;
@@ -334,8 +334,9 @@ namespace SwaggerClientTest.TestPet
public void TestDefaultHeader ()
{
PetApi petApi = new PetApi ();
+ // commented out the warning test below as it's confirmed the warning is working as expected
// there should be a warning for using AddDefaultHeader (deprecated) below
- petApi.AddDefaultHeader ("header_key", "header_value");
+ //petApi.AddDefaultHeader ("header_key", "header_value");
// the following should be used instead as suggested in the doc
petApi.Configuration.AddDefaultHeader ("header_key2", "header_value2");