From 93cadcd755d5e5db9682f498cad84ee255103664 Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 19 Jan 2016 23:39:07 +0800 Subject: [PATCH] make slim sh executable --- bin/slim-petstore-server.sh | 0 .../petstore/slim/SwaggerServer/README.md | 2 +- .../petstore/slim/SwaggerServer/index.php | 194 ++++++++++-------- 3 files changed, 114 insertions(+), 82 deletions(-) mode change 100644 => 100755 bin/slim-petstore-server.sh diff --git a/bin/slim-petstore-server.sh b/bin/slim-petstore-server.sh old mode 100644 new mode 100755 diff --git a/samples/server/petstore/slim/SwaggerServer/README.md b/samples/server/petstore/slim/SwaggerServer/README.md index 3b19f46bd38..03910060439 100644 --- a/samples/server/petstore/slim/SwaggerServer/README.md +++ b/samples/server/petstore/slim/SwaggerServer/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 PHP server. This example uses the [Slim Framework](http://www.slimframework.com/). To see how to make this your own, please take a look at the template here: diff --git a/samples/server/petstore/slim/SwaggerServer/index.php b/samples/server/petstore/slim/SwaggerServer/index.php index 1db11f806fb..2ee51c0d71f 100644 --- a/samples/server/petstore/slim/SwaggerServer/index.php +++ b/samples/server/petstore/slim/SwaggerServer/index.php @@ -13,7 +13,7 @@ $app = new Slim\App(); * POST createUser * Summary: Create user * Notes: This can only be done by the logged in user. - * Output-Formats: [application/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->POST('/user', function($request, $response, $args) { @@ -29,7 +29,7 @@ $app->POST('/user', function($request, $response, $args) { * POST createUsersWithArrayInput * Summary: Creates list of users with given input array * Notes: - * Output-Formats: [application/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->POST('/user/createWithArray', function($request, $response, $args) { @@ -45,7 +45,7 @@ $app->POST('/user/createWithArray', function($request, $response, $args) { * POST createUsersWithListInput * Summary: Creates list of users with given input array * Notes: - * Output-Formats: [application/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->POST('/user/createWithList', function($request, $response, $args) { @@ -61,7 +61,7 @@ $app->POST('/user/createWithList', function($request, $response, $args) { * GET loginUser * Summary: Logs user into the system * Notes: - * Output-Formats: [application/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->GET('/user/login', function($request, $response, $args) { @@ -78,7 +78,7 @@ $app->GET('/user/login', function($request, $response, $args) { * GET logoutUser * Summary: Logs out current logged in user session * Notes: - * Output-Formats: [application/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->GET('/user/logout', function($request, $response, $args) { @@ -94,7 +94,7 @@ $app->GET('/user/logout', function($request, $response, $args) { * GET getUserByName * Summary: Get user by user name * Notes: - * Output-Formats: [application/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->GET('/user/{username}', function($request, $response, $args) { @@ -110,7 +110,7 @@ $app->GET('/user/{username}', function($request, $response, $args) { * PUT updateUser * Summary: Updated user * Notes: This can only be done by the logged in user. - * Output-Formats: [application/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->PUT('/user/{username}', function($request, $response, $args) { @@ -126,7 +126,7 @@ $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/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->DELETE('/user/{username}', function($request, $response, $args) { @@ -138,75 +138,11 @@ $app->DELETE('/user/{username}', function($request, $response, $args) { }); -/** - * 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; - }); - - -/** - * 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; - }); - - -/** - * 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; - }); - - -/** - * 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; - }); - - /** * PUT updatePet * Summary: Update an existing pet * Notes: - * Output-Formats: [application/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->PUT('/pet', function($request, $response, $args) { @@ -222,7 +158,7 @@ $app->PUT('/pet', function($request, $response, $args) { * POST addPet * Summary: Add a new pet to the store * Notes: - * Output-Formats: [application/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->POST('/pet', function($request, $response, $args) { @@ -238,7 +174,7 @@ $app->POST('/pet', function($request, $response, $args) { * GET findPetsByStatus * Summary: Finds Pets by status * Notes: Multiple status values can be provided with comma seperated strings - * Output-Formats: [application/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->GET('/pet/findByStatus', function($request, $response, $args) { @@ -255,7 +191,7 @@ $app->GET('/pet/findByStatus', function($request, $response, $args) { * 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/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->GET('/pet/findByTags', function($request, $response, $args) { @@ -271,8 +207,8 @@ $app->GET('/pet/findByTags', function($request, $response, $args) { /** * GET getPetById * Summary: Find pet by ID - * Notes: Returns a single pet - * Output-Formats: [application/xml, application/json] + * 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) { @@ -288,7 +224,7 @@ $app->GET('/pet/{petId}', function($request, $response, $args) { * POST updatePetWithForm * Summary: Updates a pet in the store with form data * Notes: - * Output-Formats: [application/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->POST('/pet/{petId}', function($request, $response, $args) { @@ -304,7 +240,7 @@ $app->POST('/pet/{petId}', function($request, $response, $args) { * DELETE deletePet * Summary: Deletes a pet * Notes: - * Output-Formats: [application/xml, application/json] + * Output-Formats: [application/json, application/xml] */ $app->DELETE('/pet/{petId}', function($request, $response, $args) { $headers = $request->getHeaders(); @@ -320,7 +256,7 @@ $app->DELETE('/pet/{petId}', function($request, $response, $args) { * POST uploadFile * Summary: uploads an image * Notes: - * Output-Formats: [application/json] + * Output-Formats: [application/json, application/xml] */ $app->POST('/pet/{petId}/uploadImage', function($request, $response, $args) { @@ -332,5 +268,101 @@ $app->POST('/pet/{petId}/uploadImage', function($request, $response, $args) { }); +/** + * 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();