diff --git a/bin/aspnet5-petstore-server.sh b/bin/aspnet5-petstore-server.sh index 276d2a6e4b0..4481b4b318f 100755 --- a/bin/aspnet5-petstore-server.sh +++ b/bin/aspnet5-petstore-server.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -l aspnet5 -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -o samples/server/petstore/aspnet5" +ags="$@ generate -l aspnet5 -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/aspnet5" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-inflector-petstore-server.sh b/bin/java-inflector-petstore-server.sh index 5200ab26bb1..2fe4c8cac0b 100755 --- a/bin/java-inflector-petstore-server.sh +++ b/bin/java-inflector-petstore-server.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaInflector -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l inflector -o samples/server/petstore/java-inflector" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaInflector -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l inflector -o samples/server/petstore/java-inflector" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/scalatra-petstore-server.sh b/bin/scalatra-petstore-server.sh index 433f0bcbc0f..c902aec03bb 100755 --- a/bin/scalatra-petstore-server.sh +++ b/bin/scalatra-petstore-server.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t modules/swagger-codegen/src/main/resources/scalatra -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l scalatra -o samples/server/petstore/scalatra" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/scalatra -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l scalatra -o samples/server/petstore/scalatra" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/silex-petstore-server.sh b/bin/silex-petstore-server.sh index 85b658a3723..c273102828b 100755 --- a/bin/silex-petstore-server.sh +++ b/bin/silex-petstore-server.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t modules/swagger-codegen/src/main/resources/silex -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l silex-PHP -o samples/server/petstore/silex" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/silex -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l silex-PHP -o samples/server/petstore/silex" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/slim-petstore-server.sh b/bin/slim-petstore-server.sh index 654fc1d0e01..6e2e5270542 100755 --- a/bin/slim-petstore-server.sh +++ b/bin/slim-petstore-server.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t modules/swagger-codegen/src/main/resources/slim -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l slim -o samples/server/petstore/slim" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/slim -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l slim -o samples/server/petstore/slim" java $JAVA_OPTS -jar $executable $ags diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/PetApi.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/PetApi.cs index 8eb740a1e4e..a30ac7a5f1a 100644 --- a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/PetApi.cs +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/PetApi.cs @@ -19,23 +19,6 @@ namespace IO.Swagger.Controllers public class PetApiController : Controller { - /// - /// Update an existing pet - /// - /// - /// Pet object that needs to be added to the store - /// Invalid ID supplied - /// Pet not found - /// Validation exception - [HttpPut] - [Route("/pet")] - [SwaggerOperation("UpdatePet")] - public void UpdatePet([FromBody]Pet body) - { - throw new NotImplementedException(); - } - - /// /// Add a new pet to the store /// @@ -51,93 +34,6 @@ namespace IO.Swagger.Controllers } - /// - /// Finds Pets by status - /// - /// Multiple status values can be provided with comma seperated strings - /// Status values that need to be considered for filter - /// successful operation - /// Invalid status value - [HttpGet] - [Route("/pet/findByStatus")] - [SwaggerOperation("FindPetsByStatus")] - [SwaggerResponse(200, type: typeof(List))] - public IActionResult FindPetsByStatus([FromQuery]List status) - { - string exampleJson = null; - - var example = exampleJson != null - ? JsonConvert.DeserializeObject>(exampleJson) - : default(List); - - return new ObjectResult(example); - } - - - /// - /// Finds Pets by tags - /// - /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - /// Tags to filter by - /// successful operation - /// Invalid tag value - [HttpGet] - [Route("/pet/findByTags")] - [SwaggerOperation("FindPetsByTags")] - [SwaggerResponse(200, type: typeof(List))] - public IActionResult FindPetsByTags([FromQuery]List tags) - { - string exampleJson = null; - - var example = exampleJson != null - ? JsonConvert.DeserializeObject>(exampleJson) - : default(List); - - return new ObjectResult(example); - } - - - /// - /// Find pet by ID - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - /// ID of pet that needs to be fetched - /// successful operation - /// Invalid ID supplied - /// Pet not found - [HttpGet] - [Route("/pet/{petId}")] - [SwaggerOperation("GetPetById")] - [SwaggerResponse(200, type: typeof(Pet))] - public IActionResult GetPetById([FromRoute]long? petId) - { - string exampleJson = null; - - var example = exampleJson != null - ? JsonConvert.DeserializeObject(exampleJson) - : default(Pet); - - return new ObjectResult(example); - } - - - /// - /// Updates a pet in the store with form data - /// - /// - /// ID of pet that needs to be updated - /// Updated name of the pet - /// Updated status of the pet - /// Invalid input - [HttpPost] - [Route("/pet/{petId}")] - [SwaggerOperation("UpdatePetWithForm")] - public void UpdatePetWithForm([FromRoute]string petId, [FromForm]string name, [FromForm]string status) - { - throw new NotImplementedException(); - } - - /// /// Deletes a pet /// @@ -154,6 +50,107 @@ namespace IO.Swagger.Controllers } + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma separated strings + /// Status values that need to be considered for filter + /// successful operation + /// Invalid status value + [HttpGet] + [Route("/pet/findByStatus")] + [SwaggerOperation("FindPetsByStatus")] + [SwaggerResponse(200, type: typeof(List))] + public IActionResult FindPetsByStatus([FromQuery]List status) + { + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(List); + return new ObjectResult(example); + } + + + /// + /// Finds Pets by tags + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// Tags to filter by + /// successful operation + /// Invalid tag value + [HttpGet] + [Route("/pet/findByTags")] + [SwaggerOperation("FindPetsByTags")] + [SwaggerResponse(200, type: typeof(List))] + public IActionResult FindPetsByTags([FromQuery]List tags) + { + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(List); + return new ObjectResult(example); + } + + + /// + /// Find pet by ID + /// + /// Returns a single pet + /// ID of pet to return + /// successful operation + /// Invalid ID supplied + /// Pet not found + [HttpGet] + [Route("/pet/{petId}")] + [SwaggerOperation("GetPetById")] + [SwaggerResponse(200, type: typeof(Pet))] + public IActionResult GetPetById([FromRoute]long? petId) + { + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Pet); + return new ObjectResult(example); + } + + + /// + /// Update an existing pet + /// + /// + /// Pet object that needs to be added to the store + /// Invalid ID supplied + /// Pet not found + /// Validation exception + [HttpPut] + [Route("/pet")] + [SwaggerOperation("UpdatePet")] + public void UpdatePet([FromBody]Pet body) + { + throw new NotImplementedException(); + } + + + /// + /// Updates a pet in the store with form data + /// + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// Invalid input + [HttpPost] + [Route("/pet/{petId}")] + [SwaggerOperation("UpdatePetWithForm")] + public void UpdatePetWithForm([FromRoute]long? petId, [FromForm]string name, [FromForm]string status) + { + throw new NotImplementedException(); + } + + /// /// uploads an image /// @@ -161,52 +158,19 @@ namespace IO.Swagger.Controllers /// ID of pet to update /// Additional data to pass to server /// file to upload - /// successful operation + /// successful operation [HttpPost] [Route("/pet/{petId}/uploadImage")] [SwaggerOperation("UploadFile")] - public void UploadFile([FromRoute]long? petId, [FromForm]string additionalMetadata, [FromForm]Stream file) - { - throw new NotImplementedException(); - } - - - /// - /// Fake endpoint to test byte array return by 'Find pet by ID' - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - /// ID of pet that needs to be fetched - /// successful operation - /// Invalid ID supplied - /// Pet not found - [HttpGet] - [Route("/pet/{petId}/testing_byte_array=true")] - [SwaggerOperation("GetPetByIdWithByteArray")] - [SwaggerResponse(200, type: typeof(byte[]))] - public IActionResult GetPetByIdWithByteArray([FromRoute]long? petId) + [SwaggerResponse(200, type: typeof(ApiResponse))] + public IActionResult UploadFile([FromRoute]long? petId, [FromForm]string additionalMetadata, [FromForm]System.IO.Stream file) { string exampleJson = null; var example = exampleJson != null - ? JsonConvert.DeserializeObject(exampleJson) - : default(byte[]); - + ? JsonConvert.DeserializeObject(exampleJson) + : default(ApiResponse); return new ObjectResult(example); } - - - /// - /// Fake endpoint to test byte array in body parameter for adding a new pet to the store - /// - /// - /// Pet object in the form of byte array - /// Invalid input - [HttpPost] - [Route("/pet/testing_byte_array=true")] - [SwaggerOperation("AddPetUsingByteArray")] - public void AddPetUsingByteArray([FromBody]byte[] body) - { - throw new NotImplementedException(); - } } } diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/StoreApi.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/StoreApi.cs index 347c46abd69..04838253884 100644 --- a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/StoreApi.cs +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/StoreApi.cs @@ -19,6 +19,22 @@ namespace IO.Swagger.Controllers public class StoreApiController : Controller { + /// + /// Delete purchase order by ID + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// ID of the order that needs to be deleted + /// Invalid ID supplied + /// Order not found + [HttpDelete] + [Route("/store/order/{orderId}")] + [SwaggerOperation("DeleteOrder")] + public void DeleteOrder([FromRoute]string orderId) + { + throw new NotImplementedException(); + } + + /// /// Returns pet inventories by status /// @@ -35,7 +51,29 @@ namespace IO.Swagger.Controllers var example = exampleJson != null ? JsonConvert.DeserializeObject>(exampleJson) : default(Dictionary); + return new ObjectResult(example); + } + + + /// + /// Find purchase order by ID + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// ID of pet that needs to be fetched + /// successful operation + /// Invalid ID supplied + /// Order not found + [HttpGet] + [Route("/store/order/{orderId}")] + [SwaggerOperation("GetOrderById")] + [SwaggerResponse(200, type: typeof(Order))] + public IActionResult GetOrderById([FromRoute]long? orderId) + { + string exampleJson = null; + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Order); return new ObjectResult(example); } @@ -58,48 +96,7 @@ namespace IO.Swagger.Controllers var example = exampleJson != null ? JsonConvert.DeserializeObject(exampleJson) : default(Order); - return new ObjectResult(example); } - - - /// - /// Find purchase order by ID - /// - /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - /// ID of pet that needs to be fetched - /// successful operation - /// Invalid ID supplied - /// Order not found - [HttpGet] - [Route("/store/order/{orderId}")] - [SwaggerOperation("GetOrderById")] - [SwaggerResponse(200, type: typeof(Order))] - public IActionResult GetOrderById([FromRoute]string orderId) - { - string exampleJson = null; - - var example = exampleJson != null - ? JsonConvert.DeserializeObject(exampleJson) - : default(Order); - - return new ObjectResult(example); - } - - - /// - /// Delete purchase order by ID - /// - /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - /// ID of the order that needs to be deleted - /// Invalid ID supplied - /// Order not found - [HttpDelete] - [Route("/store/order/{orderId}")] - [SwaggerOperation("DeleteOrder")] - public void DeleteOrder([FromRoute]string orderId) - { - throw new NotImplementedException(); - } } } diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/UserApi.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/UserApi.cs index 180dc4aa00a..dd676fac85b 100644 --- a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/UserApi.cs +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/UserApi.cs @@ -64,6 +64,45 @@ namespace IO.Swagger.Controllers } + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// The name that needs to be deleted + /// Invalid username supplied + /// User not found + [HttpDelete] + [Route("/user/{username}")] + [SwaggerOperation("DeleteUser")] + public void DeleteUser([FromRoute]string username) + { + throw new NotImplementedException(); + } + + + /// + /// Get user by user name + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// successful operation + /// Invalid username supplied + /// User not found + [HttpGet] + [Route("/user/{username}")] + [SwaggerOperation("GetUserByName")] + [SwaggerResponse(200, type: typeof(User))] + public IActionResult GetUserByName([FromRoute]string username) + { + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(User); + return new ObjectResult(example); + } + + /// /// Logs user into the system /// @@ -83,7 +122,6 @@ namespace IO.Swagger.Controllers var example = exampleJson != null ? JsonConvert.DeserializeObject(exampleJson) : default(string); - return new ObjectResult(example); } @@ -102,30 +140,6 @@ namespace IO.Swagger.Controllers } - /// - /// Get user by user name - /// - /// - /// The name that needs to be fetched. Use user1 for testing. - /// successful operation - /// Invalid username supplied - /// User not found - [HttpGet] - [Route("/user/{username}")] - [SwaggerOperation("GetUserByName")] - [SwaggerResponse(200, type: typeof(User))] - public IActionResult GetUserByName([FromRoute]string username) - { - string exampleJson = null; - - var example = exampleJson != null - ? JsonConvert.DeserializeObject(exampleJson) - : default(User); - - return new ObjectResult(example); - } - - /// /// Updated user /// @@ -141,21 +155,5 @@ namespace IO.Swagger.Controllers { throw new NotImplementedException(); } - - - /// - /// Delete user - /// - /// This can only be done by the logged in user. - /// The name that needs to be deleted - /// Invalid username supplied - /// User not found - [HttpDelete] - [Route("/user/{username}")] - [SwaggerOperation("DeleteUser")] - public void DeleteUser([FromRoute]string username) - { - throw new NotImplementedException(); - } } } diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Category.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Category.cs index 1bdccbdc4e1..e412db81ee2 100644 --- a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Category.cs +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Category.cs @@ -27,19 +27,16 @@ namespace IO.Swagger.Models } - /// /// Gets or Sets Id /// public long? Id { get; set; } - /// /// Gets or Sets Name /// public string Name { get; set; } - /// /// Returns the string presentation of the object @@ -50,8 +47,7 @@ namespace IO.Swagger.Models var sb = new StringBuilder(); sb.Append("class Category {\n"); sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - +sb.Append(" Name: ").Append(Name).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -113,13 +109,10 @@ namespace IO.Swagger.Models { int hash = 41; // Suitable nullity checks etc, of course :) - if (this.Id != null) hash = hash * 59 + this.Id.GetHashCode(); - if (this.Name != null) hash = hash * 59 + this.Name.GetHashCode(); - return hash; } } diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Order.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Order.cs index 27252258328..5b5a9b6d14e 100644 --- a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Order.cs +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Order.cs @@ -23,7 +23,7 @@ namespace IO.Swagger.Models /// Quantity. /// ShipDate. /// Order Status. - /// Complete. + /// Complete (default to false). public Order(long? Id = null, long? PetId = null, int? Quantity = null, DateTime? ShipDate = null, string Status = null, bool? Complete = null) { this.Id = Id; @@ -31,48 +31,49 @@ namespace IO.Swagger.Models this.Quantity = Quantity; this.ShipDate = ShipDate; this.Status = Status; - this.Complete = Complete; + // use default value if no "Complete" provided + if (Complete == null) + { + this.Complete = false; + } + else + { + this.Complete = Complete; + } } - /// /// Gets or Sets Id /// public long? Id { get; set; } - /// /// Gets or Sets PetId /// public long? PetId { get; set; } - /// /// Gets or Sets Quantity /// public int? Quantity { get; set; } - /// /// Gets or Sets ShipDate /// public DateTime? ShipDate { get; set; } - /// /// Order Status /// /// Order Status public string Status { get; set; } - /// /// Gets or Sets Complete /// public bool? Complete { get; set; } - /// /// Returns the string presentation of the object @@ -83,12 +84,11 @@ namespace IO.Swagger.Models var sb = new StringBuilder(); sb.Append("class Order {\n"); sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" PetId: ").Append(PetId).Append("\n"); - sb.Append(" Quantity: ").Append(Quantity).Append("\n"); - sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); - sb.Append(" Status: ").Append(Status).Append("\n"); - sb.Append(" Complete: ").Append(Complete).Append("\n"); - +sb.Append(" PetId: ").Append(PetId).Append("\n"); +sb.Append(" Quantity: ").Append(Quantity).Append("\n"); +sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); +sb.Append(" Status: ").Append(Status).Append("\n"); +sb.Append(" Complete: ").Append(Complete).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -170,25 +170,18 @@ namespace IO.Swagger.Models { int hash = 41; // Suitable nullity checks etc, of course :) - if (this.Id != null) hash = hash * 59 + this.Id.GetHashCode(); - if (this.PetId != null) hash = hash * 59 + this.PetId.GetHashCode(); - if (this.Quantity != null) hash = hash * 59 + this.Quantity.GetHashCode(); - if (this.ShipDate != null) hash = hash * 59 + this.ShipDate.GetHashCode(); - if (this.Status != null) hash = hash * 59 + this.Status.GetHashCode(); - if (this.Complete != null) hash = hash * 59 + this.Complete.GetHashCode(); - return hash; } } diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Pet.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Pet.cs index e2756f6a80d..70a3992c294 100644 --- a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Pet.cs +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Pet.cs @@ -51,44 +51,37 @@ namespace IO.Swagger.Models } - /// /// Gets or Sets Id /// public long? Id { get; set; } - /// /// Gets or Sets Category /// public Category Category { get; set; } - /// /// Gets or Sets Name /// public string Name { get; set; } - /// /// Gets or Sets PhotoUrls /// public List PhotoUrls { get; set; } - /// /// Gets or Sets Tags /// public List Tags { get; set; } - /// /// pet status in the store /// /// pet status in the store public string Status { get; set; } - /// /// Returns the string presentation of the object @@ -99,12 +92,11 @@ namespace IO.Swagger.Models var sb = new StringBuilder(); sb.Append("class Pet {\n"); sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Category: ").Append(Category).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); - sb.Append(" Tags: ").Append(Tags).Append("\n"); - sb.Append(" Status: ").Append(Status).Append("\n"); - +sb.Append(" Category: ").Append(Category).Append("\n"); +sb.Append(" Name: ").Append(Name).Append("\n"); +sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); +sb.Append(" Tags: ").Append(Tags).Append("\n"); +sb.Append(" Status: ").Append(Status).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -186,25 +178,18 @@ namespace IO.Swagger.Models { int hash = 41; // Suitable nullity checks etc, of course :) - if (this.Id != null) hash = hash * 59 + this.Id.GetHashCode(); - if (this.Category != null) hash = hash * 59 + this.Category.GetHashCode(); - if (this.Name != null) hash = hash * 59 + this.Name.GetHashCode(); - if (this.PhotoUrls != null) hash = hash * 59 + this.PhotoUrls.GetHashCode(); - if (this.Tags != null) hash = hash * 59 + this.Tags.GetHashCode(); - if (this.Status != null) hash = hash * 59 + this.Status.GetHashCode(); - return hash; } } diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Tag.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Tag.cs index ce8a4e8eafe..77697097379 100644 --- a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Tag.cs +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Tag.cs @@ -27,19 +27,16 @@ namespace IO.Swagger.Models } - /// /// Gets or Sets Id /// public long? Id { get; set; } - /// /// Gets or Sets Name /// public string Name { get; set; } - /// /// Returns the string presentation of the object @@ -50,8 +47,7 @@ namespace IO.Swagger.Models var sb = new StringBuilder(); sb.Append("class Tag {\n"); sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - +sb.Append(" Name: ").Append(Name).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -113,13 +109,10 @@ namespace IO.Swagger.Models { int hash = 41; // Suitable nullity checks etc, of course :) - if (this.Id != null) hash = hash * 59 + this.Id.GetHashCode(); - if (this.Name != null) hash = hash * 59 + this.Name.GetHashCode(); - return hash; } } diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/User.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/User.cs index 9c3737b8b32..c8373712db9 100644 --- a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/User.cs +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/User.cs @@ -39,56 +39,47 @@ namespace IO.Swagger.Models } - /// /// Gets or Sets Id /// public long? Id { get; set; } - /// /// Gets or Sets Username /// public string Username { get; set; } - /// /// Gets or Sets FirstName /// public string FirstName { get; set; } - /// /// Gets or Sets LastName /// public string LastName { get; set; } - /// /// Gets or Sets Email /// public string Email { get; set; } - /// /// Gets or Sets Password /// public string Password { get; set; } - /// /// Gets or Sets Phone /// public string Phone { get; set; } - /// /// User Status /// /// User Status public int? UserStatus { get; set; } - /// /// Returns the string presentation of the object @@ -99,14 +90,13 @@ namespace IO.Swagger.Models var sb = new StringBuilder(); sb.Append("class User {\n"); sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Username: ").Append(Username).Append("\n"); - sb.Append(" FirstName: ").Append(FirstName).Append("\n"); - sb.Append(" LastName: ").Append(LastName).Append("\n"); - sb.Append(" Email: ").Append(Email).Append("\n"); - sb.Append(" Password: ").Append(Password).Append("\n"); - sb.Append(" Phone: ").Append(Phone).Append("\n"); - sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); - +sb.Append(" Username: ").Append(Username).Append("\n"); +sb.Append(" FirstName: ").Append(FirstName).Append("\n"); +sb.Append(" LastName: ").Append(LastName).Append("\n"); +sb.Append(" Email: ").Append(Email).Append("\n"); +sb.Append(" Password: ").Append(Password).Append("\n"); +sb.Append(" Phone: ").Append(Phone).Append("\n"); +sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -198,31 +188,22 @@ namespace IO.Swagger.Models { int hash = 41; // Suitable nullity checks etc, of course :) - if (this.Id != null) hash = hash * 59 + this.Id.GetHashCode(); - if (this.Username != null) hash = hash * 59 + this.Username.GetHashCode(); - if (this.FirstName != null) hash = hash * 59 + this.FirstName.GetHashCode(); - if (this.LastName != null) hash = hash * 59 + this.LastName.GetHashCode(); - if (this.Email != null) hash = hash * 59 + this.Email.GetHashCode(); - if (this.Password != null) hash = hash * 59 + this.Password.GetHashCode(); - if (this.Phone != null) hash = hash * 59 + this.Phone.GetHashCode(); - if (this.UserStatus != null) hash = hash * 59 + this.UserStatus.GetHashCode(); - return hash; } } diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java index 9a9c25f919f..830226116e2 100644 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java @@ -11,9 +11,10 @@ import java.util.List; import io.swagger.model.*; import io.swagger.model.Pet; +import io.swagger.model.ApiResponse; import java.io.File; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-01-19T23:33:17.124+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-04-15T17:39:42.971+08:00") public class PetController { /** * Uncomment and implement as you see fit. These operations will map @@ -22,13 +23,13 @@ public class PetController { **/ /* - public ResponseContext updatePet(RequestContext request , Pet body) { + public ResponseContext addPet(RequestContext request , Pet body) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } */ /* - public ResponseContext addPet(RequestContext request , Pet body) { + public ResponseContext deletePet(RequestContext request , Long petId, String apiKey) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } */ @@ -52,13 +53,13 @@ public class PetController { */ /* - public ResponseContext updatePetWithForm(RequestContext request , String petId, String name, String status) { + public ResponseContext updatePet(RequestContext request , Pet body) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } */ /* - public ResponseContext deletePet(RequestContext request , Long petId, String apiKey) { + public ResponseContext updatePetWithForm(RequestContext request , Long petId, String name, String status) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } */ @@ -69,11 +70,5 @@ public class PetController { } */ - /* - public ResponseContext getPetByIdWithByteArray(RequestContext request , Long petId) { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - */ - } diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java index e00b1a67048..29acd9854d3 100644 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java @@ -13,7 +13,7 @@ import io.swagger.model.*; import java.util.Map; import io.swagger.model.Order; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-01-19T23:33:17.124+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-04-15T17:39:42.971+08:00") public class StoreController { /** * Uncomment and implement as you see fit. These operations will map @@ -21,29 +21,29 @@ public class StoreController { * Code allows you to implement logic incrementally, they are disabled. **/ + /* + public ResponseContext deleteOrder(RequestContext request , String orderId) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + */ + /* public ResponseContext getInventory(RequestContext request ) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } */ + /* + public ResponseContext getOrderById(RequestContext request , Long orderId) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + */ + /* public ResponseContext placeOrder(RequestContext request , Order body) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } */ - /* - public ResponseContext getOrderById(RequestContext request , String orderId) { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - */ - - /* - public ResponseContext deleteOrder(RequestContext request , String orderId) { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - */ - } diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java index 41331602f07..6c4c282aa83 100644 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java @@ -11,9 +11,9 @@ import java.util.List; import io.swagger.model.*; import io.swagger.model.User; -import java.util.*; +import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-01-19T23:33:17.124+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-04-15T17:39:42.971+08:00") public class UserController { /** * Uncomment and implement as you see fit. These operations will map @@ -39,6 +39,18 @@ public class UserController { } */ + /* + public ResponseContext deleteUser(RequestContext request , String username) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + */ + + /* + public ResponseContext getUserByName(RequestContext request , String username) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + */ + /* public ResponseContext loginUser(RequestContext request , String username, String password) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); @@ -51,23 +63,11 @@ public class UserController { } */ - /* - public ResponseContext getUserByName(RequestContext request , String username) { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - */ - /* public ResponseContext updateUser(RequestContext request , String username, User body) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } */ - /* - public ResponseContext deleteUser(RequestContext request , String username) { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - */ - } diff --git a/samples/server/petstore/java-inflector/src/main/swagger/swagger.yaml b/samples/server/petstore/java-inflector/src/main/swagger/swagger.yaml index 6e00a887848..0917da7891b 100644 --- a/samples/server/petstore/java-inflector/src/main/swagger/swagger.yaml +++ b/samples/server/petstore/java-inflector/src/main/swagger/swagger.yaml @@ -2,9 +2,9 @@ swagger: "2.0" info: description: "This is a sample server Petstore server. You can find out more about\ - \ Swagger at http://swagger.io or on irc.freenode.net,\ - \ #swagger. For this sample, you can use the api key \"special-key\" to test\ - \ the authorization filters" + \ Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\ + \ For this sample, you can use the api key `special-key` to test the authorization\ + \ filters." version: "1.0.0" title: "Swagger Petstore" termsOfService: "http://swagger.io/terms/" @@ -15,6 +15,19 @@ info: url: "http://www.apache.org/licenses/LICENSE-2.0.html" host: "petstore.swagger.io" basePath: "/v2" +tags: +- name: "pet" + description: "Everything about your Pets" + externalDocs: + description: "Find out more" + url: "http://swagger.io" +- name: "store" + description: "Access to Petstore orders" +- name: "user" + description: "Operations about user" + externalDocs: + description: "Find out more about our store" + url: "http://swagger.io" schemes: - "http" paths: @@ -29,13 +42,13 @@ paths: - "application/json" - "application/xml" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - in: "body" name: "body" description: "Pet object that needs to be added to the store" - required: false + required: true schema: $ref: "#/definitions/Pet" responses: @@ -57,13 +70,13 @@ paths: - "application/json" - "application/xml" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - in: "body" name: "body" description: "Pet object that needs to be added to the store" - required: false + required: true schema: $ref: "#/definitions/Pet" responses: @@ -84,21 +97,25 @@ paths: tags: - "pet" summary: "Finds Pets by status" - description: "Multiple status values can be provided with comma seperated strings" + description: "Multiple status values can be provided with comma separated strings" operationId: "findPetsByStatus" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "status" in: "query" description: "Status values that need to be considered for filter" - required: false + required: true type: "array" items: type: "string" - collectionFormat: "multi" - default: "available" + default: "available" + enum: + - "available" + - "pending" + - "sold" + collectionFormat: "csv" responses: 200: description: "successful operation" @@ -119,21 +136,21 @@ paths: tags: - "pet" summary: "Finds Pets by tags" - description: "Muliple tags can be provided with comma seperated strings. Use\ + description: "Multiple tags can be provided with comma separated strings. Use\ \ tag1, tag2, tag3 for testing." operationId: "findPetsByTags" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "tags" in: "query" description: "Tags to filter by" - required: false + required: true type: "array" items: type: "string" - collectionFormat: "multi" + collectionFormat: "csv" responses: 200: description: "successful operation" @@ -154,16 +171,15 @@ paths: tags: - "pet" summary: "Find pet by ID" - description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\ - \ API error conditions" + description: "Returns a single pet" operationId: "getPetById" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "petId" in: "path" - description: "ID of pet that needs to be fetched" + description: "ID of pet to return" required: true type: "integer" format: "int64" @@ -178,9 +194,6 @@ paths: description: "Pet not found" security: - api_key: [] - - petstore_auth: - - "write:pets" - - "read:pets" x-contentType: "application/json" x-accepts: "application/json" post: @@ -192,14 +205,15 @@ paths: consumes: - "application/x-www-form-urlencoded" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "petId" in: "path" description: "ID of pet that needs to be updated" required: true - type: "string" + type: "integer" + format: "int64" - name: "name" in: "formData" description: "Updated name of the pet" @@ -226,12 +240,11 @@ paths: description: "" operationId: "deletePet" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "api_key" in: "header" - description: "" required: false type: "string" - name: "petId" @@ -260,7 +273,6 @@ paths: - "multipart/form-data" produces: - "application/json" - - "application/xml" parameters: - name: "petId" in: "path" @@ -279,80 +291,16 @@ paths: required: false type: "file" responses: - default: + 200: description: "successful operation" + schema: + $ref: "#/definitions/ApiResponse" security: - petstore_auth: - "write:pets" - "read:pets" x-contentType: "multipart/form-data" x-accepts: "application/json" - /pet/{petId}?testing_byte_array=true: - get: - tags: - - "pet" - summary: "Fake endpoint to test byte array return by 'Find pet by ID'" - description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\ - \ API error conditions" - operationId: "getPetByIdWithByteArray" - produces: - - "application/json" - - "application/xml" - parameters: - - name: "petId" - in: "path" - description: "ID of pet that needs to be fetched" - required: true - type: "integer" - format: "int64" - responses: - 200: - description: "successful operation" - schema: - type: "string" - format: "binary" - 400: - description: "Invalid ID supplied" - 404: - description: "Pet not found" - security: - - api_key: [] - - petstore_auth: - - "write:pets" - - "read:pets" - x-contentType: "application/json" - x-accepts: "application/json" - /pet?testing_byte_array=true: - post: - tags: - - "pet" - summary: "Fake endpoint to test byte array in body parameter for adding a new\ - \ pet to the store" - description: "" - operationId: "addPetUsingByteArray" - consumes: - - "application/json" - - "application/xml" - produces: - - "application/json" - - "application/xml" - parameters: - - in: "body" - name: "body" - description: "Pet object in the form of byte array" - required: false - schema: - type: "string" - format: "binary" - responses: - 405: - description: "Invalid input" - security: - - petstore_auth: - - "write:pets" - - "read:pets" - x-contentType: "application/json" - x-accepts: "application/json" /store/inventory: get: tags: @@ -362,7 +310,6 @@ paths: operationId: "getInventory" produces: - "application/json" - - "application/xml" parameters: [] responses: 200: @@ -384,13 +331,13 @@ paths: description: "" operationId: "placeOrder" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - in: "body" name: "body" description: "order placed for purchasing the pet" - required: false + required: true schema: $ref: "#/definitions/Order" responses: @@ -411,14 +358,17 @@ paths: \ values will generated exceptions" operationId: "getOrderById" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "orderId" in: "path" description: "ID of pet that needs to be fetched" required: true - type: "string" + type: "integer" + maximum: 5.0 + minimum: 1.0 + format: "int64" responses: 200: description: "successful operation" @@ -438,14 +388,15 @@ paths: \ above 1000 or nonintegers will generate API errors" operationId: "deleteOrder" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "orderId" in: "path" description: "ID of the order that needs to be deleted" required: true type: "string" + minimum: 1.0 responses: 400: description: "Invalid ID supplied" @@ -461,13 +412,13 @@ paths: description: "This can only be done by the logged in user." operationId: "createUser" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - in: "body" name: "body" description: "Created user object" - required: false + required: true schema: $ref: "#/definitions/User" responses: @@ -483,13 +434,13 @@ paths: description: "" operationId: "createUsersWithArrayInput" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - in: "body" name: "body" description: "List of user object" - required: false + required: true schema: type: "array" items: @@ -507,13 +458,13 @@ paths: description: "" operationId: "createUsersWithListInput" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - in: "body" name: "body" description: "List of user object" - required: false + required: true schema: type: "array" items: @@ -531,24 +482,33 @@ paths: description: "" operationId: "loginUser" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "username" in: "query" description: "The user name for login" - required: false + required: true type: "string" - name: "password" in: "query" description: "The password for login in clear text" - required: false + required: true type: "string" responses: 200: description: "successful operation" schema: type: "string" + headers: + X-Rate-Limit: + type: "integer" + format: "int32" + description: "calls per hour allowed by the user" + X-Expires-After: + type: "string" + format: "date-time" + description: "date in UTC when toekn expires" 400: description: "Invalid username/password supplied" x-contentType: "application/json" @@ -561,8 +521,8 @@ paths: description: "" operationId: "logoutUser" produces: - - "application/json" - "application/xml" + - "application/json" parameters: [] responses: default: @@ -577,8 +537,8 @@ paths: description: "" operationId: "getUserByName" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "username" in: "path" @@ -590,16 +550,6 @@ paths: description: "successful operation" schema: $ref: "#/definitions/User" - examples: - application/json: - id: 1 - username: "johnp" - firstName: "John" - lastName: "Public" - email: "johnp@swagger.io" - password: "-secret-" - phone: "0123456789" - userStatus: 0 400: description: "Invalid username supplied" 404: @@ -613,8 +563,8 @@ paths: description: "This can only be done by the logged in user." operationId: "updateUser" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "username" in: "path" @@ -624,7 +574,7 @@ paths: - in: "body" name: "body" description: "Updated user object" - required: false + required: true schema: $ref: "#/definitions/User" responses: @@ -641,8 +591,8 @@ paths: description: "This can only be done by the logged in user." operationId: "deleteUser" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "username" in: "path" @@ -669,7 +619,45 @@ securityDefinitions: write:pets: "modify pets in your account" read:pets: "read your pets" definitions: + Order: + type: "object" + properties: + id: + type: "integer" + format: "int64" + petId: + type: "integer" + format: "int64" + quantity: + type: "integer" + format: "int32" + shipDate: + type: "string" + format: "date-time" + status: + type: "string" + description: "Order Status" + enum: + - "placed" + - "approved" + - "delivered" + complete: + type: "boolean" + default: false + xml: + name: "Order" + Category: + type: "object" + properties: + id: + type: "integer" + format: "int64" + name: + type: "string" + xml: + name: "Category" User: + type: "object" properties: id: type: "integer" @@ -692,7 +680,8 @@ definitions: description: "User Status" xml: name: "User" - Category: + Tag: + type: "object" properties: id: type: "integer" @@ -700,8 +689,9 @@ definitions: name: type: "string" xml: - name: "Category" + name: "Tag" Pet: + type: "object" required: - "name" - "photoUrls" @@ -737,37 +727,16 @@ definitions: - "sold" xml: name: "Pet" - Tag: + ApiResponse: + type: "object" properties: - id: - type: "integer" - format: "int64" - name: - type: "string" - xml: - name: "Tag" - Order: - properties: - id: - type: "integer" - format: "int64" - petId: - type: "integer" - format: "int64" - quantity: + code: type: "integer" format: "int32" - shipDate: + type: type: "string" - format: "date-time" - status: + message: type: "string" - description: "Order Status" - enum: - - "placed" - - "approved" - - "delivered" - complete: - type: "boolean" - xml: - name: "Order" +externalDocs: + description: "Find out more about Swagger" + url: "http://swagger.io"