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);
}
/**
* @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()
{
$clients = Client::scope()
@ -37,6 +53,27 @@ class ClientApiController extends Controller
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)
{
$client = $this->clientRepo->save($request->input());

View File

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

View File

@ -5,8 +5,18 @@ use App\Models\Client;
use App\Models\Contact;
use League\Fractal;
/**
* @SWG\Definition(definition="Client", @SWG\Xml(name="Client"))
*/
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 = [
'contacts',
'invoices',

View File

@ -6,7 +6,7 @@ use App\Models\Invoice;
use League\Fractal;
/**
* @SWG\Definition(definition="Invoice",required={"invoice_number"}, @SWG\Xml(name="Invoice"))
* @SWG\Definition(definition="Invoice", required={"invoice_number"}, @SWG\Xml(name="Invoice"))
*/
class InvoiceTransformer extends EntityTransformer