From 5d3a24800e77133efecb8c1e0a06502143e1a27b Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 8 Nov 2015 23:53:13 +0200 Subject: [PATCH] Working on Swagger --- app/Http/Controllers/InvoiceApiController.php | 23 ++++++++++++ app/Http/Controllers/PaymentApiController.php | 37 +++++++++++++++++++ app/Http/Controllers/QuoteApiController.php | 16 ++++++++ app/Http/Controllers/TaskApiController.php | 37 +++++++++++++++++++ app/Ninja/Transformers/InvoiceTransformer.php | 8 ++-- 5 files changed, 117 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/InvoiceApiController.php b/app/Http/Controllers/InvoiceApiController.php index 26b28fae0bc6..268a547e573b 100644 --- a/app/Http/Controllers/InvoiceApiController.php +++ b/app/Http/Controllers/InvoiceApiController.php @@ -28,6 +28,7 @@ class InvoiceApiController extends Controller * @SWG\Get( * path="/invoices", * summary="List of invoices", + * tags={"invoice"}, * @SWG\Response( * response=200, * description="A list with invoices", @@ -69,6 +70,28 @@ class InvoiceApiController extends Controller return Response::make($response, 200, $headers); } + + /** + * @SWG\Post( + * path="/invoices", + * tags={"invoice"}, + * summary="Create an invoice", + * @SWG\Parameter( + * in="body", + * name="body", + * @SWG\Schema(ref="#/definitions/Invoice") + * ), + * @SWG\Response( + * response=200, + * description="Newly created invoice", + * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Invoice")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ public function store() { $data = Input::all(); diff --git a/app/Http/Controllers/PaymentApiController.php b/app/Http/Controllers/PaymentApiController.php index d83fcac494c8..f23a26969fb0 100644 --- a/app/Http/Controllers/PaymentApiController.php +++ b/app/Http/Controllers/PaymentApiController.php @@ -16,6 +16,22 @@ class PaymentApiController extends Controller $this->paymentRepo = $paymentRepo; } + /** + * @SWG\Get( + * path="/payments", + * tags={"payment"}, + * summary="List of payments", + * @SWG\Response( + * response=200, + * description="A list with payments", + * @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Payment")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ public function index($clientPublicId = false) { $payments = Payment::scope() @@ -37,6 +53,27 @@ class PaymentApiController extends Controller } + /** + * @SWG\Post( + * path="/payments", + * summary="Create a payment", + * tags={"payment"}, + * @SWG\Parameter( + * in="body", + * name="body", + * @SWG\Schema(ref="#/definitions/Payment") + * ), + * @SWG\Response( + * response=200, + * description="New payment", + * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Payment")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ public function store() { $data = Input::all(); diff --git a/app/Http/Controllers/QuoteApiController.php b/app/Http/Controllers/QuoteApiController.php index 24fd1639215f..055f718fb179 100644 --- a/app/Http/Controllers/QuoteApiController.php +++ b/app/Http/Controllers/QuoteApiController.php @@ -14,6 +14,22 @@ class QuoteApiController extends Controller $this->invoiceRepo = $invoiceRepo; } + /** + * @SWG\Get( + * path="/quotes", + * tags={"quote"}, + * summary="List of quotes", + * @SWG\Response( + * response=200, + * description="A list with quotes", + * @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Invoice")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ public function index($clientPublicId = false) { $invoices = Invoice::scope() diff --git a/app/Http/Controllers/TaskApiController.php b/app/Http/Controllers/TaskApiController.php index c15ea9fb659a..ddbd11f7ae92 100644 --- a/app/Http/Controllers/TaskApiController.php +++ b/app/Http/Controllers/TaskApiController.php @@ -15,6 +15,22 @@ class TaskApiController extends Controller $this->taskRepo = $taskRepo; } + /** + * @SWG\Get( + * path="/tasks", + * tags={"task"}, + * summary="List of tasks", + * @SWG\Response( + * response=200, + * description="A list with tasks", + * @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Task")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ public function index($clientPublicId = false) { $tasks = Task::scope()->with('client'); @@ -34,6 +50,27 @@ class TaskApiController extends Controller return Response::make($response, 200, $headers); } + /** + * @SWG\Post( + * path="/tasks", + * tags={"task"}, + * summary="Create a task", + * @SWG\Parameter( + * in="body", + * name="body", + * @SWG\Schema(ref="#/definitions/Task") + * ), + * @SWG\Response( + * response=200, + * description="New task", + * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Task")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ public function store() { $data = Input::all(); diff --git a/app/Ninja/Transformers/InvoiceTransformer.php b/app/Ninja/Transformers/InvoiceTransformer.php index d49e592924be..4cc751e62e6e 100644 --- a/app/Ninja/Transformers/InvoiceTransformer.php +++ b/app/Ninja/Transformers/InvoiceTransformer.php @@ -12,11 +12,11 @@ use League\Fractal; class InvoiceTransformer extends EntityTransformer { /** - * @SWG\Property(property="id", type="integer", example=1) - * @SWG\Property(property="invoice_number", type="string", example="0001") - * @SWG\Property(property="amount", type="float", example=10) - * @SWG\Property(property="balance", type="float", example=10) + * @SWG\Property(property="id", type="integer", example=1, readOnly=true) + * @SWG\Property(property="amount", type="float", example=10, readOnly=true) + * @SWG\Property(property="balance", type="float", example=10, readOnly=true) * @SWG\Property(property="client_id", type="integer", example=1) + * @SWG\Property(property="invoice_number", type="string", example="0001") * @SWG\Property(property="invoice_status_id", type="integer", example=1) */