Skip to content

Commit

Permalink
added support collection query string and swagger's summary for servi…
Browse files Browse the repository at this point in the history
…ce method
  • Loading branch information
Roman Bensman authored and Roman Bensman committed Feb 2, 2017
1 parent 26cf4e0 commit 023d81e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/ApiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ public function createApi($apiName, $apiVersion = 1)
$api->setName($apiName);

$serviceConfigs = [];
if ($this->config['zf-rest']) {
if (isset($this->config['zf-rest']) && !empty($this->config['zf-rest'])) {
$serviceConfigs = array_merge($serviceConfigs, $this->config['zf-rest']);
}
if ($this->config['zf-rpc']) {
if (isset($this->config['zf-rpc']) && !empty($this->config['zf-rpc'])) {
$serviceConfigs = array_merge($serviceConfigs, $this->config['zf-rpc']);
}

Expand Down Expand Up @@ -182,6 +182,9 @@ public function createService(Api $api, $serviceName)
return false;
}

// added service Collection Query String Whitelist
$service->setQueryWhitelist ($serviceData["collection_query_whitelist"]);

$authorizations = $this->getAuthorizations($serviceClassName);

$docsArray = $this->getDocumentationConfig($api->getName());
Expand Down Expand Up @@ -233,6 +236,12 @@ public function createService(Api $api, $serviceName)
: '';
$op->setRequestDescription($requestDescription);

// added support swagger summary option for collection's method
$requestSummary = isset($docsArray[$serviceClassName]['collection'][$httpMethod]['summary'])
? $docsArray[$serviceClassName]['collection'][$httpMethod]['summary']
: '';
$op->setSummary($requestSummary) ;

$responseDescription = isset($docsArray[$serviceClassName]['collection'][$httpMethod]['response'])
? $docsArray[$serviceClassName]['collection'][$httpMethod]['response']
: '';
Expand Down Expand Up @@ -303,6 +312,12 @@ public function createService(Api $api, $serviceName)
: '';
$op->setRequestDescription($requestDescription);

// add supprt swagger summary option for entity's methods
$requestSummary = isset($docsArray[$serviceClassName]['entity'][$httpMethod]['summary'])
? $docsArray[$serviceClassName]['entity'][$httpMethod]['summary']
: '';
$op->setSummary($requestSummary) ;

$responseDescription = isset($docsArray[$serviceClassName]['entity'][$httpMethod]['response'])
? $docsArray[$serviceClassName]['entity'][$httpMethod]['response']
: '';
Expand Down
23 changes: 23 additions & 0 deletions src/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ class Operation implements IteratorAggregate
*/
protected $responseStatusCodes = [];

/**
* Possible summary support for swagger
*
* @var string
*/
protected $summary;

/**
* @param string $httpMethod
*/
Expand Down Expand Up @@ -141,6 +148,22 @@ public function getResponseStatusCodes()
return $this->responseStatusCodes;
}

/**
* @param string $summary
*/
public function setSummary($summary)
{
$this->summary = $summary;
}

/**
* @return array
*/
public function getSummary()
{
return $this->summary;
}

/**
* Cast object to array
*
Expand Down
23 changes: 23 additions & 0 deletions src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class Service implements IteratorAggregate
*/
protected $fields = [];

/**
* @var array
*/
protected $queryWhitelist = [];

/**
* @param \ZF\Apigility\Documentation\Api $api
*/
Expand Down Expand Up @@ -242,6 +247,24 @@ public function getFields($type)
return isset($this->fields[$type]) ? $this->fields[$type] : [];
}

/**
* @param $queryWhitelist
* @return array
*/
public function setQueryWhitelist($queryWhitelist)
{
return $this->queryWhitelist = $queryWhitelist;
}

/**
*
* @return array
*/
public function getQueryWhitelist()
{
return isset($this->queryWhitelist) ? $this->queryWhitelist : [];
}

/**
* Cast object to array
*
Expand Down

1 comment on commit 023d81e

@reuven770
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to support collection query list in swagger
screen shot 2017-02-02 at 12 33 00 pm
screen shot 2017-02-02 at 12 34 22 pm
Also added summary to show swagger summary option for service method
screen shot 2017-02-02 at 12 38 23 pm

Please sign in to comment.