-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
How to Enable Filter ("Filter in Tag") as case insensitive search default lowercase #2499
Comments
Did you find a solution? |
Hi everyone, |
@sprudel79 Do you mind sharing how you setup your custom filter please ? |
Hi @msrouchou , sure I can share some details, but you have to be patient since I am on vacation right now and I'll be back on the project beginning of September. |
Hi @msrouchou, In my custom Swagger HTML file I have added the following: // Based on https://github.com/swagger-api/swagger-ui/issues/3876
const AdvancedFilterPlugin = function (system) {
return {
fn: {
opsFilter: function (taggedOps, phrase) {
phrase = phrase.toLowerCase()
var normalTaggedOps = JSON.parse(JSON.stringify(taggedOps));
for (tagObj in normalTaggedOps) {
var operations = normalTaggedOps[tagObj].operations;
var i = operations.length;
while (i--) {
var operation = operations[i].operation;
var parameters = "";
var responses = "";
var requestBody = "";
if (typeof operation.parameters !== 'undefined') {
parameters = JSON.stringify(operation.parameters).toLowerCase();
}
if (typeof operation.responses !== 'undefined') {
responses = JSON.stringify(operation.responses).toLowerCase();
}
if (typeof operation.requestBody !== 'undefined') {
requestBody = JSON.stringify(operation.requestBody).toLowerCase();
}
var keepEndpoint = (
(operations[i].path.toLowerCase().indexOf(phrase) !== -1) ||
(operation.summary && operation.summary.toLowerCase().indexOf(phrase) !== -1) ||
(operation.description && operation.description.toLowerCase().indexOf(phrase) !== -1) ||
(parameters.indexOf(phrase) !== -1) ||
(responses.indexOf(phrase) !== -1) ||
(requestBody.indexOf(phrase) !== -1)
);
if (!keepEndpoint) {
operations.splice(i, 1);
}
}
if (operations.length == 0) {
delete normalTaggedOps[tagObj];
}
else {
normalTaggedOps[tagObj].operations = operations;
}
}
return system.Im.fromJS(normalTaggedOps);
}
}
};
};
window.onload = function () {
var configObject = JSON.parse('%(ConfigObject)');
...
configObject.plugins = [SwaggerUIBundle.plugins.DownloadUrl, AdvancedFilterPlugin];
...
} |
Thank you for getting back and providing the example :) |
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made. |
Closing as we can't make absolutely everything you might want to customise supported in the built in distribution. A custom plugin, or providing your own index.html, is the way to go here. |
No description provided.
The text was updated successfully, but these errors were encountered: