forked from loafle/openapi-generator-original
Added notes, output formats, header params and body params
This commit is contained in:
@@ -10,13 +10,17 @@ $app = new Slim\App();
|
||||
|
||||
{{#apis}}{{#operations}}{{#operation}}
|
||||
/**
|
||||
* {{httpMethod}} {{baseName}}
|
||||
* {{summary}}
|
||||
* {{httpMethod}} {{nickname}}
|
||||
* Summary: {{summary}}
|
||||
* Notes: {{notes}}
|
||||
{{#hasProduces}} * Output-Formats: [{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
|
||||
*/
|
||||
$app->{{httpMethod}}('{{path}}', function($request, $response, $args) {
|
||||
{{#hasHeaderParams}}$headers = $request->getHeaders();{{/hasHeaderParams}}
|
||||
{{#hasQueryParams}}$queryParams = $request->getQueryParams();
|
||||
{{#queryParams}}${{paramName}} = $queryParams['{{paramName}}'];{{newline}} {{/queryParams}}{{/hasQueryParams}}
|
||||
{{#hasFormParams}}{{#formParams}}${{paramName}} = $args['{{paramName}}'];{{newline}} {{/formParams}}{{/hasFormParams}}
|
||||
{{#queryParams}}$qp_{{paramName}} = $queryParams['{{paramName}}'];{{newline}} {{/queryParams}}{{/hasQueryParams}}
|
||||
{{#hasFormParams}}{{#formParams}}$fp_{{paramName}} = $args['{{paramName}}'];{{newline}} {{/formParams}}{{/hasFormParams}}
|
||||
{{#hasBodyParam}}$body = $request->getParsedBody();{{/hasBodyParam}}
|
||||
$response->write('How about implementing {{nickname}} as a {{httpMethod}} method ?');
|
||||
return $response;
|
||||
});
|
||||
|
||||
@@ -10,48 +10,64 @@ $app = new Slim\App();
|
||||
|
||||
|
||||
/**
|
||||
* POST User
|
||||
* Create user
|
||||
* 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', function($request, $response, $args) {
|
||||
|
||||
|
||||
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing createUser as a POST method ?');
|
||||
return $response;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* POST User
|
||||
* Creates list of users with given input array
|
||||
* POST createUsersWithArrayInput
|
||||
* Summary: Creates list of users with given input array
|
||||
* Notes:
|
||||
* Output-Formats: [application/xml, application/json]
|
||||
*/
|
||||
$app->POST('/user/createWithArray', function($request, $response, $args) {
|
||||
|
||||
|
||||
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing createUsersWithArrayInput as a POST method ?');
|
||||
return $response;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* POST User
|
||||
* Creates list of users with given input array
|
||||
* POST createUsersWithListInput
|
||||
* Summary: Creates list of users with given input array
|
||||
* Notes:
|
||||
* Output-Formats: [application/xml, application/json]
|
||||
*/
|
||||
$app->POST('/user/createWithList', function($request, $response, $args) {
|
||||
|
||||
|
||||
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing createUsersWithListInput as a POST method ?');
|
||||
return $response;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* GET User
|
||||
* Logs user into the system
|
||||
* GET loginUser
|
||||
* Summary: Logs user into the system
|
||||
* Notes:
|
||||
* Output-Formats: [application/xml, application/json]
|
||||
*/
|
||||
$app->GET('/user/login', function($request, $response, $args) {
|
||||
|
||||
$queryParams = $request->getQueryParams();
|
||||
$username = $queryParams['username']; $password = $queryParams['password'];
|
||||
$qp_username = $queryParams['username']; $qp_password = $queryParams['password'];
|
||||
|
||||
|
||||
$response->write('How about implementing loginUser as a GET method ?');
|
||||
return $response;
|
||||
@@ -59,132 +75,176 @@ $app->GET('/user/login', function($request, $response, $args) {
|
||||
|
||||
|
||||
/**
|
||||
* GET User
|
||||
* Logs out current logged in user session
|
||||
* GET logoutUser
|
||||
* Summary: Logs out current logged in user session
|
||||
* Notes:
|
||||
* Output-Formats: [application/xml, application/json]
|
||||
*/
|
||||
$app->GET('/user/logout', function($request, $response, $args) {
|
||||
|
||||
|
||||
|
||||
|
||||
$response->write('How about implementing logoutUser as a GET method ?');
|
||||
return $response;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* GET User
|
||||
* Get user by user name
|
||||
* 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;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* PUT User
|
||||
* Updated user
|
||||
* 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}', function($request, $response, $args) {
|
||||
|
||||
|
||||
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing updateUser as a PUT method ?');
|
||||
return $response;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* DELETE User
|
||||
* Delete user
|
||||
* 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 Store
|
||||
* Returns pet inventories by status
|
||||
* 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 Store
|
||||
* Place an order for a pet
|
||||
* 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 Store
|
||||
* Find purchase order by ID
|
||||
* 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 Store
|
||||
* Delete purchase order by ID
|
||||
* 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 Pet
|
||||
* Update an existing pet
|
||||
* 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 Pet
|
||||
* Add a new pet to the store
|
||||
* 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;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* GET Pet
|
||||
* Finds Pets by status
|
||||
* GET findPetsByStatus
|
||||
* Summary: Finds Pets by status
|
||||
* Notes: Multiple status values can be provided with comma seperated strings
|
||||
* Output-Formats: [application/xml, application/json]
|
||||
*/
|
||||
$app->GET('/pet/findByStatus', function($request, $response, $args) {
|
||||
|
||||
$queryParams = $request->getQueryParams();
|
||||
$status = $queryParams['status'];
|
||||
$qp_status = $queryParams['status'];
|
||||
|
||||
|
||||
$response->write('How about implementing findPetsByStatus as a GET method ?');
|
||||
return $response;
|
||||
@@ -192,12 +252,16 @@ $app->GET('/pet/findByStatus', function($request, $response, $args) {
|
||||
|
||||
|
||||
/**
|
||||
* GET Pet
|
||||
* Finds Pets by tags
|
||||
* 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]
|
||||
*/
|
||||
$app->GET('/pet/findByTags', function($request, $response, $args) {
|
||||
|
||||
$queryParams = $request->getQueryParams();
|
||||
$tags = $queryParams['tags'];
|
||||
$qp_tags = $queryParams['tags'];
|
||||
|
||||
|
||||
$response->write('How about implementing findPetsByTags as a GET method ?');
|
||||
return $response;
|
||||
@@ -205,34 +269,46 @@ $app->GET('/pet/findByTags', function($request, $response, $args) {
|
||||
|
||||
|
||||
/**
|
||||
* GET Pet
|
||||
* Find pet by ID
|
||||
* 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;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* POST Pet
|
||||
* Updates a pet in the store with form data
|
||||
* 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'];
|
||||
|
||||
$fp_name = $args['name']; $fp_status = $args['status'];
|
||||
|
||||
$response->write('How about implementing updatePetWithForm as a POST method ?');
|
||||
return $response;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* DELETE Pet
|
||||
* Deletes a pet
|
||||
* 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 ?');
|
||||
@@ -241,12 +317,16 @@ $app->DELETE('/pet/{petId}', function($request, $response, $args) {
|
||||
|
||||
|
||||
/**
|
||||
* POST Pet
|
||||
* uploads an image
|
||||
* POST uploadFile
|
||||
* Summary: uploads an image
|
||||
* Notes:
|
||||
* Output-Formats: [application/json]
|
||||
*/
|
||||
$app->POST('/pet/{petId}/uploadImage', function($request, $response, $args) {
|
||||
|
||||
$additional_metadata = $args['additional_metadata']; $file = $args['file'];
|
||||
|
||||
$fp_additional_metadata = $args['additional_metadata']; $fp_file = $args['file'];
|
||||
|
||||
$response->write('How about implementing uploadFile as a POST method ?');
|
||||
return $response;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user