check for dot in path and throw exception if found (#6986)

This commit is contained in:
William Cheng 2017-11-17 20:18:06 +08:00 committed by GitHub
parent 73cb68ee7b
commit 15bbb52b22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 273 additions and 84 deletions

View File

@ -105,6 +105,15 @@ public class LumenServerCodegen extends AbstractPhpCodegen
@SuppressWarnings("unchecked")
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
for (CodegenOperation op : operations) {
op.httpMethod = op.httpMethod.toLowerCase();
// check to see if the path contains ".", which is not supported by Lumen
// ref: https://github.com/swagger-api/swagger-codegen/issues/6897
if (op.path != null && op.path.contains(".")) {
throw new IllegalArgumentException("'.' (dot) is not supported by PHP Lumen. Please refer to https://github.com/swagger-api/swagger-codegen/issues/6897 for more info.");
}
}
// sort the endpoints in ascending to avoid the route priority issure.
// https://github.com/swagger-api/swagger-codegen/issues/2643
Collections.sort(operations, new Comparator<CodegenOperation>() {

View File

@ -1 +1 @@
2.2.3-SNAPSHOT
2.3.0-SNAPSHOT

View File

@ -0,0 +1,53 @@
<?php
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Request;
class AnotherFakeApi extends Controller
{
/**
* Constructor
*/
public function __construct()
{
}
/**
* Operation testSpecialTags
*
* To test special tags.
*
*
* @return Http response
*/
public function testSpecialTags()
{
$input = Request::all();
//path params validation
//not path params validation
if (!isset($input['body'])) {
throw new \InvalidArgumentException('Missing the required parameter $body when calling testSpecialTags');
}
$body = $input['body'];
return response('How about implementing testSpecialTags as a patch method ?');
}
}

View File

@ -48,7 +48,7 @@ class FakeApi extends Controller
$body = $input['body'];
return response('How about implementing testClientModel as a PATCH method ?');
return response('How about implementing testClientModel as a patch method ?');
}
/**
* Operation testEndpointParameters
@ -146,7 +146,7 @@ class FakeApi extends Controller
$callback = $input['callback'];
return response('How about implementing testEndpointParameters as a POST method ?');
return response('How about implementing testEndpointParameters as a post method ?');
}
/**
* Operation testEnumParameters
@ -181,7 +181,60 @@ class FakeApi extends Controller
$enum_query_double = $input['enum_query_double'];
return response('How about implementing testEnumParameters as a GET method ?');
return response('How about implementing testEnumParameters as a get method ?');
}
/**
* Operation testInlineAdditionalProperties
*
* test inline additionalProperties.
*
*
* @return Http response
*/
public function testInlineAdditionalProperties()
{
$input = Request::all();
//path params validation
//not path params validation
if (!isset($input['param'])) {
throw new \InvalidArgumentException('Missing the required parameter $param when calling testInlineAdditionalProperties');
}
$param = $input['param'];
return response('How about implementing testInlineAdditionalProperties as a post method ?');
}
/**
* Operation testJsonFormData
*
* test json serialization of form data.
*
*
* @return Http response
*/
public function testJsonFormData()
{
$input = Request::all();
//path params validation
//not path params validation
if (!isset($input['param'])) {
throw new \InvalidArgumentException('Missing the required parameter $param when calling testJsonFormData');
}
$param = $input['param'];
if (!isset($input['param2'])) {
throw new \InvalidArgumentException('Missing the required parameter $param2 when calling testJsonFormData');
}
$param2 = $input['param2'];
return response('How about implementing testJsonFormData as a get method ?');
}
/**
* Operation fakeOuterBooleanSerialize
@ -202,7 +255,7 @@ class FakeApi extends Controller
$body = $input['body'];
return response('How about implementing fakeOuterBooleanSerialize as a POST method ?');
return response('How about implementing fakeOuterBooleanSerialize as a post method ?');
}
/**
* Operation fakeOuterCompositeSerialize
@ -223,7 +276,7 @@ class FakeApi extends Controller
$body = $input['body'];
return response('How about implementing fakeOuterCompositeSerialize as a POST method ?');
return response('How about implementing fakeOuterCompositeSerialize as a post method ?');
}
/**
* Operation fakeOuterNumberSerialize
@ -244,7 +297,7 @@ class FakeApi extends Controller
$body = $input['body'];
return response('How about implementing fakeOuterNumberSerialize as a POST method ?');
return response('How about implementing fakeOuterNumberSerialize as a post method ?');
}
/**
* Operation fakeOuterStringSerialize
@ -265,6 +318,6 @@ class FakeApi extends Controller
$body = $input['body'];
return response('How about implementing fakeOuterStringSerialize as a POST method ?');
return response('How about implementing fakeOuterStringSerialize as a post method ?');
}
}

View File

@ -0,0 +1,53 @@
<?php
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Request;
class FakeClassnameTags123Api extends Controller
{
/**
* Constructor
*/
public function __construct()
{
}
/**
* Operation testClassname
*
* To test class name in snake case.
*
*
* @return Http response
*/
public function testClassname()
{
$input = Request::all();
//path params validation
//not path params validation
if (!isset($input['body'])) {
throw new \InvalidArgumentException('Missing the required parameter $body when calling testClassname');
}
$body = $input['body'];
return response('How about implementing testClassname as a patch method ?');
}
}

View File

@ -48,7 +48,7 @@ class PetApi extends Controller
$body = $input['body'];
return response('How about implementing addPet as a POST method ?');
return response('How about implementing addPet as a post method ?');
}
/**
* Operation updatePet
@ -72,7 +72,7 @@ class PetApi extends Controller
$body = $input['body'];
return response('How about implementing updatePet as a PUT method ?');
return response('How about implementing updatePet as a put method ?');
}
/**
* Operation findPetsByStatus
@ -96,7 +96,7 @@ class PetApi extends Controller
$status = $input['status'];
return response('How about implementing findPetsByStatus as a GET method ?');
return response('How about implementing findPetsByStatus as a get method ?');
}
/**
* Operation findPetsByTags
@ -120,7 +120,7 @@ class PetApi extends Controller
$tags = $input['tags'];
return response('How about implementing findPetsByTags as a GET method ?');
return response('How about implementing findPetsByTags as a get method ?');
}
/**
* Operation deletePet
@ -140,7 +140,7 @@ class PetApi extends Controller
//not path params validation
return response('How about implementing deletePet as a DELETE method ?');
return response('How about implementing deletePet as a delete method ?');
}
/**
* Operation getPetById
@ -160,7 +160,7 @@ class PetApi extends Controller
//not path params validation
return response('How about implementing getPetById as a GET method ?');
return response('How about implementing getPetById as a get method ?');
}
/**
* Operation updatePetWithForm
@ -180,7 +180,7 @@ class PetApi extends Controller
//not path params validation
return response('How about implementing updatePetWithForm as a POST method ?');
return response('How about implementing updatePetWithForm as a post method ?');
}
/**
* Operation uploadFile
@ -200,6 +200,6 @@ class PetApi extends Controller
//not path params validation
return response('How about implementing uploadFile as a POST method ?');
return response('How about implementing uploadFile as a post method ?');
}
}

View File

@ -43,7 +43,7 @@ class StoreApi extends Controller
//not path params validation
return response('How about implementing getInventory as a GET method ?');
return response('How about implementing getInventory as a get method ?');
}
/**
* Operation placeOrder
@ -67,7 +67,7 @@ class StoreApi extends Controller
$body = $input['body'];
return response('How about implementing placeOrder as a POST method ?');
return response('How about implementing placeOrder as a post method ?');
}
/**
* Operation deleteOrder
@ -87,7 +87,7 @@ class StoreApi extends Controller
//not path params validation
return response('How about implementing deleteOrder as a DELETE method ?');
return response('How about implementing deleteOrder as a delete method ?');
}
/**
* Operation getOrderById
@ -113,6 +113,6 @@ class StoreApi extends Controller
//not path params validation
return response('How about implementing getOrderById as a GET method ?');
return response('How about implementing getOrderById as a get method ?');
}
}

View File

@ -48,7 +48,7 @@ class UserApi extends Controller
$body = $input['body'];
return response('How about implementing createUser as a POST method ?');
return response('How about implementing createUser as a post method ?');
}
/**
* Operation createUsersWithArrayInput
@ -72,7 +72,7 @@ class UserApi extends Controller
$body = $input['body'];
return response('How about implementing createUsersWithArrayInput as a POST method ?');
return response('How about implementing createUsersWithArrayInput as a post method ?');
}
/**
* Operation createUsersWithListInput
@ -96,7 +96,7 @@ class UserApi extends Controller
$body = $input['body'];
return response('How about implementing createUsersWithListInput as a POST method ?');
return response('How about implementing createUsersWithListInput as a post method ?');
}
/**
* Operation loginUser
@ -125,7 +125,7 @@ class UserApi extends Controller
$password = $input['password'];
return response('How about implementing loginUser as a GET method ?');
return response('How about implementing loginUser as a get method ?');
}
/**
* Operation logoutUser
@ -144,7 +144,7 @@ class UserApi extends Controller
//not path params validation
return response('How about implementing logoutUser as a GET method ?');
return response('How about implementing logoutUser as a get method ?');
}
/**
* Operation deleteUser
@ -164,7 +164,7 @@ class UserApi extends Controller
//not path params validation
return response('How about implementing deleteUser as a DELETE method ?');
return response('How about implementing deleteUser as a delete method ?');
}
/**
* Operation getUserByName
@ -184,7 +184,7 @@ class UserApi extends Controller
//not path params validation
return response('How about implementing getUserByName as a GET method ?');
return response('How about implementing getUserByName as a get method ?');
}
/**
* Operation updateUser
@ -204,6 +204,6 @@ class UserApi extends Controller
//not path params validation
return response('How about implementing updateUser as a PUT method ?');
return response('How about implementing updateUser as a put method ?');
}
}

View File

@ -22,199 +22,220 @@ $app->get('/', function () use ($app) {
});
/**
* PATCH testClientModel
* patch testSpecialTags
* Summary: To test special tags
* Notes: To test special tags
* Output-Formats: [application/json]
*/
$app->patch('/v2/another-fake/dummy', 'AnotherFakeApi@testSpecialTags');
/**
* patch testClientModel
* Summary: To test \&quot;client\&quot; model
* Notes: To test \&quot;client\&quot; model
* Output-Formats: [application/json]
*/
$app->PATCH('/v2/fake', 'FakeApi@testClientModel');
$app->patch('/v2/fake', 'FakeApi@testClientModel');
/**
* POST testEndpointParameters
* 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('/v2/fake', 'FakeApi@testEndpointParameters');
$app->post('/v2/fake', 'FakeApi@testEndpointParameters');
/**
* GET testEnumParameters
* get testEnumParameters
* Summary: To test enum parameters
* Notes: To test enum parameters
* Output-Formats: [*/*]
*/
$app->GET('/v2/fake', 'FakeApi@testEnumParameters');
$app->get('/v2/fake', 'FakeApi@testEnumParameters');
/**
* POST fakeOuterBooleanSerialize
* post testInlineAdditionalProperties
* Summary: test inline additionalProperties
* Notes:
*/
$app->post('/v2/fake/inline-additionalProperties', 'FakeApi@testInlineAdditionalProperties');
/**
* get testJsonFormData
* Summary: test json serialization of form data
* Notes:
*/
$app->get('/v2/fake/jsonFormData', 'FakeApi@testJsonFormData');
/**
* post fakeOuterBooleanSerialize
* Summary:
* Notes: Test serialization of outer boolean types
*/
$app->POST('/v2/fake/outer/boolean', 'FakeApi@fakeOuterBooleanSerialize');
$app->post('/v2/fake/outer/boolean', 'FakeApi@fakeOuterBooleanSerialize');
/**
* POST fakeOuterCompositeSerialize
* post fakeOuterCompositeSerialize
* Summary:
* Notes: Test serialization of object with outer number type
*/
$app->POST('/v2/fake/outer/composite', 'FakeApi@fakeOuterCompositeSerialize');
$app->post('/v2/fake/outer/composite', 'FakeApi@fakeOuterCompositeSerialize');
/**
* POST fakeOuterNumberSerialize
* post fakeOuterNumberSerialize
* Summary:
* Notes: Test serialization of outer number types
*/
$app->POST('/v2/fake/outer/number', 'FakeApi@fakeOuterNumberSerialize');
$app->post('/v2/fake/outer/number', 'FakeApi@fakeOuterNumberSerialize');
/**
* POST fakeOuterStringSerialize
* post fakeOuterStringSerialize
* Summary:
* Notes: Test serialization of outer string types
*/
$app->POST('/v2/fake/outer/string', 'FakeApi@fakeOuterStringSerialize');
$app->post('/v2/fake/outer/string', 'FakeApi@fakeOuterStringSerialize');
/**
* PATCH testClassname
* patch testClassname
* Summary: To test class name in snake case
* Notes:
* Output-Formats: [application/json]
*/
$app->PATCH('/v2/fake_classname_test', 'Fake_classname_tags123Api@testClassname');
$app->patch('/v2/fake_classname_test', 'FakeClassnameTags123Api@testClassname');
/**
* POST addPet
* post addPet
* Summary: Add a new pet to the store
* Notes:
* Output-Formats: [application/xml, application/json]
*/
$app->POST('/v2/pet', 'PetApi@addPet');
$app->post('/v2/pet', 'PetApi@addPet');
/**
* PUT updatePet
* put updatePet
* Summary: Update an existing pet
* Notes:
* Output-Formats: [application/xml, application/json]
*/
$app->PUT('/v2/pet', 'PetApi@updatePet');
$app->put('/v2/pet', 'PetApi@updatePet');
/**
* GET findPetsByStatus
* 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('/v2/pet/findByStatus', 'PetApi@findPetsByStatus');
$app->get('/v2/pet/findByStatus', 'PetApi@findPetsByStatus');
/**
* GET findPetsByTags
* 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('/v2/pet/findByTags', 'PetApi@findPetsByTags');
$app->get('/v2/pet/findByTags', 'PetApi@findPetsByTags');
/**
* DELETE deletePet
* delete deletePet
* Summary: Deletes a pet
* Notes:
* Output-Formats: [application/xml, application/json]
*/
$app->DELETE('/v2/pet/{petId}', 'PetApi@deletePet');
$app->delete('/v2/pet/{petId}', 'PetApi@deletePet');
/**
* GET getPetById
* get getPetById
* Summary: Find pet by ID
* Notes: Returns a single pet
* Output-Formats: [application/xml, application/json]
*/
$app->GET('/v2/pet/{petId}', 'PetApi@getPetById');
$app->get('/v2/pet/{petId}', 'PetApi@getPetById');
/**
* POST updatePetWithForm
* post updatePetWithForm
* Summary: Updates a pet in the store with form data
* Notes:
* Output-Formats: [application/xml, application/json]
*/
$app->POST('/v2/pet/{petId}', 'PetApi@updatePetWithForm');
$app->post('/v2/pet/{petId}', 'PetApi@updatePetWithForm');
/**
* POST uploadFile
* post uploadFile
* Summary: uploads an image
* Notes:
* Output-Formats: [application/json]
*/
$app->POST('/v2/pet/{petId}/uploadImage', 'PetApi@uploadFile');
$app->post('/v2/pet/{petId}/uploadImage', 'PetApi@uploadFile');
/**
* GET getInventory
* get getInventory
* Summary: Returns pet inventories by status
* Notes: Returns a map of status codes to quantities
* Output-Formats: [application/json]
*/
$app->GET('/v2/store/inventory', 'StoreApi@getInventory');
$app->get('/v2/store/inventory', 'StoreApi@getInventory');
/**
* POST placeOrder
* post placeOrder
* Summary: Place an order for a pet
* Notes:
* Output-Formats: [application/xml, application/json]
*/
$app->POST('/v2/store/order', 'StoreApi@placeOrder');
$app->post('/v2/store/order', 'StoreApi@placeOrder');
/**
* DELETE deleteOrder
* delete deleteOrder
* Summary: Delete purchase order by ID
* Notes: For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* Output-Formats: [application/xml, application/json]
*/
$app->DELETE('/v2/store/order/{order_id}', 'StoreApi@deleteOrder');
$app->delete('/v2/store/order/{order_id}', 'StoreApi@deleteOrder');
/**
* GET getOrderById
* get getOrderById
* Summary: Find purchase order by ID
* Notes: For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* Output-Formats: [application/xml, application/json]
*/
$app->GET('/v2/store/order/{order_id}', 'StoreApi@getOrderById');
$app->get('/v2/store/order/{order_id}', 'StoreApi@getOrderById');
/**
* POST createUser
* post createUser
* Summary: Create user
* Notes: This can only be done by the logged in user.
* Output-Formats: [application/xml, application/json]
*/
$app->POST('/v2/user', 'UserApi@createUser');
$app->post('/v2/user', 'UserApi@createUser');
/**
* POST createUsersWithArrayInput
* post createUsersWithArrayInput
* Summary: Creates list of users with given input array
* Notes:
* Output-Formats: [application/xml, application/json]
*/
$app->POST('/v2/user/createWithArray', 'UserApi@createUsersWithArrayInput');
$app->post('/v2/user/createWithArray', 'UserApi@createUsersWithArrayInput');
/**
* POST createUsersWithListInput
* post createUsersWithListInput
* Summary: Creates list of users with given input array
* Notes:
* Output-Formats: [application/xml, application/json]
*/
$app->POST('/v2/user/createWithList', 'UserApi@createUsersWithListInput');
$app->post('/v2/user/createWithList', 'UserApi@createUsersWithListInput');
/**
* GET loginUser
* get loginUser
* Summary: Logs user into the system
* Notes:
* Output-Formats: [application/xml, application/json]
*/
$app->GET('/v2/user/login', 'UserApi@loginUser');
$app->get('/v2/user/login', 'UserApi@loginUser');
/**
* GET logoutUser
* get logoutUser
* Summary: Logs out current logged in user session
* Notes:
* Output-Formats: [application/xml, application/json]
*/
$app->GET('/v2/user/logout', 'UserApi@logoutUser');
$app->get('/v2/user/logout', 'UserApi@logoutUser');
/**
* DELETE deleteUser
* delete deleteUser
* Summary: Delete user
* Notes: This can only be done by the logged in user.
* Output-Formats: [application/xml, application/json]
*/
$app->DELETE('/v2/user/{username}', 'UserApi@deleteUser');
$app->delete('/v2/user/{username}', 'UserApi@deleteUser');
/**
* GET getUserByName
* get getUserByName
* Summary: Get user by user name
* Notes:
* Output-Formats: [application/xml, application/json]
*/
$app->GET('/v2/user/{username}', 'UserApi@getUserByName');
$app->get('/v2/user/{username}', 'UserApi@getUserByName');
/**
* PUT updateUser
* put updateUser
* Summary: Updated user
* Notes: This can only be done by the logged in user.
* Output-Formats: [application/xml, application/json]
*/
$app->PUT('/v2/user/{username}', 'UserApi@updateUser');
$app->put('/v2/user/{username}', 'UserApi@updateUser');