-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Feature: Advanced Filter Core Plugin #6851
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: mathis-m <mathis.michel@outlook.de>
added match case and match whole word filter options. added tags, operations, definitions // schema matcher Signed-off-by: mathis-m <mathis.michel@outlook.de>
Signed-off-by: mathis-m <mathis.michel@outlook.de>
Signed-off-by: mathis-m <mathis.michel@outlook.de>
dc00765
to
2e82de2
Compare
2e82de2
to
d4abe2a
Compare
8d11fbb
to
95d3df9
Compare
95d3df9
to
df0163f
Compare
Signed-off-by: mathis-m <mathis.michel@outlook.de>
@tim-lai build failing due to bundle size. |
When will this be available? |
I am looking for this exact feature! |
UX review is needed. After this I will refactoring accordingly and tests will be written. |
Will this advanced filter be compatible will |
Yes since it will be released as core plugin it will be provided to swagger-ui-react too. |
Hey, this feature looks really promising :) Are there any plans when this will be made available? |
hi @tim-lai just curious if this feature will be merged any time soon? My company uses Swagger for our apidocs and would very much appreciate this feature! |
hi @tim-lai just following up again on this PR. This would be a super nice feature that would be awesome for my current company to use. Multiple engineers have been asking for this. |
@tim-lai seconding @captainkw . Our swagger docs are getting too long/complex to browse. It's now taking a decidedly nontrivial amount of time to hunt for a specific endpoint and trying out the preview above it is exactly what we need to solve the problem. |
Hi all, there's a couple of tasks to complete to get this PR merged.
|
Hi all could someone or possible some of you review the documentation? |
dev-helpers/index.html
Outdated
advancedFilter: { | ||
enabled: true | ||
}, |
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.
@tim-lai is this fine probably commited this by accident?
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.
@mathis-m I would set enabled: false
at minimum. I think having the option in dev-helpers is okay. Thanks.
@char0n should I start working on this again? Would it be possible to release it with the 4.x as default? |
Hi @mathis-m,
This is quite a big change and a lot of invested work (great work). The scope of v4 was established before the effort on v4 started. v4 is limited to evolution of dependency tree and bug-fixes. More into about this in pre-release article. IMHO the most appropriate time to restart this effort will be after the release/4.x branch lands on master. |
Is there anything we regular folks can do to help? P.S. |
hi can we get this merged already? |
Please get this merged, this is very much needed. |
pretty please? 👉👈 |
sending some good vibes here and also wishing this gets merged too soon 🤞 ❤️ |
OP here, I have stepped back from doing PRs at swagger due to time constraints... It is pretty out of sync with current code and probably needs again some work. As well as working on open points mentioned here by maintainers: #6851 (comment) Anyone can try to rebase this onto latest code and start working to finish my work up. @char0n Any chance it will be considered to be merged, in the near future, once some tackles it and finishes the work? |
Advanced Filter Core Plugin
Preview
XqEdcfWeb1.mp4
Introduction
Reflect common filtering, like we all know from IDE's.
The main focus of this PR is to implement a base for filtering that can be extended in an easy way using the plugin system.
Documentation
Configuration
The advanced filter plugin can be configured using the global SwaggerUI configuration.
To do so you can override the
AdvancedFilterConfiguration
defaults (see below), using the keyadvancedFilter
.Plug Points
The Advanced Filter fully integrates into the swagger plugin system.
Modify spec selectors
In order to apply the filtered spec the advanced filter plugin overrides spec selectors:
In this way future matcher results can be reflected back into the spec state selection process too.
MatcherOption Conventions
MatcherOptions
keys are mapped to a components via convention below, e.g.MatcherOption_matchCase
:These components should renderer the options state. In case of a two-state state a toggle button could be used.
Matcher Conventions
In order to maintain the isActive state each matcher must have a component named via convention below, e.g.
MatcherSelectOption_operations
(the keys ofMatchers
are used):Matcher fn
Each matcher has a corresponding fn to generate the filtered subset of the current spec for its context.
The fn has following naming convention, e.g.
advancedFilterMatcher_operations
:The fn gets called with these arguments
(spec, options, phrase, system)
and should return aMap
containing the subset of the filtered spec.Creating a matcher plugin
Example for matching operation summary:
Types
AdvancedFilterConfiguration
This is the public interface model for configuring the advanced filter.
string
""
boolean
false
true
the advanced filter components are rendered and filtering logic is executed.MatcherOptions
Matchers
MatcherOptions
This is a dictionary to store the state of each matcher option. Each key will be used to evaluate the corresponding component (see conventions).
boolean
true
false
it will rely on regex flag ignore case.boolean
false
true
the matchers will only match full words. The matching logic is based on regex and will wrap the escaped phrase with\b
.Matchers
This is a dictionary to store the state of each matcher. Each key will be used to evaluate the corresponding matcher select option component (see conventions).
This is the plug point to register matchers. A matcher is able to filter the current OpenAPI Specification, while respecting the matcher options provided. Each matcher has a context e.g. operations matcher - will match the operations and will return updated subset of the spec. The subsets returned by all matchers will be deep assigned with each other. The new filtered spec will be provided to the state in the
advancedFilter
namespace.BaseMatcherState
true
#/definitions
or#/components/schemas
). The filtered spec should include all matching opartions, only used tags and only the models that are used in the operations.BaseMatcherState
true
BaseMatcherState
true
BaseMatcherState
This is the base for all matchers.
boolean
true
.Current todo list:
Relations
#6744
Fixes #6648