Skip to content

Conversation

@lohanidamodar
Copy link
Member

@lohanidamodar lohanidamodar commented Aug 22, 2022

What does this PR do?

  • Dart
  • Flutter
  • Deno
  • Web
  • Node
  • Php

Swagger spec

  • parameters can have x-example-filter with the name of the custom filter

  • methods can have x-example-params with the name of params apart from required ones that we want to display on the example

  • As collection level and document level support different permissions can we have separate filters for collection, bucket params and document, files permissions 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.)

@lohanidamodar lohanidamodar marked this pull request as draft August 22, 2022 08:07
Comment on lines 88 to 91
$this->twig->addFilter(new TwigFilter('customLanguageFilter', function($value, $filter) use ($language) {
return call_user_func([$language, $filter], $value);
}));

Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

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 👍🏻

Copy link
Member Author

@lohanidamodar lohanidamodar Aug 23, 2022

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.

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

Successfully merging this pull request may close these issues.

3 participants