-
Notifications
You must be signed in to change notification settings - Fork 190
WIP using example params #523
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
base: master
Are you sure you want to change the base?
Conversation
| $this->twig->addFilter(new TwigFilter('customLanguageFilter', function($value, $filter) use ($language) { | ||
| return call_user_func([$language, $filter], $value); | ||
| })); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about that one, it might be better to be more explicit in the languages itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as this will be need in all language, doing it this way gives a nice error, if any language not implement any of the functions that are in the specs as well.
Also, even if we do it in each language, we do have to implement same customFilter in all the languages that will just call the functions. it's same for all the languages.
Or are you thinking another way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is like magic. If we want all languages to adapt these methods, we can have them as abstract in the base class or as an interface.
Also what is customLanguageFilter? The naming is not 100% clear imo 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TorstenDittmann What I want to achieve is,
The name of the filter we need to apply to the parameter is available from the spec, so I need to call the filter dynamically for each parameter if it exists. The only way I found was by calling a another filter that would accept the name of the filter, so customLanguageFilter is just a filter that calls specific filter method inside the language so that we can get proper example for that parameter based on the name of the function. If you know better way to achieve this I'd love to know. I'm not perfectly happy with this solution, but this works and also if any filter is provided in the spec and is not implemented in any language, we get error during generation so that we know we missed some.
This way, whenever spec change, add new example param filters, we will know if they are not implemented as well.
What does this PR do?
Swagger spec
parameters can have
x-example-filterwith the name of the custom filtermethods can have
x-example-paramswith the name of params apart from required ones that we want to display on the exampleAs collection level and document level support different permissions can we have separate filters for
collection,bucketparams anddocument,filespermissions params @TorstenDittmann ?Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)
Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)