question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

new decorators: `filter-in` and `filter-out`

See original GitHub issue

Is your feature request related to a problem? Please describe. Users need to generate different “slices” of single OpenAPI definition for different audiences.

For example, “include only API endpoints with x-audience set to public”.

This is more advanced version of remove-x-internal which covers only basic use case.

Describe the solution you’d like We need two decorators filter-in and filter-out.

filter-in

Keep nodes that have specific property set to the specific value. Arrays should be supported too. If the property is not set on the node it should be kept too.

filter-in:
  property: x-audience
  value: [Public, Partner] 

In the example above value should support arrays. If x-audience in the definition is an array too the node should be kept if only two arrays have at least one element in common. We can implement matchStrategy option to alter this behavior with values: ‘any’ or ‘all’.

filter-out

It’s same as filter-in but it removes nodes that have specific property set to the specific value.

filter-out:
  property: x-audience
  value: Private 

Describe alternatives you’ve considered filter-out-permission and filter-in-permission

Additional context Add any other context or screenshots about the feature request here.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
adamaltmancommented, Mar 21, 2022

I think all is more clear than every. It could be just all and any.

0reactions
RomanHotsiycommented, May 12, 2022

Another interesting use-case: splitting single source of truth definition into smaller chunks by tags:

apis:
  users@v1:
    root: ./big-oas.yaml
    lint:
      decorators:
        filter-in:
          property: tags
          value: [Users, Account] 
  payments@v1:
    root: ./big-oas.yaml # same root
    lint:
      decorators:
        filter-in:
          property: tags
          value: [Payments, CreditCards, Transactions] 
Read more comments on GitHub >

github_iconTop Results From Across the Web

Python, How to add another decorator to filter the output of the ...
You are applying your decorator to the output of the @property decorator. That decorator produces a property() object, not a function.
Read more >
filter-out - Redocly
filter -out. Removes nodes that have specific property set to the specific value and preserves others. Nodes that don't have the property ...
Read more >
Turn off ALL decorators in Neversink's filter? : r/pathofexile
Is there any to disable ALL decorators in the new filter? I've gone through and turned off any that I can find but...
Read more >
Decorator Pattern on query filter - Laracasts
Hi, i just watched the Decorator Pattern video and i was thinking to use it for flexible query filter. For a recent website...
Read more >
Filter a Backbone Collection Using the Decorator Pattern
constructor(); // Remove events associated with original filtered._callbacks = {}; filtered.filterItems = function(filter) { var items; items = ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found