Skip to content

Instantly share code, notes, and snippets.

@erunion
Last active December 12, 2018 18:11
Show Gist options
  • Save erunion/2b8baa7f14b51141d1f163314486502d to your computer and use it in GitHub Desktop.
Save erunion/2b8baa7f14b51141d1f163314486502d to your computer and use it in GitHub Desktop.
Example API controller documented with vimeo/mill
<?php
namespace Vimeo\Controllers\Api;
use Vimeo\Api\Response\UserResponse;
class UserController extends \Vimeo\Controller
{
/**
* @api-label Get a user
* @api-operationId get_user
* @api-group Users\Essentials
*
* @api-path:public:alias /me
* @api-path:public /users/+user_id
* @api-pathParam user_id `152184` (integer) - The ID of the user.
*
* @api-contentType application/vnd.vimeo.user+json
*
* @api-return:public {object} \Vimeo\Api\Response\UserResponse The user was returned.
*/
public function GET(\Vimeo\Api\Request $request): UserResponse
{
return new UserResponse($request->getUser());
}
}
<?php
namespace Vimeo\Api\Response;
/**
* @api-label User
*/
class UserResponse extends Response
{
const CONTENT_TYPE = 'application/vnd.vimeo.user';
protected function _json($user)
{
return [
/**
* @api-data uri `/users/152184` (uri) - The user's canonical relative URI.
*/
'uri' => '/users/' . $user->id
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment