From bee6803bcb039aa2060de2080a0008477b22cfe7 Mon Sep 17 00:00:00 2001 From: abcsun Date: Wed, 20 Jul 2016 19:06:14 +0800 Subject: [PATCH] add context path (#3425) --- .../src/main/resources/lumen/routes.mustache | 2 +- .../lumen/app/Http/controllers/FakeApi.php | 24 +++++++++ .../server/petstore/lumen/app/Http/routes.php | 51 +++++++++++-------- 3 files changed, 54 insertions(+), 23 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/lumen/routes.mustache b/modules/swagger-codegen/src/main/resources/lumen/routes.mustache index c5f3bdf858a..4b9631fd9a5 100644 --- a/modules/swagger-codegen/src/main/resources/lumen/routes.mustache +++ b/modules/swagger-codegen/src/main/resources/lumen/routes.mustache @@ -19,7 +19,7 @@ $app->get('/', function () use ($app) { * Notes: {{notes}} {{#hasProduces}} * Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}} */ -$app->{{httpMethod}}('{{path}}', '{{classname}}@{{operationId}}'); +$app->{{httpMethod}}('{{basePathWithoutHost}}{{path}}', '{{classname}}@{{operationId}}'); {{/operation}} {{/operations}} {{/apis}} diff --git a/samples/server/petstore/lumen/app/Http/controllers/FakeApi.php b/samples/server/petstore/lumen/app/Http/controllers/FakeApi.php index 11c9e2dc4c4..a55492b90f1 100644 --- a/samples/server/petstore/lumen/app/Http/controllers/FakeApi.php +++ b/samples/server/petstore/lumen/app/Http/controllers/FakeApi.php @@ -38,6 +38,30 @@ class FakeApi extends Controller { } + /** + * Operation testClientModel + * + * To test \"client\" model. + * + * + * @return Http response + */ + public function testClientModel() + { + $input = Request::all(); + + //path params validation + + + //not path params validation + if (!isset($input['body'])) { + throw new \InvalidArgumentException('Missing the required parameter $body when calling testClientModel'); + } + $body = $input['body']; + + + return response('How about implementing testClientModel as a PATCH method ?'); + } /** * Operation testEndpointParameters * diff --git a/samples/server/petstore/lumen/app/Http/routes.php b/samples/server/petstore/lumen/app/Http/routes.php index c61d6d3c4d3..ea9b463bffa 100644 --- a/samples/server/petstore/lumen/app/Http/routes.php +++ b/samples/server/petstore/lumen/app/Http/routes.php @@ -33,158 +33,165 @@ $app->get('/', function () use ($app) { return $app->version(); }); +/** + * PATCH testClientModel + * Summary: To test \"client\" model + * Notes: + * Output-Formats: [application/json] + */ +$app->PATCH('/v2/fake', 'FakeApi@testClientModel'); /** * POST testEndpointParameters * Summary: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * Notes: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * Output-Formats: [application/xml; charset=utf-8, application/json; charset=utf-8] */ -$app->POST('/fake', 'FakeApi@testEndpointParameters'); +$app->POST('/v2/fake', 'FakeApi@testEndpointParameters'); /** * GET testEnumQueryParameters * Summary: To test enum query parameters * Notes: * Output-Formats: [application/json] */ -$app->GET('/fake', 'FakeApi@testEnumQueryParameters'); +$app->GET('/v2/fake', 'FakeApi@testEnumQueryParameters'); /** * POST addPet * Summary: Add a new pet to the store * Notes: * Output-Formats: [application/xml, application/json] */ -$app->POST('/pet', 'PetApi@addPet'); +$app->POST('/v2/pet', 'PetApi@addPet'); /** * PUT updatePet * Summary: Update an existing pet * Notes: * Output-Formats: [application/xml, application/json] */ -$app->PUT('/pet', 'PetApi@updatePet'); +$app->PUT('/v2/pet', 'PetApi@updatePet'); /** * 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', 'PetApi@findPetsByStatus'); +$app->GET('/v2/pet/findByStatus', 'PetApi@findPetsByStatus'); /** * 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', 'PetApi@findPetsByTags'); +$app->GET('/v2/pet/findByTags', 'PetApi@findPetsByTags'); /** * DELETE deletePet * Summary: Deletes a pet * Notes: * Output-Formats: [application/xml, application/json] */ -$app->DELETE('/pet/{petId}', 'PetApi@deletePet'); +$app->DELETE('/v2/pet/{petId}', 'PetApi@deletePet'); /** * GET getPetById * Summary: Find pet by ID * Notes: Returns a single pet * Output-Formats: [application/xml, application/json] */ -$app->GET('/pet/{petId}', 'PetApi@getPetById'); +$app->GET('/v2/pet/{petId}', 'PetApi@getPetById'); /** * POST updatePetWithForm * Summary: Updates a pet in the store with form data * Notes: * Output-Formats: [application/xml, application/json] */ -$app->POST('/pet/{petId}', 'PetApi@updatePetWithForm'); +$app->POST('/v2/pet/{petId}', 'PetApi@updatePetWithForm'); /** * POST uploadFile * Summary: uploads an image * Notes: * Output-Formats: [application/json] */ -$app->POST('/pet/{petId}/uploadImage', 'PetApi@uploadFile'); +$app->POST('/v2/pet/{petId}/uploadImage', 'PetApi@uploadFile'); /** * 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', 'StoreApi@getInventory'); +$app->GET('/v2/store/inventory', 'StoreApi@getInventory'); /** * POST placeOrder * Summary: Place an order for a pet * Notes: * Output-Formats: [application/xml, application/json] */ -$app->POST('/store/order', 'StoreApi@placeOrder'); +$app->POST('/v2/store/order', 'StoreApi@placeOrder'); /** * 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}', 'StoreApi@deleteOrder'); +$app->DELETE('/v2/store/order/{orderId}', 'StoreApi@deleteOrder'); /** * 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}', 'StoreApi@getOrderById'); +$app->GET('/v2/store/order/{orderId}', 'StoreApi@getOrderById'); /** * POST createUser * Summary: Create user * Notes: This can only be done by the logged in user. * Output-Formats: [application/xml, application/json] */ -$app->POST('/user', 'UserApi@createUser'); +$app->POST('/v2/user', 'UserApi@createUser'); /** * POST createUsersWithArrayInput * Summary: Creates list of users with given input array * Notes: * Output-Formats: [application/xml, application/json] */ -$app->POST('/user/createWithArray', 'UserApi@createUsersWithArrayInput'); +$app->POST('/v2/user/createWithArray', 'UserApi@createUsersWithArrayInput'); /** * POST createUsersWithListInput * Summary: Creates list of users with given input array * Notes: * Output-Formats: [application/xml, application/json] */ -$app->POST('/user/createWithList', 'UserApi@createUsersWithListInput'); +$app->POST('/v2/user/createWithList', 'UserApi@createUsersWithListInput'); /** * GET loginUser * Summary: Logs user into the system * Notes: * Output-Formats: [application/xml, application/json] */ -$app->GET('/user/login', 'UserApi@loginUser'); +$app->GET('/v2/user/login', 'UserApi@loginUser'); /** * GET logoutUser * Summary: Logs out current logged in user session * Notes: * Output-Formats: [application/xml, application/json] */ -$app->GET('/user/logout', 'UserApi@logoutUser'); +$app->GET('/v2/user/logout', 'UserApi@logoutUser'); /** * 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}', 'UserApi@deleteUser'); +$app->DELETE('/v2/user/{username}', 'UserApi@deleteUser'); /** * GET getUserByName * Summary: Get user by user name * Notes: * Output-Formats: [application/xml, application/json] */ -$app->GET('/user/{username}', 'UserApi@getUserByName'); +$app->GET('/v2/user/{username}', 'UserApi@getUserByName'); /** * PUT updateUser * Summary: Updated user * Notes: This can only be done by the logged in user. * Output-Formats: [application/xml, application/json] */ -$app->PUT('/user/{username}', 'UserApi@updateUser'); +$app->PUT('/v2/user/{username}', 'UserApi@updateUser');