Skip to content

Commit

Permalink
added possibility use collection query string and service merhod summ…
Browse files Browse the repository at this point in the history
…ary name
  • Loading branch information
Roman Bensman authored and Roman Bensman committed Feb 2, 2017
1 parent 998a1a6 commit bed9409
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions src/Service.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ public function toArray()

protected function getTags()
{

return [
$this->cleanEmptyValues([
'name' => $this->service->getName(),
'name' => $this->service->getName() ,
'description' => $this->service->getDescription()
])
];
Expand Down Expand Up @@ -108,9 +109,12 @@ protected function getEntityOperationsData($route)

protected function getCollectionOperationsData($route)
{
$urlParameters = $this->getURLParametersNotRequired($route);
$urlParameters = $this->getURLParametersNotRequired($route);
$urlParameters = $this->getURLQueryParameters() ? array_merge($urlParameters,$this->getURLQueryParameters()) : $urlParameters;

unset($urlParameters[$this->service->routeIdentifierName]);
$operations = $this->service->operations;

return $this->getOperationsData($operations, $urlParameters);
}

Expand Down Expand Up @@ -166,6 +170,30 @@ protected function getURLParameters($route, $required)
return $templateParameters;
}

protected function getURLQueryParameters()
{
// find all parameters in Swagger naming format
//preg_match_all('#{([\w\d_-]+)}#', $route, $parameterMatches);
$queryWhitelist = $this->service->getQueryWhitelist();
if (count($queryWhitelist) > 0) {
$templateQueryParameters = [];
foreach ($queryWhitelist as $paramSegmentName) {
$templateQueryParameters[$paramSegmentName] = [
'in' => 'query',
'name' => $paramSegmentName,
'description' => 'URL parameter ' . $paramSegmentName,
'dataType' => 'string',
'required' => false,
'minimum' => 0,
'maximum' => 1,
'defaultValue' => ''
];
}
return $templateQueryParameters;
} else return false;

}

protected function getPostPatchPutBodyParameter()
{
return [
Expand All @@ -188,11 +216,16 @@ protected function getMethodFromOperation(Operation $operation)
return strtolower($operation->getHttpMethod());
}

/*
* Added summary
*/
protected function getPathOperation(Operation $operation, $parameters)
{

return $this->cleanEmptyValues([
'tags' => [$this->service->getName()],
'description' => $operation->getDescription(),
'summary' => $operation->getSummary(),
'parameters' => $parameters,
'produces' => $this->service->getRequestAcceptTypes(),
'responses' => $this->getResponsesFromOperation($operation)
Expand Down

0 comments on commit bed9409

Please sign in to comment.