Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add query params from collection whitelist #9

Open
weierophinney opened this issue Dec 31, 2019 · 2 comments
Open

add query params from collection whitelist #9

weierophinney opened this issue Dec 31, 2019 · 2 comments

Comments

@weierophinney
Copy link
Contributor

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

@loco8878
Copy link

loco8878 commented Nov 3, 2021

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 ;-)

@reuven770
Copy link

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;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants