add query params from collection whitelist
weierophinney opened this issue · 2 comments
hi there,
i'd like to see my whitelisted collection params from zf-rest.MyController.collection_query_whitelist
show up in the Swagger UI as form inputs. in order to do that, i think collection_query_whitelist
would need to be added to the \ZF\Apigility\Documentation\Service
generated by \ZF\Apigility\Documentation\ApiFactory::createService
in zfcampus/zf-apigility-documentation
, and \ZF\Apigility\Documentation\Swagger\Service::toArray
would need to updated in this package to transform collection_query_whitelist
into Swagger parameters.
does this functionality already exist and i've misconfigured something? if not, and if this sounds like a useful addition then i'll get to work.
thanks!
Originally posted by @abacaphiliac at zfcampus/zf-apigility-documentation-swagger#30
Hey guys,
What is the plan here ? I think it is an important feature to get the collection query parameters into the swagger documentation.
And maybe attach a method to decorate the final swagger doc from outside via SwaggerDecorator class for example.
That would be cool ;-)
Hey guys
In vendor/laminas-api-tools/api-tools-documentation/src/ApiFactory.php I retrieved collection_query_whitelist from config
and added two methods in vendor/laminas-api-tools/api-tools-documentation/src/Service.php
getQueryWhitelist()
setQueryWhitelist($queryWhitelist). And pass data from Apifactory
In apigility before was method getURLQueryParameters
I restored it in
vendor/laminas-api-tools/api-tools-documentation-swagger/src/Service.php
protected function getURLQueryParameters()
{
$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;
}