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/flaskConnexion.sh b/bin/flaskConnexion.sh index 1745d2a3ba2..563718f9061 100755 --- a/bin/flaskConnexion.sh +++ b/bin/flaskConnexion.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 -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l python-flask -o samples/server/petstore/flaskConnexion " +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l python-flask -o samples/server/petstore/flaskConnexion " java $JAVA_OPTS -Dservice -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/flaskConnexion/app.py b/samples/server/petstore/flaskConnexion/app.py index e790e0af19d..0b3ce76dd2f 100644 --- a/samples/server/petstore/flaskConnexion/app.py +++ b/samples/server/petstore/flaskConnexion/app.py @@ -4,5 +4,5 @@ import connexion if __name__ == '__main__': app = connexion.App(__name__, specification_dir='./swagger/') - app.add_api('swagger.yaml', arguments={'title': 'This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters'}) + app.add_api('swagger.yaml', arguments={'title': 'This is a sample server Petstore server. You can find out more about 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.'}) app.run(port=8080) diff --git a/samples/server/petstore/flaskConnexion/controllers/default_controller.py b/samples/server/petstore/flaskConnexion/controllers/default_controller.py index 6e469e0c90f..e6a231aa6fe 100644 --- a/samples/server/petstore/flaskConnexion/controllers/default_controller.py +++ b/samples/server/petstore/flaskConnexion/controllers/default_controller.py @@ -1,29 +1,20 @@ -def add_pet(body = None) -> str: - return 'do some magic!' - -def add_pet_using_byte_array(body = None) -> str: +def add_pet(body) -> str: return 'do some magic!' def delete_pet(petId, apiKey = None) -> str: return 'do some magic!' -def find_pets_by_status(status = None) -> str: +def find_pets_by_status(status) -> str: return 'do some magic!' -def find_pets_by_tags(tags = None) -> str: +def find_pets_by_tags(tags) -> str: return 'do some magic!' def get_pet_by_id(petId) -> str: return 'do some magic!' -def get_pet_by_id_in_object(petId) -> str: - return 'do some magic!' - -def pet_pet_idtesting_byte_arraytrue_get(petId) -> str: - return 'do some magic!' - -def update_pet(body = None) -> str: +def update_pet(body) -> str: return 'do some magic!' def update_pet_with_form(petId, name = None, status = None) -> str: @@ -35,28 +26,22 @@ def upload_file(petId, additionalMetadata = None, file = None) -> str: def delete_order(orderId) -> str: return 'do some magic!' -def find_orders_by_status(status = None) -> str: - return 'do some magic!' - def get_inventory() -> str: return 'do some magic!' -def get_inventory_in_object() -> str: - return 'do some magic!' - def get_order_by_id(orderId) -> str: return 'do some magic!' -def place_order(body = None) -> str: +def place_order(body) -> str: return 'do some magic!' -def create_user(body = None) -> str: +def create_user(body) -> str: return 'do some magic!' -def create_users_with_array_input(body = None) -> str: +def create_users_with_array_input(body) -> str: return 'do some magic!' -def create_users_with_list_input(body = None) -> str: +def create_users_with_list_input(body) -> str: return 'do some magic!' def delete_user(username) -> str: @@ -65,11 +50,11 @@ def delete_user(username) -> str: def get_user_by_name(username) -> str: return 'do some magic!' -def login_user(username = None, password = None) -> str: +def login_user(username, password) -> str: return 'do some magic!' def logout_user() -> str: return 'do some magic!' -def update_user(username, body = None) -> str: +def update_user(username, body) -> str: return 'do some magic!' diff --git a/samples/server/petstore/flaskConnexion/swagger/swagger.yaml b/samples/server/petstore/flaskConnexion/swagger/swagger.yaml index 5983ddd1062..368e2c24e82 100644 --- a/samples/server/petstore/flaskConnexion/swagger/swagger.yaml +++ b/samples/server/petstore/flaskConnexion/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: @@ -87,26 +100,22 @@ paths: description: "Multiple status values can be provided with comma separated strings" operationId: "controllers.default_controller.find_pets_by_status" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "status" in: "query" - description: "Status values that need to be considered for query" - required: false + description: "Status values that need to be considered for filter" + required: true type: "array" items: type: "string" + default: "available" enum: - "available" - "pending" - "sold" - collectionFormat: "multi" - default: "available" - enum: - - "available" - - "pending" - - "sold" + collectionFormat: "csv" responses: 200: description: "successful operation" @@ -127,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: "controllers.default_controller.find_pets_by_tags" 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" @@ -162,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: "controllers.default_controller.get_pet_by_id" 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" @@ -186,9 +194,6 @@ paths: description: "Pet not found" security: - api_key: [] - - petstore_auth: - - "write:pets" - - "read:pets" x-tags: - tag: "pet" post: @@ -200,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" @@ -234,12 +240,11 @@ paths: description: "" operationId: "controllers.default_controller.delete_pet" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "api_key" in: "header" - description: "" required: false type: "string" - name: "petId" @@ -268,7 +273,6 @@ paths: - "multipart/form-data" produces: - "application/json" - - "application/xml" parameters: - name: "petId" in: "path" @@ -286,151 +290,17 @@ paths: description: "file to upload" required: false type: "file" - responses: - default: - description: "successful operation" - security: - - petstore_auth: - - "write:pets" - - "read:pets" - x-tags: - - tag: "pet" - /pet/{petId}?response=inline_arbitrary_object: - get: - tags: - - "pet" - summary: "Fake endpoint to test inline arbitrary object return by 'Find pet\ - \ by ID'" - description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\ - \ API error conditions" - operationId: "controllers.default_controller.get_pet_by_id_in_object" - 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: - $ref: "#/definitions/inline_response_200" - 400: - description: "Invalid ID supplied" - 404: - description: "Pet not found" - security: - - api_key: [] - - petstore_auth: - - "write:pets" - - "read:pets" - x-tags: - - tag: "pet" - /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: "controllers.default_controller.pet_pet_idtesting_byte_arraytrue_get" - 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-tags: - - tag: "pet" - /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: "controllers.default_controller.add_pet_using_byte_array" - 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" + $ref: "#/definitions/ApiResponse" security: - petstore_auth: - "write:pets" - "read:pets" x-tags: - tag: "pet" - /store/findByStatus: - get: - tags: - - "store" - summary: "Finds orders by status" - description: "A single status value can be provided as a string" - operationId: "controllers.default_controller.find_orders_by_status" - produces: - - "application/json" - - "application/xml" - parameters: - - name: "status" - in: "query" - description: "Status value that needs to be considered for query" - required: false - type: "string" - default: "placed" - enum: - - "placed" - - "approved" - - "delivered" - responses: - 200: - description: "successful operation" - schema: - type: "array" - items: - $ref: "#/definitions/Order" - 400: - description: "Invalid status value" - security: - - test_api_client_secret: [] - test_api_client_id: [] - x-tags: - - tag: "store" /store/inventory: get: tags: @@ -440,7 +310,6 @@ paths: operationId: "controllers.default_controller.get_inventory" produces: - "application/json" - - "application/xml" parameters: [] responses: 200: @@ -454,28 +323,6 @@ paths: - api_key: [] x-tags: - tag: "store" - /store/inventory?response=arbitrary_object: - get: - tags: - - "store" - summary: "Fake endpoint to test arbitrary object return by 'Get inventory'" - description: "Returns an arbitrary object which is actually a map of status\ - \ codes to quantities" - operationId: "controllers.default_controller.get_inventory_in_object" - produces: - - "application/json" - - "application/xml" - parameters: [] - responses: - 200: - description: "successful operation" - schema: - type: "object" - properties: {} - security: - - api_key: [] - x-tags: - - tag: "store" /store/order: post: tags: @@ -484,13 +331,13 @@ paths: description: "" operationId: "controllers.default_controller.place_order" 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: @@ -500,9 +347,6 @@ paths: $ref: "#/definitions/Order" 400: description: "Invalid Order" - security: - - test_api_client_secret: [] - test_api_client_id: [] x-tags: - tag: "store" /store/order/{orderId}: @@ -514,14 +358,17 @@ paths: \ values will generated exceptions" operationId: "controllers.default_controller.get_order_by_id" 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" @@ -531,9 +378,6 @@ paths: description: "Invalid ID supplied" 404: description: "Order not found" - security: - - test_api_key_header: [] - - test_api_key_query: [] x-tags: - tag: "store" delete: @@ -544,14 +388,15 @@ paths: \ above 1000 or nonintegers will generate API errors" operationId: "controllers.default_controller.delete_order" 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" @@ -567,13 +412,13 @@ paths: description: "This can only be done by the logged in user." operationId: "controllers.default_controller.create_user" 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: @@ -589,13 +434,13 @@ paths: description: "" operationId: "controllers.default_controller.create_users_with_array_input" 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: @@ -613,13 +458,13 @@ paths: description: "" operationId: "controllers.default_controller.create_users_with_list_input" 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: @@ -637,24 +482,33 @@ paths: description: "" operationId: "controllers.default_controller.login_user" 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-tags: @@ -667,8 +521,8 @@ paths: description: "" operationId: "controllers.default_controller.logout_user" produces: - - "application/json" - "application/xml" + - "application/json" parameters: [] responses: default: @@ -683,8 +537,8 @@ paths: description: "" operationId: "controllers.default_controller.get_user_by_name" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "username" in: "path" @@ -696,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: @@ -719,8 +563,8 @@ paths: description: "This can only be done by the logged in user." operationId: "controllers.default_controller.update_user" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "username" in: "path" @@ -730,7 +574,7 @@ paths: - in: "body" name: "body" description: "Updated user object" - required: false + required: true schema: $ref: "#/definitions/User" responses: @@ -747,8 +591,8 @@ paths: description: "This can only be done by the logged in user." operationId: "controllers.default_controller.delete_user" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "username" in: "path" @@ -760,33 +604,13 @@ paths: description: "Invalid username supplied" 404: description: "User not found" - security: - - test_http_basic: [] x-tags: - tag: "user" securityDefinitions: - test_api_key_header: - type: "apiKey" - name: "test_api_key_header" - in: "header" api_key: type: "apiKey" name: "api_key" in: "header" - test_http_basic: - type: "basic" - test_api_client_secret: - type: "apiKey" - name: "x-test_api_client_secret" - in: "header" - test_api_client_id: - type: "apiKey" - name: "x-test_api_client_id" - in: "header" - test_api_key_query: - type: "apiKey" - name: "test_api_key_query" - in: "query" petstore_auth: type: "oauth2" authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog" @@ -795,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" @@ -818,7 +680,8 @@ definitions: description: "User Status" xml: name: "User" - Category: + Tag: + type: "object" properties: id: type: "integer" @@ -826,8 +689,9 @@ definitions: name: type: "string" xml: - name: "Category" + name: "Tag" Pet: + type: "object" required: - "name" - "photoUrls" @@ -863,163 +727,16 @@ definitions: - "sold" xml: name: "Pet" - Tag: - properties: - id: - type: "integer" - format: "int64" - name: - type: "string" - xml: - name: "Tag" - Order: - properties: - id: - type: "integer" - format: "int64" - readOnly: true - 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" - xml: - name: "Order" - $special[model.name]: - properties: - $special[property.name]: - type: "integer" - format: "int64" - xml: - name: "$special[model.name]" - Return: - properties: - return: - type: "integer" - format: "int32" - description: "Model for testing reserved words" - xml: - name: "Return" - Name: - required: - - "name" - properties: - name: - type: "integer" - format: "int32" - snake_case: - type: "integer" - format: "int32" - readOnly: true - description: "Model for testing model name same as property name" - xml: - name: "Name" - 200_response: - properties: - name: - type: "integer" - format: "int32" - description: "Model for testing model name starting with number" - xml: - name: "Name" - Dog: - allOf: - - $ref: "#/definitions/Animal" - - type: "object" - properties: - breed: - type: "string" - Cat: - allOf: - - $ref: "#/definitions/Animal" - - type: "object" - properties: - declawed: - type: "boolean" - Animal: + ApiResponse: type: "object" - required: - - "className" - discriminator: "className" properties: - className: - type: "string" - format_test: - type: "object" - required: - - "number" - properties: - integer: - type: "integer" - int32: + code: type: "integer" format: "int32" - int64: - type: "integer" - format: "int64" - number: - type: "number" - float: - type: "number" - format: "float" - double: - type: "number" - format: "double" - string: + type: type: "string" - byte: + message: type: "string" - format: "byte" - binary: - type: "string" - format: "binary" - date: - type: "string" - format: "date" - dateTime: - type: "string" - format: "date-time" - password: - type: "string" - format: "password" - inline_response_200: - required: - - "id" - properties: - tags: - type: "array" - items: - $ref: "#/definitions/Tag" - id: - type: "integer" - format: "int64" - category: - type: "object" - properties: {} - status: - type: "string" - description: "pet status in the store" - enum: - - "available" - - "pending" - - "sold" - name: - type: "string" - example: "doggie" - photoUrls: - type: "array" - items: - type: "string" +externalDocs: + description: "Find out more about Swagger" + url: "http://swagger.io" diff --git a/samples/server/petstore/java-inflector/inflector.yaml b/samples/server/petstore/java-inflector/inflector.yaml index 8a11ca3b659..2511293c542 100644 --- a/samples/server/petstore/java-inflector/inflector.yaml +++ b/samples/server/petstore/java-inflector/inflector.yaml @@ -2,12 +2,15 @@ controllerPackage: io.swagger.handler modelPackage: io.swagger.model swaggerUrl: ./src/main/swagger/swagger.yaml modelMappings: - User : io.swagger.model.User - Category : io.swagger.model.Category - Pet : io.swagger.model.Pet - Tag : io.swagger.model.Tag - Order : io.swagger.model.Order - + # to enable explicit mappings, use this syntax: + DefinitionFromSwaggerSpecification: fully.qualified.path.to.Model + ApiResponse : io.swagger.model.ApiResponse +Category : io.swagger.model.Category +Order : io.swagger.model.Order +Pet : io.swagger.model.Pet +Tag : io.swagger.model.Tag +User : io.swagger.model.User + entityProcessors: - json - xml diff --git a/samples/server/petstore/java-inflector/pom.xml b/samples/server/petstore/java-inflector/pom.xml index ace023a70db..d93b5e8a6c5 100644 --- a/samples/server/petstore/java-inflector/pom.xml +++ b/samples/server/petstore/java-inflector/pom.xml @@ -19,6 +19,25 @@ target ${project.artifactId}-${project.version} + + org.codehaus.mojo + build-helper-maven-plugin + 1.10 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + maven-dependency-plugin @@ -78,12 +97,21 @@ io.swagger swagger-inflector - 1.0.0 + ${swagger-inflector-version} + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + true + + + 1.0.0 - 1.5.7 + 1.0.4 9.2.9.v20150224 1.0.1 4.8.2 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..e05a1ffc1f2 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:48:04.458+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..cf96ddf68fd 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:48:04.458+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..4d99da8b342 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:48:04.458+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/java/io/swagger/model/Category.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java deleted file mode 100644 index ce925e6cfb8..00000000000 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java +++ /dev/null @@ -1,87 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-01-19T23:33:17.124+08:00") -public class Category { - - private Long id = null; - private String name = null; - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Category category = (Category) o; - return Objects.equals(id, category.id) && - Objects.equals(name, category.name); - } - - @Override - public int hashCode() { - return Objects.hash(id, name); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Category {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java deleted file mode 100644 index 4a1505f7442..00000000000 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java +++ /dev/null @@ -1,173 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.util.Date; - - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-01-19T23:33:17.124+08:00") -public class Order { - - private Long id = null; - private Long petId = null; - private Integer quantity = null; - private Date shipDate = null; - - - public enum StatusEnum { - PLACED("placed"), - APPROVED("approved"), - DELIVERED("delivered"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return value; - } - } - - private StatusEnum status = null; - private Boolean complete = null; - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("petId") - public Long getPetId() { - return petId; - } - public void setPetId(Long petId) { - this.petId = petId; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("quantity") - public Integer getQuantity() { - return quantity; - } - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("shipDate") - public Date getShipDate() { - return shipDate; - } - public void setShipDate(Date shipDate) { - this.shipDate = shipDate; - } - - - /** - * Order Status - **/ - - @ApiModelProperty(value = "Order Status") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("complete") - public Boolean getComplete() { - return complete; - } - public void setComplete(Boolean complete) { - this.complete = complete; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Order order = (Order) o; - return Objects.equals(id, order.id) && - Objects.equals(petId, order.petId) && - Objects.equals(quantity, order.quantity) && - Objects.equals(shipDate, order.shipDate) && - Objects.equals(status, order.status) && - Objects.equals(complete, order.complete); - } - - @Override - public int hashCode() { - return Objects.hash(id, petId, quantity, shipDate, status, complete); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Order {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); - sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); - sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java deleted file mode 100644 index 1e62a0a60dd..00000000000 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java +++ /dev/null @@ -1,175 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.model.Category; -import io.swagger.model.Tag; -import java.util.*; - - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-01-19T23:33:17.124+08:00") -public class Pet { - - private Long id = null; - private Category category = null; - private String name = null; - private List photoUrls = new ArrayList(); - private List tags = new ArrayList(); - - - public enum StatusEnum { - AVAILABLE("available"), - PENDING("pending"), - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return value; - } - } - - private StatusEnum status = null; - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("category") - public Category getCategory() { - return category; - } - public void setCategory(Category category) { - this.category = category; - } - - - /** - **/ - - @ApiModelProperty(required = true, value = "") - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - /** - **/ - - @ApiModelProperty(required = true, value = "") - @JsonProperty("photoUrls") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("tags") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - - /** - * pet status in the store - **/ - - @ApiModelProperty(value = "pet status in the store") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Pet pet = (Pet) o; - return Objects.equals(id, pet.id) && - Objects.equals(category, pet.category) && - Objects.equals(name, pet.name) && - Objects.equals(photoUrls, pet.photoUrls) && - Objects.equals(tags, pet.tags) && - Objects.equals(status, pet.status); - } - - @Override - public int hashCode() { - return Objects.hash(id, category, name, photoUrls, tags, status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Pet {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java deleted file mode 100644 index c0d2e1e4c0e..00000000000 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java +++ /dev/null @@ -1,87 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-01-19T23:33:17.124+08:00") -public class Tag { - - private Long id = null; - private String name = null; - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Tag tag = (Tag) o; - return Objects.equals(id, tag.id) && - Objects.equals(name, tag.name); - } - - @Override - public int hashCode() { - return Objects.hash(id, name); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Tag {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java deleted file mode 100644 index e2982024306..00000000000 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java +++ /dev/null @@ -1,184 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-01-19T23:33:17.124+08:00") -public class User { - - private Long id = null; - private String username = null; - private String firstName = null; - private String lastName = null; - private String email = null; - private String password = null; - private String phone = null; - private Integer userStatus = null; - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("username") - public String getUsername() { - return username; - } - public void setUsername(String username) { - this.username = username; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("firstName") - public String getFirstName() { - return firstName; - } - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("lastName") - public String getLastName() { - return lastName; - } - public void setLastName(String lastName) { - this.lastName = lastName; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("email") - public String getEmail() { - return email; - } - public void setEmail(String email) { - this.email = email; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("password") - public String getPassword() { - return password; - } - public void setPassword(String password) { - this.password = password; - } - - - /** - **/ - - @ApiModelProperty(value = "") - @JsonProperty("phone") - public String getPhone() { - return phone; - } - public void setPhone(String phone) { - this.phone = phone; - } - - - /** - * User Status - **/ - - @ApiModelProperty(value = "User Status") - @JsonProperty("userStatus") - public Integer getUserStatus() { - return userStatus; - } - public void setUserStatus(Integer userStatus) { - this.userStatus = userStatus; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - User user = (User) o; - return Objects.equals(id, user.id) && - Objects.equals(username, user.username) && - Objects.equals(firstName, user.firstName) && - Objects.equals(lastName, user.lastName) && - Objects.equals(email, user.email) && - Objects.equals(password, user.password) && - Objects.equals(phone, user.phone) && - Objects.equals(userStatus, user.userStatus); - } - - @Override - public int hashCode() { - return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class User {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" username: ").append(toIndentedString(username)).append("\n"); - sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); - sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); - sb.append(" email: ").append(toIndentedString(email)).append("\n"); - sb.append(" password: ").append(toIndentedString(password)).append("\n"); - sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); - sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - 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" diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java index 7b26e047746..39ffe2436a8 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java @@ -14,7 +14,7 @@ public interface StoreApi { @Path("/store/order/{orderId}") @Produces({ "application/xml", "application/json" }) - public Response deleteOrder(@PathParam("orderId") Long orderId); + public Response deleteOrder(@PathParam("orderId") String orderId); @GET @Path("/store/inventory") diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/ApiResponse.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/ApiResponse.java index 68908204335..e6100b2fc6a 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/ApiResponse.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/ApiResponse.java @@ -24,7 +24,6 @@ public class ApiResponse { private String message = null; - /** **/ @@ -34,7 +33,6 @@ public class ApiResponse { public void setCode(Integer code) { this.code = code; } - /** **/ @@ -44,7 +42,6 @@ public class ApiResponse { public void setType(String type) { this.type = type; } - /** **/ @@ -54,7 +51,6 @@ public class ApiResponse { public void setMessage(String message) { this.message = message; } - @Override public String toString() { diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java index d34537dc435..f2d34f77367 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java @@ -22,7 +22,6 @@ public class Category { private String name = null; - /** **/ @@ -32,7 +31,6 @@ public class Category { public void setId(Long id) { this.id = id; } - /** **/ @@ -42,7 +40,6 @@ public class Category { public void setName(String name) { this.name = name; } - @Override public String toString() { diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java index 93c120e6c5a..3a9cbf3c130 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java @@ -32,7 +32,7 @@ import javax.xml.bind.annotation.XmlType; @XmlType(name="Order") @XmlEnum public enum Order { - {values=[placed, approved, delivered], enumVars=[{name=PLACED, value=placed}, {name=APPROVED, value=approved}, {name=DELIVERED, value=delivered}]}, + {values=[placed, approved, delivered], enumVars=[{name=PLACED, value=placed}, {name=APPROVED, value=approved}, {name=DELIVERED, value=delivered}]}, public String value() { return name(); @@ -47,7 +47,6 @@ public enum Order { private Boolean complete = false; - /** **/ @@ -57,7 +56,6 @@ public enum Order { public void setId(Long id) { this.id = id; } - /** **/ @@ -67,7 +65,6 @@ public enum Order { public void setPetId(Long petId) { this.petId = petId; } - /** **/ @@ -77,7 +74,6 @@ public enum Order { public void setQuantity(Integer quantity) { this.quantity = quantity; } - /** **/ @@ -87,7 +83,6 @@ public enum Order { public void setShipDate(javax.xml.datatype.XMLGregorianCalendar shipDate) { this.shipDate = shipDate; } - /** * Order Status **/ @@ -98,7 +93,6 @@ public enum Order { public void setStatus(StatusEnum status) { this.status = status; } - /** **/ @@ -108,7 +102,6 @@ public enum Order { public void setComplete(Boolean complete) { this.complete = complete; } - @Override public String toString() { diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java index 979781f19e0..707f90a3af8 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java @@ -38,7 +38,7 @@ import javax.xml.bind.annotation.XmlType; @XmlType(name="Pet") @XmlEnum public enum Pet { - {values=[available, pending, sold], enumVars=[{name=AVAILABLE, value=available}, {name=PENDING, value=pending}, {name=SOLD, value=sold}]}, + {values=[available, pending, sold], enumVars=[{name=AVAILABLE, value=available}, {name=PENDING, value=pending}, {name=SOLD, value=sold}]}, public String value() { return name(); @@ -51,7 +51,6 @@ public enum Pet { private StatusEnum status = null; - /** **/ @@ -61,7 +60,6 @@ public enum Pet { public void setId(Long id) { this.id = id; } - /** **/ @@ -71,7 +69,6 @@ public enum Pet { public void setCategory(Category category) { this.category = category; } - /** **/ @@ -81,7 +78,6 @@ public enum Pet { public void setName(String name) { this.name = name; } - /** **/ @@ -91,7 +87,6 @@ public enum Pet { public void setPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; } - /** **/ @@ -101,7 +96,6 @@ public enum Pet { public void setTags(List tags) { this.tags = tags; } - /** * pet status in the store **/ @@ -112,7 +106,6 @@ public enum Pet { public void setStatus(StatusEnum status) { this.status = status; } - @Override public String toString() { diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java index b2a2bcaaff9..1912fa6f731 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java @@ -22,7 +22,6 @@ public class Tag { private String name = null; - /** **/ @@ -32,7 +31,6 @@ public class Tag { public void setId(Long id) { this.id = id; } - /** **/ @@ -42,7 +40,6 @@ public class Tag { public void setName(String name) { this.name = name; } - @Override public String toString() { diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java index 8683a630e5c..c35af076cf6 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java @@ -34,7 +34,6 @@ public class User { private Integer userStatus = null; - /** **/ @@ -44,7 +43,6 @@ public class User { public void setId(Long id) { this.id = id; } - /** **/ @@ -54,7 +52,6 @@ public class User { public void setUsername(String username) { this.username = username; } - /** **/ @@ -64,7 +61,6 @@ public class User { public void setFirstName(String firstName) { this.firstName = firstName; } - /** **/ @@ -74,7 +70,6 @@ public class User { public void setLastName(String lastName) { this.lastName = lastName; } - /** **/ @@ -84,7 +79,6 @@ public class User { public void setEmail(String email) { this.email = email; } - /** **/ @@ -94,7 +88,6 @@ public class User { public void setPassword(String password) { this.password = password; } - /** **/ @@ -104,7 +97,6 @@ public class User { public void setPhone(String phone) { this.phone = phone; } - /** * User Status **/ @@ -115,7 +107,6 @@ public class User { public void setUserStatus(Integer userStatus) { this.userStatus = userStatus; } - @Override public String toString() { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java index bfeaf6571ad..2a519b09b8b 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public class ApiException extends Exception{ private int code; public ApiException (int code, String msg) { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java index 419f9ebab09..a7a3a461a1d 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java @@ -5,7 +5,7 @@ import java.io.IOException; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public class ApiOriginFilter implements javax.servlet.Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java index 2e00645c336..07f1fd78fe0 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java @@ -3,7 +3,7 @@ package io.swagger.api; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java index 52d5224b7eb..a8a136f8760 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public class NotFoundException extends ApiException { private int code; public NotFoundException (int code, String msg) { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java index 10d335c19bd..8beeb2b7a93 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java @@ -5,7 +5,7 @@ import io.swagger.api.PetApiService; import io.swagger.api.factories.PetApiServiceFactory; import io.swagger.model.Pet; -import io.swagger.model.InlineResponse200; +import io.swagger.model.ApiResponse; import java.io.File; import java.util.List; @@ -22,14 +22,14 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; @Path("/pet") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public class PetApi { private final PetApiService delegate = PetApiServiceFactory.getPetApi(); @POST @Consumes({ "application/json", "application/xml" }) - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response addPet( Pet body,@Context SecurityContext securityContext) throws NotFoundException { return delegate.addPet(body,securityContext); @@ -37,7 +37,7 @@ public class PetApi { @DELETE @Path("/{petId}") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response deletePet( @PathParam("petId") Long petId,@HeaderParam("api_key") String apiKey,@Context SecurityContext securityContext) throws NotFoundException { return delegate.deletePet(petId,apiKey,securityContext); @@ -45,7 +45,7 @@ public class PetApi { @GET @Path("/findByStatus") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response findPetsByStatus( @QueryParam("status") List status,@Context SecurityContext securityContext) throws NotFoundException { return delegate.findPetsByStatus(status,securityContext); @@ -53,7 +53,7 @@ public class PetApi { @GET @Path("/findByTags") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response findPetsByTags( @QueryParam("tags") List tags,@Context SecurityContext securityContext) throws NotFoundException { return delegate.findPetsByTags(tags,securityContext); @@ -61,31 +61,15 @@ public class PetApi { @GET @Path("/{petId}") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response getPetById( @PathParam("petId") Long petId,@Context SecurityContext securityContext) throws NotFoundException { return delegate.getPetById(petId,securityContext); } - @GET - @Path("/{petId}?response=inline_arbitrary_object") - - @Produces({ "application/json", "application/xml" }) - public Response getPetByIdInObject( @PathParam("petId") Long petId,@Context SecurityContext securityContext) - throws NotFoundException { - return delegate.getPetByIdInObject(petId,securityContext); - } - @GET - @Path("/{petId}?testing_byte_array=true") - - @Produces({ "application/json", "application/xml" }) - public Response petPetIdtestingByteArraytrueGet( @PathParam("petId") Long petId,@Context SecurityContext securityContext) - throws NotFoundException { - return delegate.petPetIdtestingByteArraytrueGet(petId,securityContext); - } @PUT @Consumes({ "application/json", "application/xml" }) - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response updatePet( Pet body,@Context SecurityContext securityContext) throws NotFoundException { return delegate.updatePet(body,securityContext); @@ -93,15 +77,15 @@ public class PetApi { @POST @Path("/{petId}") @Consumes({ "application/x-www-form-urlencoded" }) - @Produces({ "application/json", "application/xml" }) - public Response updatePetWithForm( @PathParam("petId") String petId,@FormParam("name") String name,@FormParam("status") String status,@Context SecurityContext securityContext) + @Produces({ "application/xml", "application/json" }) + public Response updatePetWithForm( @PathParam("petId") Long petId,@FormParam("name") String name,@FormParam("status") String status,@Context SecurityContext securityContext) throws NotFoundException { return delegate.updatePetWithForm(petId,name,status,securityContext); } @POST @Path("/{petId}/uploadImage") @Consumes({ "multipart/form-data" }) - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/json" }) public Response uploadFile(MultipartFormDataInput input, @PathParam("petId") Long petId,@Context SecurityContext securityContext) throws NotFoundException { return delegate.uploadFile(input,petId,securityContext); diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java index 47ed65af8ab..4d65977483c 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java @@ -6,7 +6,7 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; import io.swagger.model.Pet; -import io.swagger.model.InlineResponse200; +import io.swagger.model.ApiResponse; import java.io.File; import java.util.List; @@ -17,37 +17,22 @@ import java.io.InputStream; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public abstract class PetApiService { - public abstract Response addPet(Pet body,SecurityContext securityContext) throws NotFoundException; - public abstract Response deletePet(Long petId,String apiKey,SecurityContext securityContext) throws NotFoundException; - public abstract Response findPetsByStatus(List status,SecurityContext securityContext) throws NotFoundException; - public abstract Response findPetsByTags(List tags,SecurityContext securityContext) throws NotFoundException; - public abstract Response getPetById(Long petId,SecurityContext securityContext) throws NotFoundException; - - public abstract Response getPetByIdInObject(Long petId,SecurityContext securityContext) - throws NotFoundException; - - public abstract Response petPetIdtestingByteArraytrueGet(Long petId,SecurityContext securityContext) - throws NotFoundException; - public abstract Response updatePet(Pet body,SecurityContext securityContext) throws NotFoundException; - - public abstract Response updatePetWithForm(String petId,String name,String status,SecurityContext securityContext) + public abstract Response updatePetWithForm(Long petId,String name,String status,SecurityContext securityContext) throws NotFoundException; - public abstract Response uploadFile(MultipartFormDataInput input,Long petId,SecurityContext securityContext) throws NotFoundException; - } diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java index 945b73e32f3..e6ab3511835 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java @@ -4,8 +4,8 @@ import io.swagger.model.*; import io.swagger.api.StoreApiService; import io.swagger.api.factories.StoreApiServiceFactory; -import io.swagger.model.Order; import java.util.Map; +import io.swagger.model.Order; import java.util.List; import io.swagger.api.NotFoundException; @@ -20,54 +20,38 @@ import javax.ws.rs.*; @Path("/store") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public class StoreApi { private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi(); @DELETE @Path("/order/{orderId}") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response deleteOrder( @PathParam("orderId") String orderId,@Context SecurityContext securityContext) throws NotFoundException { return delegate.deleteOrder(orderId,securityContext); } @GET - @Path("/findByStatus") - - @Produces({ "application/json", "application/xml" }) - public Response findOrdersByStatus( @QueryParam("status") String status,@Context SecurityContext securityContext) - throws NotFoundException { - return delegate.findOrdersByStatus(status,securityContext); - } - @GET @Path("/inventory") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/json" }) public Response getInventory(@Context SecurityContext securityContext) throws NotFoundException { return delegate.getInventory(securityContext); } @GET - @Path("/inventory?response=arbitrary_object") - - @Produces({ "application/json", "application/xml" }) - public Response getInventoryInObject(@Context SecurityContext securityContext) - throws NotFoundException { - return delegate.getInventoryInObject(securityContext); - } - @GET @Path("/order/{orderId}") - @Produces({ "application/json", "application/xml" }) - public Response getOrderById( @PathParam("orderId") String orderId,@Context SecurityContext securityContext) + @Produces({ "application/xml", "application/json" }) + public Response getOrderById( @PathParam("orderId") Long orderId,@Context SecurityContext securityContext) throws NotFoundException { return delegate.getOrderById(orderId,securityContext); } @POST @Path("/order") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response placeOrder( Order body,@Context SecurityContext securityContext) throws NotFoundException { return delegate.placeOrder(body,securityContext); diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java index 61ad4fd923b..c246af6e58e 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java @@ -4,8 +4,8 @@ import io.swagger.api.*; import io.swagger.model.*; -import io.swagger.model.Order; import java.util.Map; +import io.swagger.model.Order; import java.util.List; import io.swagger.api.NotFoundException; @@ -15,25 +15,14 @@ import java.io.InputStream; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public abstract class StoreApiService { - public abstract Response deleteOrder(String orderId,SecurityContext securityContext) throws NotFoundException; - - public abstract Response findOrdersByStatus(String status,SecurityContext securityContext) - throws NotFoundException; - public abstract Response getInventory(SecurityContext securityContext) throws NotFoundException; - - public abstract Response getInventoryInObject(SecurityContext securityContext) + public abstract Response getOrderById(Long orderId,SecurityContext securityContext) throws NotFoundException; - - public abstract Response getOrderById(String orderId,SecurityContext securityContext) - throws NotFoundException; - public abstract Response placeOrder(Order body,SecurityContext securityContext) throws NotFoundException; - } diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java index 87d9317396e..c358c74b469 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java index be7af49cefa..966965db529 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java @@ -20,14 +20,14 @@ import javax.ws.rs.*; @Path("/user") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public class UserApi { private final UserApiService delegate = UserApiServiceFactory.getUserApi(); @POST - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response createUser( User body,@Context SecurityContext securityContext) throws NotFoundException { return delegate.createUser(body,securityContext); @@ -35,7 +35,7 @@ public class UserApi { @POST @Path("/createWithArray") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response createUsersWithArrayInput( List body,@Context SecurityContext securityContext) throws NotFoundException { return delegate.createUsersWithArrayInput(body,securityContext); @@ -43,7 +43,7 @@ public class UserApi { @POST @Path("/createWithList") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response createUsersWithListInput( List body,@Context SecurityContext securityContext) throws NotFoundException { return delegate.createUsersWithListInput(body,securityContext); @@ -51,7 +51,7 @@ public class UserApi { @DELETE @Path("/{username}") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response deleteUser( @PathParam("username") String username,@Context SecurityContext securityContext) throws NotFoundException { return delegate.deleteUser(username,securityContext); @@ -59,7 +59,7 @@ public class UserApi { @GET @Path("/{username}") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response getUserByName( @PathParam("username") String username,@Context SecurityContext securityContext) throws NotFoundException { return delegate.getUserByName(username,securityContext); @@ -67,7 +67,7 @@ public class UserApi { @GET @Path("/login") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response loginUser( @QueryParam("username") String username, @QueryParam("password") String password,@Context SecurityContext securityContext) throws NotFoundException { return delegate.loginUser(username,password,securityContext); @@ -75,7 +75,7 @@ public class UserApi { @GET @Path("/logout") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response logoutUser(@Context SecurityContext securityContext) throws NotFoundException { return delegate.logoutUser(securityContext); @@ -83,7 +83,7 @@ public class UserApi { @PUT @Path("/{username}") - @Produces({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) public Response updateUser( @PathParam("username") String username, User body,@Context SecurityContext securityContext) throws NotFoundException { return delegate.updateUser(username,body,securityContext); diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java index d28f14c07c0..a656efd6f72 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java @@ -15,31 +15,22 @@ import java.io.InputStream; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public abstract class UserApiService { - public abstract Response createUser(User body,SecurityContext securityContext) throws NotFoundException; - public abstract Response createUsersWithArrayInput(List body,SecurityContext securityContext) throws NotFoundException; - public abstract Response createUsersWithListInput(List body,SecurityContext securityContext) throws NotFoundException; - public abstract Response deleteUser(String username,SecurityContext securityContext) throws NotFoundException; - public abstract Response getUserByName(String username,SecurityContext securityContext) throws NotFoundException; - public abstract Response loginUser(String username,String password,SecurityContext securityContext) throws NotFoundException; - public abstract Response logoutUser(SecurityContext securityContext) throws NotFoundException; - public abstract Response updateUser(String username,User body,SecurityContext securityContext) throws NotFoundException; - } diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ApiResponse.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ApiResponse.java new file mode 100644 index 00000000000..f67a16b28e6 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ApiResponse.java @@ -0,0 +1,94 @@ +package io.swagger.model; + +import java.util.Objects; +import java.util.ArrayList; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +public class ApiResponse { + + private Integer code = null; + private String type = null; + private String message = null; + + /** + **/ + + @JsonProperty("code") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + /** + **/ + + @JsonProperty("type") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + + @JsonProperty("message") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiResponse apiResponse = (ApiResponse) o; + return Objects.equals(code, apiResponse.code) && + Objects.equals(type, apiResponse.type) && + Objects.equals(message, apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java index 3786c816887..c74992a36ba 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java @@ -8,13 +8,12 @@ import com.fasterxml.jackson.annotation.JsonValue; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public class Category { private Long id = null; private String name = null; - /** **/ @@ -26,7 +25,6 @@ public class Category { this.id = id; } - /** **/ @@ -38,7 +36,6 @@ public class Category { this.name = name; } - @Override public boolean equals(Object o) { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java index 1d40f9c3359..7d1093ec0e2 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java @@ -9,7 +9,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public class Order { private Long id = null; @@ -37,9 +37,8 @@ public class Order { } private StatusEnum status = null; - private Boolean complete = null; + private Boolean complete = false; - /** **/ @@ -51,7 +50,6 @@ public class Order { this.id = id; } - /** **/ @@ -63,7 +61,6 @@ public class Order { this.petId = petId; } - /** **/ @@ -75,7 +72,6 @@ public class Order { this.quantity = quantity; } - /** **/ @@ -87,7 +83,6 @@ public class Order { this.shipDate = shipDate; } - /** * Order Status **/ @@ -100,7 +95,6 @@ public class Order { this.status = status; } - /** **/ @@ -112,7 +106,6 @@ public class Order { this.complete = complete; } - @Override public boolean equals(Object o) { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java index 51f31e982ef..c763a801181 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java @@ -11,7 +11,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public class Pet { private Long id = null; @@ -41,7 +41,6 @@ public class Pet { private StatusEnum status = null; - /** **/ @@ -53,7 +52,6 @@ public class Pet { this.id = id; } - /** **/ @@ -65,7 +63,6 @@ public class Pet { this.category = category; } - /** **/ @@ -77,7 +74,6 @@ public class Pet { this.name = name; } - /** **/ @@ -89,7 +85,6 @@ public class Pet { this.photoUrls = photoUrls; } - /** **/ @@ -101,7 +96,6 @@ public class Pet { this.tags = tags; } - /** * pet status in the store **/ @@ -114,7 +108,6 @@ public class Pet { this.status = status; } - @Override public boolean equals(Object o) { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java index 9f231bfabcd..3046b9ff951 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java @@ -8,13 +8,12 @@ import com.fasterxml.jackson.annotation.JsonValue; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public class Tag { private Long id = null; private String name = null; - /** **/ @@ -26,7 +25,6 @@ public class Tag { this.id = id; } - /** **/ @@ -38,7 +36,6 @@ public class Tag { this.name = name; } - @Override public boolean equals(Object o) { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java index 16b2b78a9f3..924d72b9bcc 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonValue; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") public class User { private Long id = null; @@ -20,7 +20,6 @@ public class User { private String phone = null; private Integer userStatus = null; - /** **/ @@ -32,7 +31,6 @@ public class User { this.id = id; } - /** **/ @@ -44,7 +42,6 @@ public class User { this.username = username; } - /** **/ @@ -56,7 +53,6 @@ public class User { this.firstName = firstName; } - /** **/ @@ -68,7 +64,6 @@ public class User { this.lastName = lastName; } - /** **/ @@ -80,7 +75,6 @@ public class User { this.email = email; } - /** **/ @@ -92,7 +86,6 @@ public class User { this.password = password; } - /** **/ @@ -104,7 +97,6 @@ public class User { this.phone = phone; } - /** * User Status **/ @@ -117,7 +109,6 @@ public class User { this.userStatus = userStatus; } - @Override public boolean equals(Object o) { diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java index 1e4b479b32f..c1192247ba3 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java @@ -51,14 +51,18 @@ public class PetApiServiceImpl extends PetApiService { return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + /* + * comment out as the method (for testing) does not exit in the original swagger spec + * we'll uncomment this code block later if we update the petstore server @Override public Response getPetByIdInObject(Long petId,SecurityContext securityContext) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + */ @Override - public Response updatePetWithForm(String petId,String name,String status,SecurityContext securityContext) throws NotFoundException { + public Response updatePetWithForm(Long petId,String name,String status,SecurityContext securityContext) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } @@ -75,11 +79,15 @@ public class PetApiServiceImpl extends PetApiService { return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + /* + * comment out as the method (for testing) does not exit in the original swagger spec + * we'll uncomment this code block later if we update the petstore server @Override public Response petPetIdtestingByteArraytrueGet(Long petId,SecurityContext securityContext) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + */ } diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java index 0bb503589cb..b19e9003af5 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java @@ -26,11 +26,15 @@ public class StoreApiServiceImpl extends StoreApiService { return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + /* + * * comment out as the method (for testing) does not exit in the original swagger spec + * * we'll uncomment this code block later if we update the petstore server @Override public Response getInventoryInObject(SecurityContext securityContext) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + */ @Override public Response placeOrder(Order body,SecurityContext securityContext) throws NotFoundException { @@ -39,7 +43,7 @@ public class StoreApiServiceImpl extends StoreApiService { } @Override - public Response getOrderById(String orderId,SecurityContext securityContext) throws NotFoundException { + public Response getOrderById(Long orderId,SecurityContext securityContext) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } @@ -50,11 +54,15 @@ public class StoreApiServiceImpl extends StoreApiService { return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + /* + * * comment out as the method (for testing) does not exit in the original swagger spec + * * we'll uncomment this code block later if we update the petstore server @Override public Response findOrdersByStatus(String status, SecurityContext securityContext) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } + */ } diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java index 500451add3a..e439e48d212 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java @@ -62,8 +62,7 @@ public class PetApi { }) }, tags={ "pet", }) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = void.class), - @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = void.class) }) + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value", response = void.class) }) public Response deletePet( @ApiParam(value = "Pet id to delete",required=true) @PathParam("petId") Long petId, @ApiParam(value = "" )@HeaderParam("api_key") String apiKey, @@ -94,7 +93,7 @@ public class PetApi { @Path("/findByTags") @Produces({ "application/xml", "application/json" }) - @io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma separated strings. Use\ntag1, tag2, tag3 for testing.\n", response = Pet.class, responseContainer = "List", authorizations = { + @io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") @@ -150,7 +149,7 @@ public class PetApi { @Path("/{petId}") @Consumes({ "application/x-www-form-urlencoded" }) @Produces({ "application/xml", "application/json" }) - @io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "null", response = void.class, authorizations = { + @io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = void.class, authorizations = { @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java index 2aa3ab0cd34..7a2d8b60585 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java @@ -22,29 +22,20 @@ import javax.ws.rs.core.SecurityContext; public abstract class PetApiService { - public abstract Response addPet(Pet body,SecurityContext securityContext) throws NotFoundException; - public abstract Response deletePet(Long petId,String apiKey,SecurityContext securityContext) throws NotFoundException; - public abstract Response findPetsByStatus(List status,SecurityContext securityContext) throws NotFoundException; - public abstract Response findPetsByTags(List tags,SecurityContext securityContext) throws NotFoundException; - public abstract Response getPetById(Long petId,SecurityContext securityContext) throws NotFoundException; - public abstract Response updatePet(Pet body,SecurityContext securityContext) throws NotFoundException; - public abstract Response updatePetWithForm(Long petId,String name,String status,SecurityContext securityContext) throws NotFoundException; - public abstract Response uploadFile(Long petId,String additionalMetadata,InputStream inputStream, FormDataContentDisposition fileDetail,SecurityContext securityContext) throws NotFoundException; - } diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java index c9d9a17aec7..91c37506181 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java @@ -36,12 +36,12 @@ public class StoreApi { @Path("/order/{orderId}") @Produces({ "application/xml", "application/json" }) - @io.swagger.annotations.ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with positive integer value.\\ \\ Negative or non-integer values will generate API errors", response = void.class, tags={ "store", }) + @io.swagger.annotations.ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = void.class, tags={ "store", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = void.class), @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = void.class) }) public Response deleteOrder( - @ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathParam("orderId") Long orderId, + @ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathParam("orderId") String orderId, @Context SecurityContext securityContext) throws NotFoundException { return delegate.deleteOrder(orderId,securityContext); @@ -64,7 +64,7 @@ public class StoreApi { @Path("/order/{orderId}") @Produces({ "application/xml", "application/json" }) - @io.swagger.annotations.ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value >= 1 and <= 10.\nOther values will generated exceptions\n", response = Order.class, tags={ "store", }) + @io.swagger.annotations.ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class), diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java index 643a46d6596..c065b6c780c 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java @@ -21,17 +21,12 @@ import javax.ws.rs.core.SecurityContext; public abstract class StoreApiService { - - public abstract Response deleteOrder(Long orderId,SecurityContext securityContext) + public abstract Response deleteOrder(String orderId,SecurityContext securityContext) throws NotFoundException; - public abstract Response getInventory(SecurityContext securityContext) throws NotFoundException; - public abstract Response getOrderById(Long orderId,SecurityContext securityContext) throws NotFoundException; - public abstract Response placeOrder(Order body,SecurityContext securityContext) throws NotFoundException; - } diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java index 43728481866..5c53e751c4f 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java @@ -95,7 +95,7 @@ public class UserApi { @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = User.class), @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = User.class) }) public Response getUserByName( - @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathParam("username") String username, + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathParam("username") String username, @Context SecurityContext securityContext) throws NotFoundException { return delegate.getUserByName(username,securityContext); @@ -119,7 +119,7 @@ public class UserApi { @Path("/logout") @Produces({ "application/xml", "application/json" }) - @io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "null", response = void.class, tags={ "user", }) + @io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = void.class, tags={ "user", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) }) public Response logoutUser( @@ -136,7 +136,7 @@ public class UserApi { @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied", response = void.class), @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = void.class) }) public Response updateUser( - @ApiParam(value = "name that need to be updated",required=true) @PathParam("username") String username, + @ApiParam(value = "name that need to be deleted",required=true) @PathParam("username") String username, @ApiParam(value = "Updated user object" ,required=true) User body, @Context SecurityContext securityContext) throws NotFoundException { diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java index 334bfa1164b..f2f03f7c327 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java @@ -21,29 +21,20 @@ import javax.ws.rs.core.SecurityContext; public abstract class UserApiService { - public abstract Response createUser(User body,SecurityContext securityContext) throws NotFoundException; - public abstract Response createUsersWithArrayInput(List body,SecurityContext securityContext) throws NotFoundException; - public abstract Response createUsersWithListInput(List body,SecurityContext securityContext) throws NotFoundException; - public abstract Response deleteUser(String username,SecurityContext securityContext) throws NotFoundException; - public abstract Response getUserByName(String username,SecurityContext securityContext) throws NotFoundException; - public abstract Response loginUser(String username,String password,SecurityContext securityContext) throws NotFoundException; - public abstract Response logoutUser(SecurityContext securityContext) throws NotFoundException; - public abstract Response updateUser(String username,User body,SecurityContext securityContext) throws NotFoundException; - } diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/ApiResponse.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/ApiResponse.java index dd6bcbf2cb1..ac9fb970f82 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/ApiResponse.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/ApiResponse.java @@ -16,7 +16,6 @@ public class ApiResponse { private String type = null; private String message = null; - /** **/ public ApiResponse code(Integer code) { @@ -34,7 +33,6 @@ public class ApiResponse { this.code = code; } - /** **/ public ApiResponse type(String type) { @@ -52,7 +50,6 @@ public class ApiResponse { this.type = type; } - /** **/ public ApiResponse message(String message) { @@ -70,7 +67,6 @@ public class ApiResponse { this.message = message; } - @Override public boolean equals(Object o) { diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java index fd27ccac1c4..67bc75b3b10 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java @@ -15,7 +15,6 @@ public class Category { private Long id = null; private String name = null; - /** **/ public Category id(Long id) { @@ -33,7 +32,6 @@ public class Category { this.id = id; } - /** **/ public Category name(String name) { @@ -51,7 +49,6 @@ public class Category { this.name = name; } - @Override public boolean equals(Object o) { diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java index 0dd4222776c..825fa282b8b 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java @@ -41,7 +41,6 @@ public class Order { private StatusEnum status = null; private Boolean complete = false; - /** **/ public Order id(Long id) { @@ -59,7 +58,6 @@ public class Order { this.id = id; } - /** **/ public Order petId(Long petId) { @@ -77,7 +75,6 @@ public class Order { this.petId = petId; } - /** **/ public Order quantity(Integer quantity) { @@ -95,7 +92,6 @@ public class Order { this.quantity = quantity; } - /** **/ public Order shipDate(Date shipDate) { @@ -113,7 +109,6 @@ public class Order { this.shipDate = shipDate; } - /** * Order Status **/ @@ -132,7 +127,6 @@ public class Order { this.status = status; } - /** **/ public Order complete(Boolean complete) { @@ -150,7 +144,6 @@ public class Order { this.complete = complete; } - @Override public boolean equals(Object o) { diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java index 514bb24508d..24092cbee25 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java @@ -44,7 +44,6 @@ public class Pet { private StatusEnum status = null; - /** **/ public Pet id(Long id) { @@ -62,7 +61,6 @@ public class Pet { this.id = id; } - /** **/ public Pet category(Category category) { @@ -80,7 +78,6 @@ public class Pet { this.category = category; } - /** **/ public Pet name(String name) { @@ -98,7 +95,6 @@ public class Pet { this.name = name; } - /** **/ public Pet photoUrls(List photoUrls) { @@ -116,7 +112,6 @@ public class Pet { this.photoUrls = photoUrls; } - /** **/ public Pet tags(List tags) { @@ -134,7 +129,6 @@ public class Pet { this.tags = tags; } - /** * pet status in the store **/ @@ -153,7 +147,6 @@ public class Pet { this.status = status; } - @Override public boolean equals(Object o) { diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java index b46638ccb69..f26d84e74b2 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java @@ -15,7 +15,6 @@ public class Tag { private Long id = null; private String name = null; - /** **/ public Tag id(Long id) { @@ -33,7 +32,6 @@ public class Tag { this.id = id; } - /** **/ public Tag name(String name) { @@ -51,7 +49,6 @@ public class Tag { this.name = name; } - @Override public boolean equals(Object o) { diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java index 7f18c02f599..5dc291a7889 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java @@ -21,7 +21,6 @@ public class User { private String phone = null; private Integer userStatus = null; - /** **/ public User id(Long id) { @@ -39,7 +38,6 @@ public class User { this.id = id; } - /** **/ public User username(String username) { @@ -57,7 +55,6 @@ public class User { this.username = username; } - /** **/ public User firstName(String firstName) { @@ -75,7 +72,6 @@ public class User { this.firstName = firstName; } - /** **/ public User lastName(String lastName) { @@ -93,7 +89,6 @@ public class User { this.lastName = lastName; } - /** **/ public User email(String email) { @@ -111,7 +106,6 @@ public class User { this.email = email; } - /** **/ public User password(String password) { @@ -129,7 +123,6 @@ public class User { this.password = password; } - /** **/ public User phone(String phone) { @@ -147,7 +140,6 @@ public class User { this.phone = phone; } - /** * User Status **/ @@ -166,7 +158,6 @@ public class User { this.userStatus = userStatus; } - @Override public boolean equals(Object o) { diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/Bootstrap.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/Bootstrap.java index 0651af80f18..1f60ed6cf4b 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/Bootstrap.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/Bootstrap.java @@ -15,7 +15,7 @@ public class Bootstrap extends HttpServlet { public void init(ServletConfig config) throws ServletException { Info info = new Info() .title("Swagger Server") - .description("This is a sample server Petstore server. You can find out more about\nSwagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\nFor this sample, you can use the api key `special-key` to test the authorization filters.\n") + .description("This is a sample server Petstore server. You can find out more about 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.") .termsOfService("http://swagger.io/terms/") .contact(new Contact() .email("apiteam@swagger.io")) diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java index e54a128b242..d347d2b8f1f 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java @@ -23,7 +23,7 @@ import javax.ws.rs.core.SecurityContext; public class StoreApiServiceImpl extends StoreApiService { @Override - public Response deleteOrder(Long orderId, SecurityContext securityContext) + public Response deleteOrder(String orderId, SecurityContext securityContext) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); diff --git a/samples/server/petstore/nodejs/api/swagger.yaml b/samples/server/petstore/nodejs/api/swagger.yaml index 7f6eada7d8c..1aad0a1d4f4 100644 --- a/samples/server/petstore/nodejs/api/swagger.yaml +++ b/samples/server/petstore/nodejs/api/swagger.yaml @@ -1,23 +1,37 @@ --- swagger: "2.0" info: - description: "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.io)\ - \ or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample,\ - \ you can use the api key `special-key` to test the authorization filters\n" + description: "This is a sample server Petstore server. You can find out more about\ + \ 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/" contact: - name: "apiteam@swagger.io" + email: "apiteam@swagger.io" license: name: "Apache 2.0" 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: - /pets: + /pet: post: tags: - "pet" @@ -28,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: @@ -42,8 +56,8 @@ paths: description: "Invalid input" security: - petstore_auth: - - "write_pets" - - "read_pets" + - "write:pets" + - "read:pets" x-swagger-router-controller: "Pet" put: tags: @@ -55,13 +69,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: @@ -73,28 +87,33 @@ paths: description: "Validation exception" security: - petstore_auth: - - "write_pets" - - "read_pets" + - "write:pets" + - "read:pets" x-swagger-router-controller: "Pet" - /pets/findByStatus: + /pet/findByStatus: get: 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" + enum: + - "available" + - "pending" + - "sold" + collectionFormat: "csv" responses: 200: description: "successful operation" @@ -106,29 +125,29 @@ paths: description: "Invalid status value" security: - petstore_auth: - - "write_pets" - - "read_pets" + - "write:pets" + - "read:pets" x-swagger-router-controller: "Pet" - /pets/findByTags: + /pet/findByTags: get: 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" @@ -140,24 +159,23 @@ paths: description: "Invalid tag value" security: - petstore_auth: - - "write_pets" - - "read_pets" + - "write:pets" + - "read:pets" x-swagger-router-controller: "Pet" - /pets/{petId}: + /pet/{petId}: get: 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" @@ -172,9 +190,6 @@ paths: description: "Pet not found" security: - api_key: [] - - petstore_auth: - - "write_pets" - - "read_pets" x-swagger-router-controller: "Pet" post: tags: @@ -185,31 +200,32 @@ 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" - required: true + required: false type: "string" - name: "status" in: "formData" description: "Updated status of the pet" - required: true + required: false type: "string" responses: 405: description: "Invalid input" security: - petstore_auth: - - "write_pets" - - "read_pets" + - "write:pets" + - "read:pets" x-swagger-router-controller: "Pet" delete: tags: @@ -218,13 +234,12 @@ paths: description: "" operationId: "deletePet" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "api_key" in: "header" - description: "" - required: true + required: false type: "string" - name: "petId" in: "path" @@ -237,10 +252,69 @@ paths: description: "Invalid pet value" security: - petstore_auth: - - "write_pets" - - "read_pets" + - "write:pets" + - "read:pets" x-swagger-router-controller: "Pet" - /stores/order: + /pet/{petId}/uploadImage: + post: + tags: + - "pet" + summary: "uploads an image" + description: "" + operationId: "uploadFile" + consumes: + - "multipart/form-data" + produces: + - "application/json" + parameters: + - name: "petId" + in: "path" + description: "ID of pet to update" + required: true + type: "integer" + format: "int64" + - name: "additionalMetadata" + in: "formData" + description: "Additional data to pass to server" + required: false + type: "string" + - name: "file" + in: "formData" + description: "file to upload" + required: false + type: "file" + responses: + 200: + description: "successful operation" + schema: + $ref: "#/definitions/ApiResponse" + security: + - petstore_auth: + - "write:pets" + - "read:pets" + x-swagger-router-controller: "Pet" + /store/inventory: + get: + tags: + - "store" + summary: "Returns pet inventories by status" + description: "Returns a map of status codes to quantities" + operationId: "getInventory" + produces: + - "application/json" + parameters: [] + responses: + 200: + description: "successful operation" + schema: + type: "object" + additionalProperties: + type: "integer" + format: "int32" + security: + - api_key: [] + x-swagger-router-controller: "Store" + /store/order: post: tags: - "store" @@ -248,13 +322,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: @@ -265,7 +339,7 @@ paths: 400: description: "Invalid Order" x-swagger-router-controller: "Store" - /stores/order/{orderId}: + /store/order/{orderId}: get: tags: - "store" @@ -274,14 +348,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 + minimum: 1 + format: "int64" responses: 200: description: "successful operation" @@ -300,21 +377,22 @@ 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 responses: 400: description: "Invalid ID supplied" 404: description: "Order not found" x-swagger-router-controller: "Store" - /users: + /user: post: tags: - "user" @@ -322,20 +400,20 @@ 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: default: description: "successful operation" x-swagger-router-controller: "User" - /users/createWithArray: + /user/createWithArray: post: tags: - "user" @@ -343,13 +421,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: @@ -358,7 +436,7 @@ paths: default: description: "successful operation" x-swagger-router-controller: "User" - /users/createWithList: + /user/createWithList: post: tags: - "user" @@ -366,13 +444,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: @@ -381,7 +459,7 @@ paths: default: description: "successful operation" x-swagger-router-controller: "User" - /users/login: + /user/login: get: tags: - "user" @@ -389,28 +467,37 @@ 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-swagger-router-controller: "User" - /users/logout: + /user/logout: get: tags: - "user" @@ -418,14 +505,14 @@ paths: description: "" operationId: "logoutUser" produces: - - "application/json" - "application/xml" + - "application/json" parameters: [] responses: default: description: "successful operation" x-swagger-router-controller: "User" - /users/{username}: + /user/{username}: get: tags: - "user" @@ -433,12 +520,12 @@ paths: description: "" operationId: "getUserByName" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "username" in: "path" - description: "The name that needs to be fetched. Use user1 for testing." + description: "The name that needs to be fetched. Use user1 for testing. " required: true type: "string" responses: @@ -458,8 +545,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" @@ -469,7 +556,7 @@ paths: - in: "body" name: "body" description: "Updated user object" - required: false + required: true schema: $ref: "#/definitions/User" responses: @@ -485,8 +572,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" @@ -509,9 +596,46 @@ securityDefinitions: authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog" flow: "implicit" scopes: - write_pets: "modify pets in your account" - read_pets: "read your pets" + 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: @@ -534,7 +658,9 @@ definitions: type: "integer" format: "int32" description: "User Status" - Category: + xml: + name: "User" + Tag: type: "object" properties: id: @@ -542,6 +668,8 @@ definitions: format: "int64" name: type: "string" + xml: + name: "Tag" Pet: type: "object" required: @@ -558,40 +686,37 @@ definitions: example: "doggie" photoUrls: type: "array" + xml: + name: "photoUrl" + wrapped: true items: type: "string" tags: type: "array" + xml: + name: "tag" + wrapped: true items: $ref: "#/definitions/Tag" status: type: "string" description: "pet status in the store" - Tag: + enum: + - "available" + - "pending" + - "sold" + xml: + name: "Pet" + ApiResponse: type: "object" properties: - id: - type: "integer" - format: "int64" - name: - type: "string" - Order: - type: "object" - 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" - complete: - type: "boolean" +externalDocs: + description: "Find out more about Swagger" + url: "http://swagger.io" diff --git a/samples/server/petstore/nodejs/controllers/Pet.js b/samples/server/petstore/nodejs/controllers/Pet.js index a7d196faa7c..3748305bfbe 100644 --- a/samples/server/petstore/nodejs/controllers/Pet.js +++ b/samples/server/petstore/nodejs/controllers/Pet.js @@ -33,3 +33,7 @@ module.exports.updatePet = function updatePet (req, res, next) { module.exports.updatePetWithForm = function updatePetWithForm (req, res, next) { Pet.updatePetWithForm(req.swagger.params, res, next); }; + +module.exports.uploadFile = function uploadFile (req, res, next) { + Pet.uploadFile(req.swagger.params, res, next); +}; diff --git a/samples/server/petstore/nodejs/controllers/PetService.js b/samples/server/petstore/nodejs/controllers/PetService.js index 29a51e31a2b..95f42f6a038 100644 --- a/samples/server/petstore/nodejs/controllers/PetService.js +++ b/samples/server/petstore/nodejs/controllers/PetService.js @@ -12,8 +12,8 @@ exports.addPet = function(args, res, next) { exports.deletePet = function(args, res, next) { /** * parameters expected in the args: - * apiKey (String) * petId (Long) + * apiKey (String) **/ // no response value expected for this operation res.end(); @@ -121,7 +121,7 @@ exports.updatePet = function(args, res, next) { exports.updatePetWithForm = function(args, res, next) { /** * parameters expected in the args: - * petId (String) + * petId (Long) * name (String) * status (String) **/ @@ -129,3 +129,26 @@ exports.updatePetWithForm = function(args, res, next) { res.end(); } +exports.uploadFile = function(args, res, next) { + /** + * parameters expected in the args: + * petId (Long) + * additionalMetadata (String) + * file (file) + **/ + var examples = {}; + examples['application/json'] = { + "message" : "aeiou", + "code" : 123, + "type" : "aeiou" +}; + if(Object.keys(examples).length > 0) { + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); + } + else { + res.end(); + } + +} + diff --git a/samples/server/petstore/nodejs/controllers/Store.js b/samples/server/petstore/nodejs/controllers/Store.js index 95fcb02711e..ac67c740d29 100644 --- a/samples/server/petstore/nodejs/controllers/Store.js +++ b/samples/server/petstore/nodejs/controllers/Store.js @@ -10,6 +10,10 @@ module.exports.deleteOrder = function deleteOrder (req, res, next) { Store.deleteOrder(req.swagger.params, res, next); }; +module.exports.getInventory = function getInventory (req, res, next) { + Store.getInventory(req.swagger.params, res, next); +}; + module.exports.getOrderById = function getOrderById (req, res, next) { Store.getOrderById(req.swagger.params, res, next); }; diff --git a/samples/server/petstore/nodejs/controllers/StoreService.js b/samples/server/petstore/nodejs/controllers/StoreService.js index 6ee8ff36f94..01759173bd4 100644 --- a/samples/server/petstore/nodejs/controllers/StoreService.js +++ b/samples/server/petstore/nodejs/controllers/StoreService.js @@ -9,10 +9,28 @@ exports.deleteOrder = function(args, res, next) { res.end(); } +exports.getInventory = function(args, res, next) { + /** + * parameters expected in the args: + **/ + var examples = {}; + examples['application/json'] = { + "key" : 123 +}; + if(Object.keys(examples).length > 0) { + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); + } + else { + res.end(); + } + +} + exports.getOrderById = function(args, res, next) { /** * parameters expected in the args: - * orderId (String) + * orderId (Long) **/ var examples = {}; examples['application/json'] = { diff --git a/samples/server/petstore/nodejs/package.json b/samples/server/petstore/nodejs/package.json index 2ebddec5e2e..293316dac0e 100644 --- a/samples/server/petstore/nodejs/package.json +++ b/samples/server/petstore/nodejs/package.json @@ -1,7 +1,7 @@ { "name": "swagger-petstore", "version": "1.0.0", - "description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.io) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n", + "description": "This is a sample server Petstore server. You can find out more about 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.", "main": "index.js", "keywords": [ "swagger" diff --git a/samples/server/petstore/scalatra/README.md b/samples/server/petstore/scalatra/README.md index 3ffa01fb257..327870827fd 100644 --- a/samples/server/petstore/scalatra/README.md +++ b/samples/server/petstore/scalatra/README.md @@ -2,7 +2,7 @@ ## Overview This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the -[swagger-spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This +[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This is an example of building a swagger-enabled scalatra server. This example uses the [scalatra](http://scalatra.org/) framework. To see how to make this your own, look here: diff --git a/samples/server/petstore/scalatra/src/main/scala/ScalatraBootstrap.scala b/samples/server/petstore/scalatra/src/main/scala/ScalatraBootstrap.scala index 1129a77d3c8..9dceb9fc302 100644 --- a/samples/server/petstore/scalatra/src/main/scala/ScalatraBootstrap.scala +++ b/samples/server/petstore/scalatra/src/main/scala/ScalatraBootstrap.scala @@ -1,6 +1,6 @@ import com.wordnik.client.api._ import akka.actor.ActorSystem -import io.swagger.app.{ResourcesApp, SwaggerApp} +import io.swagger.app.{ ResourcesApp, SwaggerApp } import javax.servlet.ServletContext import org.scalatra.LifeCycle @@ -10,10 +10,10 @@ class ScalatraBootstrap extends LifeCycle { override def init(context: ServletContext) { implicit val system = ActorSystem("appActorSystem") try { - context mount (new UserApi, "/User/*") context mount (new PetApi, "/Pet/*") context mount (new StoreApi, "/Store/*") - + context mount (new UserApi, "/User/*") + context mount (new ResourcesApp, "/api-docs/*") } catch { case e: Throwable => e.printStackTrace() diff --git a/samples/server/petstore/scalatra/src/main/scala/ServletApp.scala b/samples/server/petstore/scalatra/src/main/scala/ServletApp.scala index 6631eb98cc1..e5063473ebe 100644 --- a/samples/server/petstore/scalatra/src/main/scala/ServletApp.scala +++ b/samples/server/petstore/scalatra/src/main/scala/ServletApp.scala @@ -3,26 +3,26 @@ package io.swagger.app import _root_.akka.actor.ActorSystem import org.scalatra.swagger.{ ApiInfo, SwaggerWithAuth, Swagger } -import org.scalatra.swagger.{JacksonSwaggerBase, Swagger} +import org.scalatra.swagger.{ JacksonSwaggerBase, Swagger } import org.scalatra.ScalatraServlet -import org.json4s.{DefaultFormats, Formats} +import org.json4s.{ DefaultFormats, Formats } class ResourcesApp(implicit protected val system: ActorSystem, val swagger: SwaggerApp) - extends ScalatraServlet with JacksonSwaggerBase { + extends ScalatraServlet with JacksonSwaggerBase { before() { response.headers += ("Access-Control-Allow-Origin" -> "*") } protected def buildFullUrl(path: String) = if (path.startsWith("http")) path else { - val port = request.getServerPort - val h = request.getServerName - val prot = if (port == 443) "https" else "http" - val (proto, host) = if (port != 80 && port != 443) ("http", h+":"+port.toString) else (prot, h) - "%s://%s%s%s".format( - proto, - host, - request.getContextPath, - path) + val port = request.getServerPort + val h = request.getServerName + val prot = if (port == 443) "https" else "http" + val (proto, host) = if (port != 80 && port != 443) ("http", h + ":" + port.toString) else (prot, h) + "%s://%s%s%s".format( + proto, + host, + request.getContextPath, + path) } } @@ -31,7 +31,7 @@ class SwaggerApp extends Swagger(apiInfo = ApiSwagger.apiInfo, apiVersion = "1.0 object ApiSwagger { val apiInfo = ApiInfo( """Swagger Petstore""", - """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""", + """This is a sample server Petstore server. You can find out more about 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.""", """""", """apiteam@swagger.io""", """Apache 2.0""", diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/PetApi.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/PetApi.scala index 7e0a438db1e..58984f1783c 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/PetApi.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/PetApi.scala @@ -1,6 +1,7 @@ package com.wordnik.client.api import com.wordnik.client.model.Pet +import com.wordnik.client.model.ApiResponse import java.io.File import java.io.File @@ -29,156 +30,16 @@ class PetApi (implicit val swagger: Swagger) extends ScalatraServlet } - val updatePetOperation = (apiOperation[Unit]("updatePet") - summary "Update an existing pet" - parameters(bodyParam[Pet]("body").description("").optional) - ) - - put("/pet",operation(updatePetOperation)) { - - - - -bodyParam[Pet]("body").description("").optional - - println("body: " + body) - - } - - - val addPetOperation = (apiOperation[Unit]("addPet") summary "Add a new pet to the store" - parameters(bodyParam[Pet]("body").description("").optional) + parameters(bodyParam[Pet]("body").description("")) ) post("/pet",operation(addPetOperation)) { - - -bodyParam[Pet]("body").description("").optional - + bodyParam[Pet]("body").description("") println("body: " + body) - - } - - - - val findPetsByStatusOperation = (apiOperation[List[Pet]]("findPetsByStatus") - summary "Finds Pets by status" - parameters(queryParam[List[String]]("status").description("").optional.defaultValue(available)) - ) - - get("/pet/findByStatus",operation(findPetsByStatusOperation)) { - - - - - val statusString = params.getAs[String]("status") - val status = if("multi".equals("default")) { - statusString match { - case Some(str) => str.split(",") - case None => List() - } - } - else - List() - - - - - - println("status: " + status) - - } - - - - val findPetsByTagsOperation = (apiOperation[List[Pet]]("findPetsByTags") - summary "Finds Pets by tags" - parameters(queryParam[List[String]]("tags").description("").optional) - ) - - get("/pet/findByTags",operation(findPetsByTagsOperation)) { - - - - - val tagsString = params.getAs[String]("tags") - val tags = if("multi".equals("default")) { - tagsString match { - case Some(str) => str.split(",") - case None => List() - } - } - else - List() - - - - - - println("tags: " + tags) - - } - - - - val getPetByIdOperation = (apiOperation[Pet]("getPetById") - summary "Find pet by ID" - parameters(pathParam[Long]("petId").description("")) - ) - - get("/pet/{petId}",operation(getPetByIdOperation)) { - - - - val petId = params.getOrElse("petId", halt(400)) - - - - println("petId: " + petId) - - } - - - - val updatePetWithFormOperation = (apiOperation[Unit]("updatePetWithForm") - summary "Updates a pet in the store with form data" - parameters(pathParam[String]("petId").description(""), - formParam[String]("name").description("").optional, - formParam[String]("status").description("").optional) - ) - - post("/pet/{petId}",operation(updatePetWithFormOperation)) { - - - - val petId = params.getOrElse("petId", halt(400)) - - - - println("petId: " + petId) - - - - - val name = params.getAs[String]("name") - - - - println("name: " + name) - - - - - val status = params.getAs[String]("status") - - - - println("status: " + status) - } @@ -192,27 +53,123 @@ bodyParam[Pet]("body").description("").optional delete("/pet/{petId}",operation(deletePetOperation)) { - val petId = params.getOrElse("petId", halt(400)) - - println("petId: " + petId) - - - val apiKey = request.getHeader("apiKey") - + val apiKey = request.getHeader("apiKey") - println("apiKey: " + apiKey) - } - val uploadFileOperation = (apiOperation[Unit]("uploadFile") + val findPetsByStatusOperation = (apiOperation[List[Pet]]("findPetsByStatus") + summary "Finds Pets by status" + parameters(queryParam[List[String]]("status").description("")) + ) + + get("/pet/findByStatus",operation(findPetsByStatusOperation)) { + + + val statusString = params.getAs[String]("status") + val status = if("csv".equals("default")) { + statusString match { + case Some(str) => str.split(",") + case None => List() + } + } + else + List() + + + println("status: " + status) + } + + + + val findPetsByTagsOperation = (apiOperation[List[Pet]]("findPetsByTags") + summary "Finds Pets by tags" + parameters(queryParam[List[String]]("tags").description("")) + ) + + get("/pet/findByTags",operation(findPetsByTagsOperation)) { + + + val tagsString = params.getAs[String]("tags") + val tags = if("csv".equals("default")) { + tagsString match { + case Some(str) => str.split(",") + case None => List() + } + } + else + List() + + + println("tags: " + tags) + } + + + + val getPetByIdOperation = (apiOperation[Pet]("getPetById") + summary "Find pet by ID" + parameters(pathParam[Long]("petId").description("")) + ) + + get("/pet/{petId}",operation(getPetByIdOperation)) { + + + val petId = params.getOrElse("petId", halt(400)) + + println("petId: " + petId) + } + + + + val updatePetOperation = (apiOperation[Unit]("updatePet") + summary "Update an existing pet" + parameters(bodyParam[Pet]("body").description("")) + ) + + put("/pet",operation(updatePetOperation)) { + + + bodyParam[Pet]("body").description("") + println("body: " + body) + } + + + + val updatePetWithFormOperation = (apiOperation[Unit]("updatePetWithForm") + summary "Updates a pet in the store with form data" + parameters(pathParam[Long]("petId").description(""), + formParam[String]("name").description("").optional, + formParam[String]("status").description("").optional) + ) + + post("/pet/{petId}",operation(updatePetWithFormOperation)) { + + + val petId = params.getOrElse("petId", halt(400)) + + println("petId: " + petId) + + + val name = params.getAs[String]("name") + + println("name: " + name) + + + val status = params.getAs[String]("status") + + println("status: " + status) + } + + + + val uploadFileOperation = (apiOperation[ApiResponse]("uploadFile") summary "uploads an image" parameters(pathParam[Long]("petId").description(""), formParam[String]("additionalMetadata").description("").optional, @@ -222,26 +179,16 @@ bodyParam[Pet]("body").description("").optional post("/pet/{petId}/uploadImage",operation(uploadFileOperation)) { - val petId = params.getOrElse("petId", halt(400)) - - println("petId: " + petId) - - - val additionalMetadata = params.getAs[String]("additionalMetadata") - + val additionalMetadata = params.getAs[String]("additionalMetadata") - println("additionalMetadata: " + additionalMetadata) - val file = fileParams("file") - - println("file: " + file) - + println("file: " + file) } } \ No newline at end of file diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/StoreApi.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/StoreApi.scala index 27fbc08e2c2..934eb329fca 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/StoreApi.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/StoreApi.scala @@ -9,11 +9,11 @@ import org.scalatra.swagger._ import org.json4s._ import org.json4s.JsonDSL._ import org.scalatra.json.{ JValueResult, JacksonJsonSupport } -import org.scalatra.servlet.{FileUploadSupport, MultipartConfig, SizeConstraintExceededException} +import org.scalatra.servlet.{ FileUploadSupport, MultipartConfig, SizeConstraintExceededException } import scala.collection.JavaConverters._ -class StoreApi (implicit val swagger: Swagger) extends ScalatraServlet +class StoreApi(implicit val swagger: Swagger) extends ScalatraServlet with FileUploadSupport with JacksonJsonSupport with SwaggerSupport { @@ -26,71 +26,48 @@ class StoreApi (implicit val swagger: Swagger) extends ScalatraServlet contentType = formats("json") response.headers += ("Access-Control-Allow-Origin" -> "*") } - - - val getInventoryOperation = (apiOperation[Map[String, Int]]("getInventory") - summary "Returns pet inventories by status" - parameters() - ) - - get("/store/inventory",operation(getInventoryOperation)) { - - } - - - - val placeOrderOperation = (apiOperation[Order]("placeOrder") - summary "Place an order for a pet" - parameters(bodyParam[Order]("body").description("").optional) - ) - - post("/store/order",operation(placeOrderOperation)) { - - - - -bodyParam[Order]("body").description("").optional - - println("body: " + body) - - } - - - - val getOrderByIdOperation = (apiOperation[Order]("getOrderById") - summary "Find purchase order by ID" - parameters(pathParam[String]("orderId").description("")) - ) - - get("/store/order/{orderId}",operation(getOrderByIdOperation)) { - - - - val orderId = params.getOrElse("orderId", halt(400)) - - - - println("orderId: " + orderId) - - } - - val deleteOrderOperation = (apiOperation[Unit]("deleteOrder") - summary "Delete purchase order by ID" - parameters(pathParam[String]("orderId").description("")) + summary "Delete purchase order by ID" + parameters (pathParam[String]("orderId").description("")) ) - delete("/store/order/{orderId}",operation(deleteOrderOperation)) { - - - - val orderId = params.getOrElse("orderId", halt(400)) - + delete("/store/order/{orderId}", operation(deleteOrderOperation)) { + + val orderId = params.getOrElse("orderId", halt(400)) - println("orderId: " + orderId) - + } + + val getInventoryOperation = (apiOperation[Map[String, Int]]("getInventory") + summary "Returns pet inventories by status" + parameters () + ) + + get("/store/inventory", operation(getInventoryOperation)) { + } + + val getOrderByIdOperation = (apiOperation[Order]("getOrderById") + summary "Find purchase order by ID" + parameters (pathParam[Long]("orderId").description("")) + ) + + get("/store/order/{orderId}", operation(getOrderByIdOperation)) { + + val orderId = params.getOrElse("orderId", halt(400)) + + println("orderId: " + orderId) + } + + val placeOrderOperation = (apiOperation[Order]("placeOrder") + summary "Place an order for a pet" + parameters (bodyParam[Order]("body").description("")) + ) + + post("/store/order", operation(placeOrderOperation)) { + + bodyParam[Order]("body").description("") + println("body: " + body) } } \ No newline at end of file diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/UserApi.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/UserApi.scala index c63151a8d38..0d5bc6c276b 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/UserApi.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/UserApi.scala @@ -9,11 +9,11 @@ import org.scalatra.swagger._ import org.json4s._ import org.json4s.JsonDSL._ import org.scalatra.json.{ JValueResult, JacksonJsonSupport } -import org.scalatra.servlet.{FileUploadSupport, MultipartConfig, SizeConstraintExceededException} +import org.scalatra.servlet.{ FileUploadSupport, MultipartConfig, SizeConstraintExceededException } import scala.collection.JavaConverters._ -class UserApi (implicit val swagger: Swagger) extends ScalatraServlet +class UserApi(implicit val swagger: Swagger) extends ScalatraServlet with FileUploadSupport with JacksonJsonSupport with SwaggerSupport { @@ -26,166 +26,103 @@ class UserApi (implicit val swagger: Swagger) extends ScalatraServlet contentType = formats("json") response.headers += ("Access-Control-Allow-Origin" -> "*") } - val createUserOperation = (apiOperation[Unit]("createUser") - summary "Create user" - parameters(bodyParam[User]("body").description("").optional) + summary "Create user" + parameters (bodyParam[User]("body").description("")) ) - post("/user",operation(createUserOperation)) { - - - - -bodyParam[User]("body").description("").optional - - println("body: " + body) - - } + post("/user", operation(createUserOperation)) { - + bodyParam[User]("body").description("") + println("body: " + body) + } val createUsersWithArrayInputOperation = (apiOperation[Unit]("createUsersWithArrayInput") - summary "Creates list of users with given input array" - parameters(bodyParam[List[User]]("body").description("").optional) + summary "Creates list of users with given input array" + parameters (bodyParam[List[User]]("body").description("")) ) - post("/user/createWithArray",operation(createUsersWithArrayInputOperation)) { - - - - -bodyParam[List[User]]("body").description("").optional - - println("body: " + body) - - } + post("/user/createWithArray", operation(createUsersWithArrayInputOperation)) { - + bodyParam[List[User]]("body").description("") + println("body: " + body) + } val createUsersWithListInputOperation = (apiOperation[Unit]("createUsersWithListInput") - summary "Creates list of users with given input array" - parameters(bodyParam[List[User]]("body").description("").optional) + summary "Creates list of users with given input array" + parameters (bodyParam[List[User]]("body").description("")) ) - post("/user/createWithList",operation(createUsersWithListInputOperation)) { - - - - -bodyParam[List[User]]("body").description("").optional - + post("/user/createWithList", operation(createUsersWithListInputOperation)) { + + bodyParam[List[User]]("body").description("") println("body: " + body) - } - - - val loginUserOperation = (apiOperation[String]("loginUser") - summary "Logs user into the system" - parameters(queryParam[String]("username").description("").optional, - queryParam[String]("password").description("").optional) - ) - - get("/user/login",operation(loginUserOperation)) { - - - - - - val username = params.getAs[String]("username") - - - - println("username: " + username) - - - - - - val password = params.getAs[String]("password") - - - - println("password: " + password) - - } - - - - val logoutUserOperation = (apiOperation[Unit]("logoutUser") - summary "Logs out current logged in user session" - parameters() - ) - - get("/user/logout",operation(logoutUserOperation)) { - - } - - - - val getUserByNameOperation = (apiOperation[User]("getUserByName") - summary "Get user by user name" - parameters(pathParam[String]("username").description("")) - ) - - get("/user/{username}",operation(getUserByNameOperation)) { - - - - val username = params.getOrElse("username", halt(400)) - - - - println("username: " + username) - - } - - - - val updateUserOperation = (apiOperation[Unit]("updateUser") - summary "Updated user" - parameters(pathParam[String]("username").description(""), - bodyParam[User]("body").description("").optional) - ) - - put("/user/{username}",operation(updateUserOperation)) { - - - - val username = params.getOrElse("username", halt(400)) - - - - println("username: " + username) - - - - -bodyParam[User]("body").description("").optional - - println("body: " + body) - - } - - - val deleteUserOperation = (apiOperation[Unit]("deleteUser") - summary "Delete user" - parameters(pathParam[String]("username").description("")) + summary "Delete user" + parameters (pathParam[String]("username").description("")) ) - delete("/user/{username}",operation(deleteUserOperation)) { - - - - val username = params.getOrElse("username", halt(400)) - + delete("/user/{username}", operation(deleteUserOperation)) { + + val username = params.getOrElse("username", halt(400)) - println("username: " + username) - + } + + val getUserByNameOperation = (apiOperation[User]("getUserByName") + summary "Get user by user name" + parameters (pathParam[String]("username").description("")) + ) + + get("/user/{username}", operation(getUserByNameOperation)) { + + val username = params.getOrElse("username", halt(400)) + + println("username: " + username) + } + + val loginUserOperation = (apiOperation[String]("loginUser") + summary "Logs user into the system" + parameters (queryParam[String]("username").description(""), + queryParam[String]("password").description("")) + ) + + get("/user/login", operation(loginUserOperation)) { + + val username = params.getAs[String]("username") + + println("username: " + username) + + val password = params.getAs[String]("password") + + println("password: " + password) + } + + val logoutUserOperation = (apiOperation[Unit]("logoutUser") + summary "Logs out current logged in user session" + parameters () + ) + + get("/user/logout", operation(logoutUserOperation)) { + } + + val updateUserOperation = (apiOperation[Unit]("updateUser") + summary "Updated user" + parameters (pathParam[String]("username").description(""), + bodyParam[User]("body").description("")) + ) + + put("/user/{username}", operation(updateUserOperation)) { + + val username = params.getOrElse("username", halt(400)) + + println("username: " + username) + + bodyParam[User]("body").description("") + println("body: " + body) } } \ No newline at end of file diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Category.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Category.scala index d4ee7a692e6..bb77cbc1771 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Category.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Category.scala @@ -1,8 +1,5 @@ package com.wordnik.client.model - - -case class Category ( - id: Long, - name: String -) +case class Category( + id: Option[Long], + name: Option[String]) diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Order.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Order.scala index 918cf132d2c..763803bc4b9 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Order.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Order.scala @@ -2,12 +2,10 @@ package com.wordnik.client.model import java.util.Date - -case class Order ( - id: Long, - petId: Long, - quantity: Int, - shipDate: Date, - status: String, - complete: Boolean -) +case class Order( + id: Option[Long], + petId: Option[Long], + quantity: Option[Int], + shipDate: Option[Date], + status: Option[String], // Order Status + complete: Option[Boolean]) diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Pet.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Pet.scala index cea17dedae7..0f8fdddfed2 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Pet.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Pet.scala @@ -3,12 +3,11 @@ package com.wordnik.client.model import com.wordnik.client.model.Category import com.wordnik.client.model.Tag - -case class Pet ( - id: Long, - category: Category, +case class Pet( + id: Option[Long], + category: Option[Category], name: String, photoUrls: List[String], - tags: List[Tag], - status: String -) + tags: Option[List[Tag]], + status: Option[String] // pet status in the store + ) diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Tag.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Tag.scala index bd28dd4d44d..0e803adca38 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Tag.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Tag.scala @@ -1,8 +1,5 @@ package com.wordnik.client.model - - -case class Tag ( - id: Long, - name: String -) +case class Tag( + id: Option[Long], + name: Option[String]) diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/User.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/User.scala index acadf78f7a1..77b7ec5d70c 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/User.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/User.scala @@ -1,14 +1,12 @@ package com.wordnik.client.model - - -case class User ( - id: Long, - username: String, - firstName: String, - lastName: String, - email: String, - password: String, - phone: String, - userStatus: Int -) +case class User( + id: Option[Long], + username: Option[String], + firstName: Option[String], + lastName: Option[String], + email: Option[String], + password: Option[String], + phone: Option[String], + userStatus: Option[Int] // User Status + ) diff --git a/samples/server/petstore/silex/SwaggerServer/index.php b/samples/server/petstore/silex/SwaggerServer/index.php index 450b8e74967..aba755a883a 100644 --- a/samples/server/petstore/silex/SwaggerServer/index.php +++ b/samples/server/petstore/silex/SwaggerServer/index.php @@ -7,85 +7,6 @@ use Silex\Application; $app = new Silex\Application(); - - - - -$app->POST('/user', function(Application $app, Request $request) { - - - return new Response('How about implementing createUser as a POST method ?'); - }); - - - -$app->POST('/user/createWithArray', function(Application $app, Request $request) { - - - return new Response('How about implementing createUsersWithArrayInput as a POST method ?'); - }); - - - -$app->POST('/user/createWithList', function(Application $app, Request $request) { - - - return new Response('How about implementing createUsersWithListInput as a POST method ?'); - }); - - - -$app->GET('/user/login', function(Application $app, Request $request) { - $username = $request->get('username'); $password = $request->get('password'); - - return new Response('How about implementing loginUser as a GET method ?'); - }); - - - -$app->GET('/user/logout', function(Application $app, Request $request) { - - - return new Response('How about implementing logoutUser as a GET method ?'); - }); - - - -$app->GET('/user/{username}', function(Application $app, Request $request, $username) { - - - return new Response('How about implementing getUserByName as a GET method ?'); - }); - - - -$app->PUT('/user/{username}', function(Application $app, Request $request, $username) { - - - return new Response('How about implementing updateUser as a PUT method ?'); - }); - - - -$app->DELETE('/user/{username}', function(Application $app, Request $request, $username) { - - - return new Response('How about implementing deleteUser as a DELETE method ?'); - }); - - - - - - - -$app->PUT('/pet', function(Application $app, Request $request) { - - - return new Response('How about implementing updatePet as a PUT method ?'); - }); - - $app->POST('/pet', function(Application $app, Request $request) { @@ -93,39 +14,6 @@ $app->POST('/pet', function(Application $app, Request $request) { return new Response('How about implementing addPet as a POST method ?'); }); - - -$app->GET('/pet/findByStatus', function(Application $app, Request $request) { - $status = $request->get('status'); - - return new Response('How about implementing findPetsByStatus as a GET method ?'); - }); - - - -$app->GET('/pet/findByTags', function(Application $app, Request $request) { - $tags = $request->get('tags'); - - return new Response('How about implementing findPetsByTags as a GET method ?'); - }); - - - -$app->GET('/pet/{petId}', function(Application $app, Request $request, $pet_id) { - - - return new Response('How about implementing getPetById as a GET method ?'); - }); - - - -$app->POST('/pet/{petId}', function(Application $app, Request $request, $pet_id) { - - $name = $request->get('name'); $status = $request->get('status'); - return new Response('How about implementing updatePetWithForm as a POST method ?'); - }); - - $app->DELETE('/pet/{petId}', function(Application $app, Request $request, $pet_id) { @@ -133,7 +21,41 @@ $app->DELETE('/pet/{petId}', function(Application $app, Request $request, $pet_i return new Response('How about implementing deletePet as a DELETE method ?'); }); + +$app->GET('/pet/findByStatus', function(Application $app, Request $request) { + $status = $request->get('status'); + return new Response('How about implementing findPetsByStatus as a GET method ?'); + }); + + +$app->GET('/pet/findByTags', function(Application $app, Request $request) { + $tags = $request->get('tags'); + + return new Response('How about implementing findPetsByTags as a GET method ?'); + }); + + +$app->GET('/pet/{petId}', function(Application $app, Request $request, $pet_id) { + + + return new Response('How about implementing getPetById as a GET method ?'); + }); + + +$app->PUT('/pet', function(Application $app, Request $request) { + + + return new Response('How about implementing updatePet as a PUT method ?'); + }); + + +$app->POST('/pet/{petId}', function(Application $app, Request $request, $pet_id) { + + $name = $request->get('name'); $status = $request->get('status'); + return new Response('How about implementing updatePetWithForm as a POST method ?'); + }); + $app->POST('/pet/{petId}/uploadImage', function(Application $app, Request $request, $pet_id) { @@ -141,51 +63,6 @@ $app->POST('/pet/{petId}/uploadImage', function(Application $app, Request $reque return new Response('How about implementing uploadFile as a POST method ?'); }); - - -$app->GET('/pet/{petId}?testing_byte_array=true', function(Application $app, Request $request, $pet_id) { - - - return new Response('How about implementing getPetByIdWithByteArray as a GET method ?'); - }); - - - -$app->POST('/pet?testing_byte_array=true', function(Application $app, Request $request) { - - - return new Response('How about implementing addPetUsingByteArray as a POST method ?'); - }); - - - - - - - -$app->GET('/store/inventory', function(Application $app, Request $request) { - - - return new Response('How about implementing getInventory as a GET method ?'); - }); - - - -$app->POST('/store/order', function(Application $app, Request $request) { - - - return new Response('How about implementing placeOrder as a POST method ?'); - }); - - - -$app->GET('/store/order/{orderId}', function(Application $app, Request $request, $order_id) { - - - return new Response('How about implementing getOrderById as a GET method ?'); - }); - - $app->DELETE('/store/order/{orderId}', function(Application $app, Request $request, $order_id) { @@ -193,8 +70,82 @@ $app->DELETE('/store/order/{orderId}', function(Application $app, Request $reque return new Response('How about implementing deleteOrder as a DELETE method ?'); }); + +$app->GET('/store/inventory', function(Application $app, Request $request) { - - + + return new Response('How about implementing getInventory as a GET method ?'); + }); + + +$app->GET('/store/order/{orderId}', function(Application $app, Request $request, $order_id) { + + + return new Response('How about implementing getOrderById as a GET method ?'); + }); + + +$app->POST('/store/order', function(Application $app, Request $request) { + + + return new Response('How about implementing placeOrder as a POST method ?'); + }); + + +$app->POST('/user', function(Application $app, Request $request) { + + + return new Response('How about implementing createUser as a POST method ?'); + }); + + +$app->POST('/user/createWithArray', function(Application $app, Request $request) { + + + return new Response('How about implementing createUsersWithArrayInput as a POST method ?'); + }); + + +$app->POST('/user/createWithList', function(Application $app, Request $request) { + + + return new Response('How about implementing createUsersWithListInput as a POST method ?'); + }); + + +$app->DELETE('/user/{username}', function(Application $app, Request $request, $username) { + + + return new Response('How about implementing deleteUser as a DELETE method ?'); + }); + + +$app->GET('/user/{username}', function(Application $app, Request $request, $username) { + + + return new Response('How about implementing getUserByName as a GET method ?'); + }); + + +$app->GET('/user/login', function(Application $app, Request $request) { + $username = $request->get('username'); $password = $request->get('password'); + + return new Response('How about implementing loginUser as a GET method ?'); + }); + + +$app->GET('/user/logout', function(Application $app, Request $request) { + + + return new Response('How about implementing logoutUser as a GET method ?'); + }); + + +$app->PUT('/user/{username}', function(Application $app, Request $request, $username) { + + + return new Response('How about implementing updateUser as a PUT method ?'); + }); + $app->run(); diff --git a/samples/server/petstore/sinatra/api/pet_api.rb b/samples/server/petstore/sinatra/api/pet_api.rb index 3ca40f568d3..e2bb229218b 100644 --- a/samples/server/petstore/sinatra/api/pet_api.rb +++ b/samples/server/petstore/sinatra/api/pet_api.rb @@ -1,25 +1,20 @@ require 'json' -MyApp.add_route('POST', '/v2/pets', { +MyApp.add_route('POST', '/v2/pet', { "resourcePath" => "/Pet", "summary" => "Add a new pet to the store", "nickname" => "add_pet", "responseClass" => "void", - "endpoint" => "/pets", + "endpoint" => "/pet", "notes" => "", "parameters" => [ - - - - { "name" => "body", "description" => "Pet object that needs to be added to the store", "dataType" => "Pet", "paramType" => "body", } - ]}) do cross_origin # the guts live here @@ -28,32 +23,26 @@ MyApp.add_route('POST', '/v2/pets', { end -MyApp.add_route('DELETE', '/v2/pets/{petId}', { +MyApp.add_route('DELETE', '/v2/pet/{petId}', { "resourcePath" => "/Pet", "summary" => "Deletes a pet", "nickname" => "delete_pet", "responseClass" => "void", - "endpoint" => "/pets/{petId}", + "endpoint" => "/pet/{petId}", "notes" => "", "parameters" => [ - - { "name" => "pet_id", "description" => "Pet id to delete", "dataType" => "int", "paramType" => "path", }, - - { "name" => "api_key", "description" => "", "dataType" => "string", "paramType" => "header", }, - - ]}) do cross_origin # the guts live here @@ -62,28 +51,23 @@ MyApp.add_route('DELETE', '/v2/pets/{petId}', { end -MyApp.add_route('GET', '/v2/pets/findByStatus', { +MyApp.add_route('GET', '/v2/pet/findByStatus', { "resourcePath" => "/Pet", "summary" => "Finds Pets by status", "nickname" => "find_pets_by_status", "responseClass" => "array[Pet]", - "endpoint" => "/pets/findByStatus", - "notes" => "Multiple status values can be provided with comma seperated strings", + "endpoint" => "/pet/findByStatus", + "notes" => "Multiple status values can be provided with comma separated strings", "parameters" => [ - { "name" => "status", "description" => "Status values that need to be considered for filter", "dataType" => "array[string]", "paramType" => "query", - "collectionFormat" => "multi", + "collectionFormat" => "csv", "allowableValues" => "", }, - - - - ]}) do cross_origin # the guts live here @@ -92,28 +76,23 @@ MyApp.add_route('GET', '/v2/pets/findByStatus', { end -MyApp.add_route('GET', '/v2/pets/findByTags', { +MyApp.add_route('GET', '/v2/pet/findByTags', { "resourcePath" => "/Pet", "summary" => "Finds Pets by tags", "nickname" => "find_pets_by_tags", "responseClass" => "array[Pet]", - "endpoint" => "/pets/findByTags", - "notes" => "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", + "endpoint" => "/pet/findByTags", + "notes" => "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", "parameters" => [ - { "name" => "tags", "description" => "Tags to filter by", "dataType" => "array[string]", "paramType" => "query", - "collectionFormat" => "multi", + "collectionFormat" => "csv", "allowableValues" => "", }, - - - - ]}) do cross_origin # the guts live here @@ -122,25 +101,20 @@ MyApp.add_route('GET', '/v2/pets/findByTags', { end -MyApp.add_route('GET', '/v2/pets/{petId}', { +MyApp.add_route('GET', '/v2/pet/{petId}', { "resourcePath" => "/Pet", "summary" => "Find pet by ID", "nickname" => "get_pet_by_id", "responseClass" => "Pet", - "endpoint" => "/pets/{petId}", - "notes" => "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", + "endpoint" => "/pet/{petId}", + "notes" => "Returns a single pet", "parameters" => [ - - { "name" => "pet_id", - "description" => "ID of pet that needs to be fetched", + "description" => "ID of pet to return", "dataType" => "int", "paramType" => "path", }, - - - ]}) do cross_origin # the guts live here @@ -149,25 +123,20 @@ MyApp.add_route('GET', '/v2/pets/{petId}', { end -MyApp.add_route('PUT', '/v2/pets', { +MyApp.add_route('PUT', '/v2/pet', { "resourcePath" => "/Pet", "summary" => "Update an existing pet", "nickname" => "update_pet", "responseClass" => "void", - "endpoint" => "/pets", + "endpoint" => "/pet", "notes" => "", "parameters" => [ - - - - { "name" => "body", "description" => "Pet object that needs to be added to the store", "dataType" => "Pet", "paramType" => "body", } - ]}) do cross_origin # the guts live here @@ -176,25 +145,42 @@ MyApp.add_route('PUT', '/v2/pets', { end -MyApp.add_route('POST', '/v2/pets/{petId}', { +MyApp.add_route('POST', '/v2/pet/{petId}', { "resourcePath" => "/Pet", "summary" => "Updates a pet in the store with form data", "nickname" => "update_pet_with_form", "responseClass" => "void", - "endpoint" => "/pets/{petId}", + "endpoint" => "/pet/{petId}", "notes" => "", "parameters" => [ - - { "name" => "pet_id", "description" => "ID of pet that needs to be updated", - "dataType" => "string", + "dataType" => "int", + "paramType" => "path", + }, + ]}) do + cross_origin + # the guts live here + + {"message" => "yes, it worked"}.to_json +end + + +MyApp.add_route('POST', '/v2/pet/{petId}/uploadImage', { + "resourcePath" => "/Pet", + "summary" => "uploads an image", + "nickname" => "upload_file", + "responseClass" => "ApiResponse", + "endpoint" => "/pet/{petId}/uploadImage", + "notes" => "", + "parameters" => [ + { + "name" => "pet_id", + "description" => "ID of pet to update", + "dataType" => "int", "paramType" => "path", }, - - - ]}) do cross_origin # the guts live here diff --git a/samples/server/petstore/sinatra/api/store_api.rb b/samples/server/petstore/sinatra/api/store_api.rb index 26ac567759b..e6fa2551e3a 100644 --- a/samples/server/petstore/sinatra/api/store_api.rb +++ b/samples/server/petstore/sinatra/api/store_api.rb @@ -1,25 +1,20 @@ require 'json' -MyApp.add_route('DELETE', '/v2/stores/order/{orderId}', { +MyApp.add_route('DELETE', '/v2/store/order/{orderId}', { "resourcePath" => "/Store", "summary" => "Delete purchase order by ID", "nickname" => "delete_order", "responseClass" => "void", - "endpoint" => "/stores/order/{orderId}", + "endpoint" => "/store/order/{orderId}", "notes" => "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", "parameters" => [ - - { "name" => "order_id", "description" => "ID of the order that needs to be deleted", "dataType" => "string", "paramType" => "path", }, - - - ]}) do cross_origin # the guts live here @@ -28,25 +23,36 @@ MyApp.add_route('DELETE', '/v2/stores/order/{orderId}', { end -MyApp.add_route('GET', '/v2/stores/order/{orderId}', { +MyApp.add_route('GET', '/v2/store/inventory', { + "resourcePath" => "/Store", + "summary" => "Returns pet inventories by status", + "nickname" => "get_inventory", + "responseClass" => "map[string,int]", + "endpoint" => "/store/inventory", + "notes" => "Returns a map of status codes to quantities", + "parameters" => [ + ]}) do + cross_origin + # the guts live here + + {"message" => "yes, it worked"}.to_json +end + + +MyApp.add_route('GET', '/v2/store/order/{orderId}', { "resourcePath" => "/Store", "summary" => "Find purchase order by ID", "nickname" => "get_order_by_id", "responseClass" => "Order", - "endpoint" => "/stores/order/{orderId}", + "endpoint" => "/store/order/{orderId}", "notes" => "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", "parameters" => [ - - { "name" => "order_id", "description" => "ID of pet that needs to be fetched", - "dataType" => "string", + "dataType" => "int", "paramType" => "path", }, - - - ]}) do cross_origin # the guts live here @@ -55,25 +61,20 @@ MyApp.add_route('GET', '/v2/stores/order/{orderId}', { end -MyApp.add_route('POST', '/v2/stores/order', { +MyApp.add_route('POST', '/v2/store/order', { "resourcePath" => "/Store", "summary" => "Place an order for a pet", "nickname" => "place_order", "responseClass" => "Order", - "endpoint" => "/stores/order", + "endpoint" => "/store/order", "notes" => "", "parameters" => [ - - - - { "name" => "body", "description" => "order placed for purchasing the pet", "dataType" => "Order", "paramType" => "body", } - ]}) do cross_origin # the guts live here diff --git a/samples/server/petstore/sinatra/api/user_api.rb b/samples/server/petstore/sinatra/api/user_api.rb index aaa76430310..bfec8909586 100644 --- a/samples/server/petstore/sinatra/api/user_api.rb +++ b/samples/server/petstore/sinatra/api/user_api.rb @@ -1,25 +1,20 @@ require 'json' -MyApp.add_route('POST', '/v2/users', { +MyApp.add_route('POST', '/v2/user', { "resourcePath" => "/User", "summary" => "Create user", "nickname" => "create_user", "responseClass" => "void", - "endpoint" => "/users", + "endpoint" => "/user", "notes" => "This can only be done by the logged in user.", "parameters" => [ - - - - { "name" => "body", "description" => "Created user object", "dataType" => "User", "paramType" => "body", } - ]}) do cross_origin # the guts live here @@ -28,25 +23,20 @@ MyApp.add_route('POST', '/v2/users', { end -MyApp.add_route('POST', '/v2/users/createWithArray', { +MyApp.add_route('POST', '/v2/user/createWithArray', { "resourcePath" => "/User", "summary" => "Creates list of users with given input array", "nickname" => "create_users_with_array_input", "responseClass" => "void", - "endpoint" => "/users/createWithArray", + "endpoint" => "/user/createWithArray", "notes" => "", "parameters" => [ - - - - { "name" => "body", "description" => "List of user object", "dataType" => "array[User]", "paramType" => "body", } - ]}) do cross_origin # the guts live here @@ -55,25 +45,20 @@ MyApp.add_route('POST', '/v2/users/createWithArray', { end -MyApp.add_route('POST', '/v2/users/createWithList', { +MyApp.add_route('POST', '/v2/user/createWithList', { "resourcePath" => "/User", "summary" => "Creates list of users with given input array", "nickname" => "create_users_with_list_input", "responseClass" => "void", - "endpoint" => "/users/createWithList", + "endpoint" => "/user/createWithList", "notes" => "", "parameters" => [ - - - - { "name" => "body", "description" => "List of user object", "dataType" => "array[User]", "paramType" => "body", } - ]}) do cross_origin # the guts live here @@ -82,25 +67,20 @@ MyApp.add_route('POST', '/v2/users/createWithList', { end -MyApp.add_route('DELETE', '/v2/users/{username}', { +MyApp.add_route('DELETE', '/v2/user/{username}', { "resourcePath" => "/User", "summary" => "Delete user", "nickname" => "delete_user", "responseClass" => "void", - "endpoint" => "/users/{username}", + "endpoint" => "/user/{username}", "notes" => "This can only be done by the logged in user.", "parameters" => [ - - { "name" => "username", "description" => "The name that needs to be deleted", "dataType" => "string", "paramType" => "path", }, - - - ]}) do cross_origin # the guts live here @@ -109,25 +89,20 @@ MyApp.add_route('DELETE', '/v2/users/{username}', { end -MyApp.add_route('GET', '/v2/users/{username}', { +MyApp.add_route('GET', '/v2/user/{username}', { "resourcePath" => "/User", "summary" => "Get user by user name", "nickname" => "get_user_by_name", "responseClass" => "User", - "endpoint" => "/users/{username}", + "endpoint" => "/user/{username}", "notes" => "", "parameters" => [ - - { "name" => "username", - "description" => "The name that needs to be fetched. Use user1 for testing.", + "description" => "The name that needs to be fetched. Use user1 for testing. ", "dataType" => "string", "paramType" => "path", }, - - - ]}) do cross_origin # the guts live here @@ -136,15 +111,14 @@ MyApp.add_route('GET', '/v2/users/{username}', { end -MyApp.add_route('GET', '/v2/users/login', { +MyApp.add_route('GET', '/v2/user/login', { "resourcePath" => "/User", "summary" => "Logs user into the system", "nickname" => "login_user", "responseClass" => "string", - "endpoint" => "/users/login", + "endpoint" => "/user/login", "notes" => "", "parameters" => [ - { "name" => "username", "description" => "The user name for login", @@ -154,7 +128,6 @@ MyApp.add_route('GET', '/v2/users/login', { "allowableValues" => "", }, - { "name" => "password", "description" => "The password for login in clear text", @@ -164,10 +137,6 @@ MyApp.add_route('GET', '/v2/users/login', { "allowableValues" => "", }, - - - - ]}) do cross_origin # the guts live here @@ -176,18 +145,14 @@ MyApp.add_route('GET', '/v2/users/login', { end -MyApp.add_route('GET', '/v2/users/logout', { +MyApp.add_route('GET', '/v2/user/logout', { "resourcePath" => "/User", "summary" => "Logs out current logged in user session", "nickname" => "logout_user", "responseClass" => "void", - "endpoint" => "/users/logout", + "endpoint" => "/user/logout", "notes" => "", "parameters" => [ - - - - ]}) do cross_origin # the guts live here @@ -196,32 +161,26 @@ MyApp.add_route('GET', '/v2/users/logout', { end -MyApp.add_route('PUT', '/v2/users/{username}', { +MyApp.add_route('PUT', '/v2/user/{username}', { "resourcePath" => "/User", "summary" => "Updated user", "nickname" => "update_user", "responseClass" => "void", - "endpoint" => "/users/{username}", + "endpoint" => "/user/{username}", "notes" => "This can only be done by the logged in user.", "parameters" => [ - - { "name" => "username", "description" => "name that need to be deleted", "dataType" => "string", "paramType" => "path", }, - - - { "name" => "body", "description" => "Updated user object", "dataType" => "User", "paramType" => "body", } - ]}) do cross_origin # the guts live here diff --git a/samples/server/petstore/sinatra/swagger.yaml b/samples/server/petstore/sinatra/swagger.yaml index 4aa26a9539c..e6a9add869d 100644 --- a/samples/server/petstore/sinatra/swagger.yaml +++ b/samples/server/petstore/sinatra/swagger.yaml @@ -1,23 +1,37 @@ --- swagger: "2.0" info: - description: "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.io)\ - \ or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample,\ - \ you can use the api key `special-key` to test the authorization filters\n" + description: "This is a sample server Petstore server. You can find out more about\ + \ 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://helloreverb.com/terms/" + termsOfService: "http://swagger.io/terms/" contact: - name: "apiteam@swagger.io" + email: "apiteam@swagger.io" license: name: "Apache 2.0" 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: - /pets: + /pet: post: tags: - "pet" @@ -28,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: @@ -42,8 +56,8 @@ paths: description: "Invalid input" security: - petstore_auth: - - "write_pets" - - "read_pets" + - "write:pets" + - "read:pets" put: tags: - "pet" @@ -54,13 +68,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: @@ -72,27 +86,32 @@ paths: description: "Validation exception" security: - petstore_auth: - - "write_pets" - - "read_pets" - /pets/findByStatus: + - "write:pets" + - "read:pets" + /pet/findByStatus: get: 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" + enum: + - "available" + - "pending" + - "sold" + collectionFormat: "csv" responses: 200: description: "successful operation" @@ -104,28 +123,28 @@ paths: description: "Invalid status value" security: - petstore_auth: - - "write_pets" - - "read_pets" - /pets/findByTags: + - "write:pets" + - "read:pets" + /pet/findByTags: get: 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" @@ -137,23 +156,22 @@ paths: description: "Invalid tag value" security: - petstore_auth: - - "write_pets" - - "read_pets" - /pets/{petId}: + - "write:pets" + - "read:pets" + /pet/{petId}: get: 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" @@ -168,9 +186,6 @@ paths: description: "Pet not found" security: - api_key: [] - - petstore_auth: - - "write_pets" - - "read_pets" post: tags: - "pet" @@ -180,31 +195,32 @@ 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" - required: true + required: false type: "string" - name: "status" in: "formData" description: "Updated status of the pet" - required: true + required: false type: "string" responses: 405: description: "Invalid input" security: - petstore_auth: - - "write_pets" - - "read_pets" + - "write:pets" + - "read:pets" delete: tags: - "pet" @@ -212,13 +228,12 @@ paths: description: "" operationId: "deletePet" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "api_key" in: "header" - description: "" - required: true + required: false type: "string" - name: "petId" in: "path" @@ -231,9 +246,66 @@ paths: description: "Invalid pet value" security: - petstore_auth: - - "write_pets" - - "read_pets" - /stores/order: + - "write:pets" + - "read:pets" + /pet/{petId}/uploadImage: + post: + tags: + - "pet" + summary: "uploads an image" + description: "" + operationId: "uploadFile" + consumes: + - "multipart/form-data" + produces: + - "application/json" + parameters: + - name: "petId" + in: "path" + description: "ID of pet to update" + required: true + type: "integer" + format: "int64" + - name: "additionalMetadata" + in: "formData" + description: "Additional data to pass to server" + required: false + type: "string" + - name: "file" + in: "formData" + description: "file to upload" + required: false + type: "file" + responses: + 200: + description: "successful operation" + schema: + $ref: "#/definitions/ApiResponse" + security: + - petstore_auth: + - "write:pets" + - "read:pets" + /store/inventory: + get: + tags: + - "store" + summary: "Returns pet inventories by status" + description: "Returns a map of status codes to quantities" + operationId: "getInventory" + produces: + - "application/json" + parameters: [] + responses: + 200: + description: "successful operation" + schema: + type: "object" + additionalProperties: + type: "integer" + format: "int32" + security: + - api_key: [] + /store/order: post: tags: - "store" @@ -241,13 +313,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: @@ -257,7 +329,7 @@ paths: $ref: "#/definitions/Order" 400: description: "Invalid Order" - /stores/order/{orderId}: + /store/order/{orderId}: get: tags: - "store" @@ -266,14 +338,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" @@ -291,20 +366,21 @@ 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" 404: description: "Order not found" - /users: + /user: post: tags: - "user" @@ -312,19 +388,19 @@ 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: default: description: "successful operation" - /users/createWithArray: + /user/createWithArray: post: tags: - "user" @@ -332,13 +408,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: @@ -346,7 +422,7 @@ paths: responses: default: description: "successful operation" - /users/createWithList: + /user/createWithList: post: tags: - "user" @@ -354,13 +430,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: @@ -368,7 +444,7 @@ paths: responses: default: description: "successful operation" - /users/login: + /user/login: get: tags: - "user" @@ -376,27 +452,36 @@ 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" - /users/logout: + /user/logout: get: tags: - "user" @@ -404,13 +489,13 @@ paths: description: "" operationId: "logoutUser" produces: - - "application/json" - "application/xml" + - "application/json" parameters: [] responses: default: description: "successful operation" - /users/{username}: + /user/{username}: get: tags: - "user" @@ -418,12 +503,12 @@ paths: description: "" operationId: "getUserByName" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "username" in: "path" - description: "The name that needs to be fetched. Use user1 for testing." + description: "The name that needs to be fetched. Use user1 for testing. " required: true type: "string" responses: @@ -442,8 +527,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" @@ -453,7 +538,7 @@ paths: - in: "body" name: "body" description: "Updated user object" - required: false + required: true schema: $ref: "#/definitions/User" responses: @@ -468,8 +553,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" @@ -491,9 +576,46 @@ securityDefinitions: authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog" flow: "implicit" scopes: - write_pets: "modify pets in your account" - read_pets: "read your pets" + 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: @@ -516,7 +638,9 @@ definitions: type: "integer" format: "int32" description: "User Status" - Category: + xml: + name: "User" + Tag: type: "object" properties: id: @@ -524,6 +648,8 @@ definitions: format: "int64" name: type: "string" + xml: + name: "Tag" Pet: type: "object" required: @@ -540,40 +666,37 @@ definitions: example: "doggie" photoUrls: type: "array" + xml: + name: "photoUrl" + wrapped: true items: type: "string" tags: type: "array" + xml: + name: "tag" + wrapped: true items: $ref: "#/definitions/Tag" status: type: "string" description: "pet status in the store" - Tag: + enum: + - "available" + - "pending" + - "sold" + xml: + name: "Pet" + ApiResponse: type: "object" properties: - id: - type: "integer" - format: "int64" - name: - type: "string" - Order: - type: "object" - 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" - complete: - type: "boolean" +externalDocs: + description: "Find out more about Swagger" + url: "http://swagger.io" diff --git a/samples/server/petstore/slim/SwaggerServer/index.php b/samples/server/petstore/slim/SwaggerServer/index.php index 2ee51c0d71f..0138feb1d55 100644 --- a/samples/server/petstore/slim/SwaggerServer/index.php +++ b/samples/server/petstore/slim/SwaggerServer/index.php @@ -9,11 +9,205 @@ require_once __DIR__ . '/vendor/autoload.php'; $app = new Slim\App(); +/** + * POST addPet + * Summary: Add a new pet to the store + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/pet', function($request, $response, $args) { + + + + $body = $request->getParsedBody(); + $response->write('How about implementing addPet as a POST method ?'); + return $response; + }); + + +/** + * DELETE deletePet + * Summary: Deletes a pet + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->DELETE('/pet/{petId}', function($request, $response, $args) { + $headers = $request->getHeaders(); + + + + $response->write('How about implementing deletePet as a DELETE method ?'); + return $response; + }); + + +/** + * GET findPetsByStatus + * Summary: Finds Pets by status + * Notes: Multiple status values can be provided with comma separated strings + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/pet/findByStatus', function($request, $response, $args) { + + $queryParams = $request->getQueryParams(); + $status = $queryParams['status']; + + + $response->write('How about implementing findPetsByStatus as a GET method ?'); + return $response; + }); + + +/** + * GET findPetsByTags + * Summary: Finds Pets by tags + * Notes: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/pet/findByTags', function($request, $response, $args) { + + $queryParams = $request->getQueryParams(); + $tags = $queryParams['tags']; + + + $response->write('How about implementing findPetsByTags as a GET method ?'); + return $response; + }); + + +/** + * GET getPetById + * Summary: Find pet by ID + * Notes: Returns a single pet + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/pet/{petId}', function($request, $response, $args) { + + + + + $response->write('How about implementing getPetById as a GET method ?'); + return $response; + }); + + +/** + * PUT updatePet + * Summary: Update an existing pet + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->PUT('/pet', function($request, $response, $args) { + + + + $body = $request->getParsedBody(); + $response->write('How about implementing updatePet as a PUT method ?'); + return $response; + }); + + +/** + * POST updatePetWithForm + * Summary: Updates a pet in the store with form data + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/pet/{petId}', function($request, $response, $args) { + + + $name = $args['name']; $status = $args['status']; + + $response->write('How about implementing updatePetWithForm as a POST method ?'); + return $response; + }); + + +/** + * POST uploadFile + * Summary: uploads an image + * Notes: + * Output-Formats: [application/json] + */ +$app->POST('/pet/{petId}/uploadImage', function($request, $response, $args) { + + + $additionalMetadata = $args['additionalMetadata']; $file = $args['file']; + + $response->write('How about implementing uploadFile as a POST method ?'); + return $response; + }); + + +/** + * DELETE deleteOrder + * Summary: Delete purchase order by ID + * Notes: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Output-Formats: [application/xml, application/json] + */ +$app->DELETE('/store/order/{orderId}', function($request, $response, $args) { + + + + + $response->write('How about implementing deleteOrder as a DELETE method ?'); + return $response; + }); + + +/** + * GET getInventory + * Summary: Returns pet inventories by status + * Notes: Returns a map of status codes to quantities + * Output-Formats: [application/json] + */ +$app->GET('/store/inventory', function($request, $response, $args) { + + + + + $response->write('How about implementing getInventory as a GET method ?'); + return $response; + }); + + +/** + * GET getOrderById + * Summary: Find purchase order by ID + * Notes: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/store/order/{orderId}', function($request, $response, $args) { + + + + + $response->write('How about implementing getOrderById as a GET method ?'); + return $response; + }); + + +/** + * POST placeOrder + * Summary: Place an order for a pet + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/store/order', function($request, $response, $args) { + + + + $body = $request->getParsedBody(); + $response->write('How about implementing placeOrder as a POST method ?'); + return $response; + }); + + /** * POST createUser * Summary: Create user * Notes: This can only be done by the logged in user. - * Output-Formats: [application/json, application/xml] + * Output-Formats: [application/xml, application/json] */ $app->POST('/user', function($request, $response, $args) { @@ -29,7 +223,7 @@ $app->POST('/user', function($request, $response, $args) { * POST createUsersWithArrayInput * Summary: Creates list of users with given input array * Notes: - * Output-Formats: [application/json, application/xml] + * Output-Formats: [application/xml, application/json] */ $app->POST('/user/createWithArray', function($request, $response, $args) { @@ -45,7 +239,7 @@ $app->POST('/user/createWithArray', function($request, $response, $args) { * POST createUsersWithListInput * Summary: Creates list of users with given input array * Notes: - * Output-Formats: [application/json, application/xml] + * Output-Formats: [application/xml, application/json] */ $app->POST('/user/createWithList', function($request, $response, $args) { @@ -57,11 +251,43 @@ $app->POST('/user/createWithList', function($request, $response, $args) { }); +/** + * DELETE deleteUser + * Summary: Delete user + * Notes: This can only be done by the logged in user. + * Output-Formats: [application/xml, application/json] + */ +$app->DELETE('/user/{username}', function($request, $response, $args) { + + + + + $response->write('How about implementing deleteUser as a DELETE method ?'); + return $response; + }); + + +/** + * GET getUserByName + * Summary: Get user by user name + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/user/{username}', function($request, $response, $args) { + + + + + $response->write('How about implementing getUserByName as a GET method ?'); + return $response; + }); + + /** * GET loginUser * Summary: Logs user into the system * Notes: - * Output-Formats: [application/json, application/xml] + * Output-Formats: [application/xml, application/json] */ $app->GET('/user/login', function($request, $response, $args) { @@ -78,7 +304,7 @@ $app->GET('/user/login', function($request, $response, $args) { * GET logoutUser * Summary: Logs out current logged in user session * Notes: - * Output-Formats: [application/json, application/xml] + * Output-Formats: [application/xml, application/json] */ $app->GET('/user/logout', function($request, $response, $args) { @@ -90,27 +316,11 @@ $app->GET('/user/logout', function($request, $response, $args) { }); -/** - * GET getUserByName - * Summary: Get user by user name - * Notes: - * Output-Formats: [application/json, application/xml] - */ -$app->GET('/user/{username}', function($request, $response, $args) { - - - - - $response->write('How about implementing getUserByName as a GET method ?'); - return $response; - }); - - /** * PUT updateUser * Summary: Updated user * Notes: This can only be done by the logged in user. - * Output-Formats: [application/json, application/xml] + * Output-Formats: [application/xml, application/json] */ $app->PUT('/user/{username}', function($request, $response, $args) { @@ -122,247 +332,5 @@ $app->PUT('/user/{username}', function($request, $response, $args) { }); -/** - * DELETE deleteUser - * Summary: Delete user - * Notes: This can only be done by the logged in user. - * Output-Formats: [application/json, application/xml] - */ -$app->DELETE('/user/{username}', function($request, $response, $args) { - - - - - $response->write('How about implementing deleteUser as a DELETE method ?'); - return $response; - }); - - -/** - * PUT updatePet - * Summary: Update an existing pet - * Notes: - * Output-Formats: [application/json, application/xml] - */ -$app->PUT('/pet', function($request, $response, $args) { - - - - $body = $request->getParsedBody(); - $response->write('How about implementing updatePet as a PUT method ?'); - return $response; - }); - - -/** - * POST addPet - * Summary: Add a new pet to the store - * Notes: - * Output-Formats: [application/json, application/xml] - */ -$app->POST('/pet', function($request, $response, $args) { - - - - $body = $request->getParsedBody(); - $response->write('How about implementing addPet as a POST method ?'); - return $response; - }); - - -/** - * GET findPetsByStatus - * Summary: Finds Pets by status - * Notes: Multiple status values can be provided with comma seperated strings - * Output-Formats: [application/json, application/xml] - */ -$app->GET('/pet/findByStatus', function($request, $response, $args) { - - $queryParams = $request->getQueryParams(); - $status = $queryParams['status']; - - - $response->write('How about implementing findPetsByStatus as a GET method ?'); - return $response; - }); - - -/** - * GET findPetsByTags - * Summary: Finds Pets by tags - * Notes: Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * Output-Formats: [application/json, application/xml] - */ -$app->GET('/pet/findByTags', function($request, $response, $args) { - - $queryParams = $request->getQueryParams(); - $tags = $queryParams['tags']; - - - $response->write('How about implementing findPetsByTags as a GET method ?'); - return $response; - }); - - -/** - * GET getPetById - * Summary: Find pet by ID - * Notes: Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * Output-Formats: [application/json, application/xml] - */ -$app->GET('/pet/{petId}', function($request, $response, $args) { - - - - - $response->write('How about implementing getPetById as a GET method ?'); - return $response; - }); - - -/** - * POST updatePetWithForm - * Summary: Updates a pet in the store with form data - * Notes: - * Output-Formats: [application/json, application/xml] - */ -$app->POST('/pet/{petId}', function($request, $response, $args) { - - - $name = $args['name']; $status = $args['status']; - - $response->write('How about implementing updatePetWithForm as a POST method ?'); - return $response; - }); - - -/** - * DELETE deletePet - * Summary: Deletes a pet - * Notes: - * Output-Formats: [application/json, application/xml] - */ -$app->DELETE('/pet/{petId}', function($request, $response, $args) { - $headers = $request->getHeaders(); - - - - $response->write('How about implementing deletePet as a DELETE method ?'); - return $response; - }); - - -/** - * POST uploadFile - * Summary: uploads an image - * Notes: - * Output-Formats: [application/json, application/xml] - */ -$app->POST('/pet/{petId}/uploadImage', function($request, $response, $args) { - - - $additionalMetadata = $args['additionalMetadata']; $file = $args['file']; - - $response->write('How about implementing uploadFile as a POST method ?'); - return $response; - }); - - -/** - * GET getPetByIdWithByteArray - * Summary: Fake endpoint to test byte array return by 'Find pet by ID' - * Notes: Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * Output-Formats: [application/json, application/xml] - */ -$app->GET('/pet/{petId}?testing_byte_array=true', function($request, $response, $args) { - - - - - $response->write('How about implementing getPetByIdWithByteArray as a GET method ?'); - return $response; - }); - - -/** - * POST addPetUsingByteArray - * Summary: Fake endpoint to test byte array in body parameter for adding a new pet to the store - * Notes: - * Output-Formats: [application/json, application/xml] - */ -$app->POST('/pet?testing_byte_array=true', function($request, $response, $args) { - - - - $body = $request->getParsedBody(); - $response->write('How about implementing addPetUsingByteArray as a POST method ?'); - return $response; - }); - - -/** - * GET getInventory - * Summary: Returns pet inventories by status - * Notes: Returns a map of status codes to quantities - * Output-Formats: [application/json, application/xml] - */ -$app->GET('/store/inventory', function($request, $response, $args) { - - - - - $response->write('How about implementing getInventory as a GET method ?'); - return $response; - }); - - -/** - * POST placeOrder - * Summary: Place an order for a pet - * Notes: - * Output-Formats: [application/json, application/xml] - */ -$app->POST('/store/order', function($request, $response, $args) { - - - - $body = $request->getParsedBody(); - $response->write('How about implementing placeOrder as a POST method ?'); - return $response; - }); - - -/** - * GET getOrderById - * Summary: Find purchase order by ID - * Notes: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * Output-Formats: [application/json, application/xml] - */ -$app->GET('/store/order/{orderId}', function($request, $response, $args) { - - - - - $response->write('How about implementing getOrderById as a GET method ?'); - return $response; - }); - - -/** - * DELETE deleteOrder - * Summary: Delete purchase order by ID - * Notes: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * Output-Formats: [application/json, application/xml] - */ -$app->DELETE('/store/order/{orderId}', function($request, $response, $args) { - - - - - $response->write('How about implementing deleteOrder as a DELETE method ?'); - return $response; - }); - - $app->run();