Skip to content

Commit

Permalink
Add Swagger annotations on IncidentController
Browse files Browse the repository at this point in the history
Swagger annotations were added on IncidentController.
Also a typo has been fixed ComponentControlelr.

See: cachethq/docs#4
  • Loading branch information
nalysius committed Jun 2, 2018
1 parent c7bfdd1 commit 919fe65
Show file tree
Hide file tree
Showing 2 changed files with 169 additions and 30 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/ComponentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function show(Component $component)
* ),
* @SWG\Response(
* response=400,
* description="Invalid ccomponent."
* description="Invalid component."
* )
* )
*
Expand Down
197 changes: 168 additions & 29 deletions app/Http/Controllers/Api/IncidentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,49 @@ class IncidentController extends AbstractApiController
/**
* Get all incidents.
*
* The following searchable keys are available:
* - `id`
* - `component_id`
* - `name`
* - `status`
* - `visible`
*
* @return \Illuminate\Http\JsonResponse
*
* @SWG\Get(
* path="/incidents",
* summary="List all incidents.",
* operationId="Incident@index",
* tags={"Incidents"},
* produces={"application/json"},
* @SWG\Parameter(
* description="Minimum visibility of the incidents.",
* in="query",
* name="visible",
* required=false,
* type="integer",
* format="int64"
* ),
* @SWG\Parameter(
* description="The field on which sort the results.",
* in="query",
* name="sort",
* required=false,
* type="string"
* ),
* @SWG\Parameter(
* description="The direction on which sort the results. 'asc' or 'desc'.",
* in="query",
* name="order",
* required=false,
* type="string"
* ),
* @SWG\Parameter(
* description="The number of items to get. Default to 20.",
* in="query",
* name="per_page",
* required=false,
* type="integer",
* format="int64"
* ),
* @SWG\Response(
* response=200,
* description="A list with all incidents."
* )
* )
*/
public function index()
{
Expand All @@ -62,15 +97,34 @@ public function index()
/**
* Get a single incident.
*
* **Path Params:**
*
* Name | Type | Required | Description
* -----|------|------------|---------
* incident | int32 | Y | ID of the incident
*
* @param \CachetHQ\Cachet\Models\Incident $incident
*
* @return \Illuminate\Http\JsonResponse
*
* @SWG\Get(
* path="/incidents/{incident}",
* summary="Get a single incident.",
* description="",
* operationId="Incident@show",
* produces={"application/json"},
* tags={"Incidents"},
* @SWG\Parameter(
* name="incident",
* in="path",
* description="The incident identifier.",
* required=true,
* type="integer",
* format="int64"
* ),
* @SWG\Response(
* response=200,
* description="The incident."
* ),
* @SWG\Response(
* response="404",
* description="Incident not found."
* )
* )
*/
public function show(Incident $incident)
{
Expand All @@ -80,23 +134,108 @@ public function show(Incident $incident)
/**
* Create a new incident.
*
* **Body params:**
*
* Name | Type | Required | Description
* -----|------|------------|----------
* name | string | Y | Name of the incident
* message | string | Y | A message (supporting Markdown) to explain more
* status | int32 | Y | Status of the incident
* component_id | int32 | Y | Component to update (required with component_status)
* component_status | int32 | Y | The status to update the given component with
* visible | int32 | N | Whether the incident is publicly visible
* notify | boolean | N | Whether to notify subscribers
* stickied | boolean | N |Should the incident be stickied
* template | string | The template slug to use
* vars | string[] | N | The variables to pass to the template
* meta | string[] | N | The meta
*
* @return \Illuminate\Http\JsonResponse
*
* @SWG\Post(
* path="/incidents",
* tags={"Incidents"},
* operationId="Incident@store",
* summary="Add a new incident.",
* description="",
* consumes={"multipart/form-data"},
* produces={"application/json"},
* @SWG\Parameter(
* name="name",
* in="formData",
* type="string",
* description="Name of the incident.",
* required=true
* ),
* @SWG\Parameter(
* name="message",
* in="formData",
* type="string",
* description="A message (supporting Markdown) to explain more.",
* required=true
* ),
* @SWG\Parameter(
* name="status",
* in="formData",
* type="integer",
* description="Status of the incident.",
* required=true
* ),
* @SWG\Parameter(
* name="component_id",
* in="formData",
* type="integer",
* description="Component to update.",
* required=true
* ),
* @SWG\Parameter(
* name="component_status",
* in="formData",
* type="integer",
* description="The status to update the given component with.",
* required=true
* ),
* @SWG\Parameter(
* name="occured_at",
* in="formData",
* type="string",
* description="The date/time when the incident occured.",
* required=true
* ),
* @SWG\Parameter(
* name="template",
* in="formData",
* type="string",
* description="The templace slug to use.",
* required=true
* ),
* @SWG\Parameter(
* name="notify",
* in="formData",
* type="boolean",
* description="Whether to notify subscribers. Default true.",
* required=false
* ),
* @SWG\Parameter(
* name="stickied",
* in="formData",
* type="integer",
* description="Should the incident be stickied? Default false.",
* required=false
* ),
* @SWG\Parameter(
* name="vars",
* in="formData",
* type="array",
* description="",
* required=false,
* @SWG\Items(
* type="string"
* )
* ),
* @SWG\Parameter(
* name="meta",
* in="formData",
* type="array",
* description="",
* required=false,
* @SWG\Items(
* type="string"
* )
* ),
* @SWG\Response(
* response=200,
* description="The incident."
* ),
* @SWG\Response(
* response=400,
* description="Invalid incident."
* )
* )
*/
public function store()
{
Expand Down

0 comments on commit 919fe65

Please sign in to comment.