Working on Swagger

This commit is contained in:
Hillel Coren 2015-11-08 23:57:28 +02:00
parent 5d3a24800e
commit 0524f53850
4 changed files with 49 additions and 2 deletions

View File

@ -23,6 +23,22 @@ class ClientApiController extends Controller
return Response::make('', 200, $headers); return Response::make('', 200, $headers);
} }
/**
* @SWG\Get(
* path="/clients",
* summary="List of clients",
* tags={"client"},
* @SWG\Response(
* response=200,
* description="A list with clients",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Client"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function index() public function index()
{ {
$clients = Client::scope() $clients = Client::scope()
@ -37,6 +53,27 @@ class ClientApiController extends Controller
return Response::make($response, 200, $headers); return Response::make($response, 200, $headers);
} }
/**
* @SWG\Post(
* path="/clients",
* tags={"client"},
* summary="Create a client",
* @SWG\Parameter(
* in="body",
* name="body",
* @SWG\Schema(ref="#/definitions/Client")
* ),
* @SWG\Response(
* response=200,
* description="New client",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Client"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function store(CreateClientRequest $request) public function store(CreateClientRequest $request)
{ {
$client = $this->clientRepo->save($request->input()); $client = $this->clientRepo->save($request->input());

View File

@ -83,7 +83,7 @@ class InvoiceApiController extends Controller
* ), * ),
* @SWG\Response( * @SWG\Response(
* response=200, * response=200,
* description="Newly created invoice", * description="New invoice",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Invoice")) * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Invoice"))
* ), * ),
* @SWG\Response( * @SWG\Response(

View File

@ -5,8 +5,18 @@ use App\Models\Client;
use App\Models\Contact; use App\Models\Contact;
use League\Fractal; use League\Fractal;
/**
* @SWG\Definition(definition="Client", @SWG\Xml(name="Client"))
*/
class ClientTransformer extends EntityTransformer class ClientTransformer extends EntityTransformer
{ {
/**
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="balance", type="float", example=10, readOnly=true)
* @SWG\Property(property="paid_to_date", type="float", example=10, readOnly=true)
*/
protected $defaultIncludes = [ protected $defaultIncludes = [
'contacts', 'contacts',
'invoices', 'invoices',