Skip to content

Commit

Permalink
add filter
Browse files Browse the repository at this point in the history
  • Loading branch information
netweng committed Feb 9, 2022
1 parent 9221efb commit 529024e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
13 changes: 12 additions & 1 deletion cloudtower-api-doc/swagger/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
wrapPathWithI18n,
wrapSchemaWithI18n,
} from "./utils";
import _ from "lodash";
import _, { values } from "lodash";


const WrapWithI18n = (Original) => (props) => <Original {...props} i18next={i18next} />;
Expand Down Expand Up @@ -50,6 +50,17 @@ const App: React.FC = () => {
plugins: [
() => ({
components: { CustomLayout },
fn: {
opsFilter: (taggedOps, filter) => {
const filters = filter.split(' ');
return taggedOps.filter((val, key) => {
const ops = val.get('operations');
return filters.some(item => key.indexOf(item) > -1) || ops.some(op => {
return filters.some(item => op.get('path').includes(item) || op.get('operation').get('description').includes(item));
})
})
}
},
wrapComponents: {
Example: WrapWithI18n,
authorizeBtn: WrapWithI18n,
Expand Down
1 change: 0 additions & 1 deletion cloudtower-api-doc/swagger/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import Servers from './components/Servers';
import { CommonSwaggerProps, translateComponent } from './utils';
import i18next from './i18n';

interface ILayoutState {
customServers: { url: string }[];
Expand Down
2 changes: 1 addition & 1 deletion cloudtower-api-doc/swagger/locales/en/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"server_placeholder": "add new server, http://YOUR_TOWER_URL/v2/api",
"authorization": "Authorize",
"servers": "Servers",
"filter_placeholder": "Filter By Tag",
"filter_placeholder": "Filter By Tag, API, API Description.",
"parameters": "Parameters",
"download": "Download File",
"tryItOut": "Try It Out",
Expand Down
2 changes: 1 addition & 1 deletion cloudtower-api-doc/swagger/locales/zh/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"server_placeholder": "添加新的 server,http://YOUR_TOWER_URL/v2/api",
"authorization": "鉴权",
"servers": "服务",
"filter_placeholder": "通过标签过滤",
"filter_placeholder": "通过标签, API,API 描述过滤,通过空格进行多个过滤",
"parameters": "参数",
"download": "下载文件",
"tryItOut": "试一试",
Expand Down

1 comment on commit 529024e

@vercel
Copy link

@vercel vercel bot commented on 529024e Feb 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.