Skip to content

Commit 38ee390

Browse files
committed
Search in paths with normal and regexp mode
1 parent 9c9a452 commit 38ee390

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,10 @@
2626
<script src="./dist/vendor.js"></script>
2727
<script src="./dist/data.js"></script>
2828
<script src="./dist/main.js"></script>
29+
<script>
30+
$(function () {
31+
$("[data-toggle=\"tooltip\"]").tooltip();
32+
});
33+
</script>
2934
</body>
3035
</html>

src/app/OpenApiClient.vue

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@
99
v-if="!fullscreen">
1010
<nav class="col-sm-4 col-md-3 d-none d-sm-block bg-faded logo">
1111
{{ schema.info.title }}
12+
<div class="row">
13+
<div class="col">
14+
<div class="input-group">
15+
<input
16+
id="search"
17+
:placeholder="this.searchRegexp ? 'Regexp' : 'Search'"
18+
class="form-control"
19+
v-model="search">
20+
<div class="input-group-append">
21+
<button
22+
:class="['btn', this.searchRegexp ? 'btn-primary' : 'btn-outline-secondary']"
23+
type="button"
24+
data-toggle="tooltip"
25+
data-placement="right"
26+
title="Toggle Regexp Search"
27+
@click="onToggleSearchMode">
28+
<i class="oi oi-code"/>
29+
</button>
30+
</div>
31+
</div>
32+
</div>
33+
</div>
1234
</nav>
1335
<div class="col-sm-8 offset-sm-4 col-md-9 offset-md-3 pt-3">
1436
<request-url
@@ -21,10 +43,15 @@
2143
</div>
2244
</div>
2345
<div class="row">
24-
<nav class="col-sm-4 col-md-3 d-none d-sm-block bg-faded sidebar" v-if="!fullscreen">
46+
<nav
47+
class="col-sm-4 col-md-3 d-none d-sm-block bg-faded sidebar"
48+
v-if="!fullscreen">
49+
2550
<path-menu
2651
:schema="schema"
2752
:request-url="selectedUrl"
53+
:search="search"
54+
:search-regexp="searchRegexp"
2855
@selectUrl="onSelectUrl"/>
2956
</nav>
3057
<main class="col-sm-8 offset-sm-4 col-md-9 offset-md-3 pt-3">
@@ -88,14 +115,19 @@ export default {
88115
responseHeaders: {},
89116
responseBody: "",
90117
requestUrl: "",
91-
fullscreen: false
118+
fullscreen: false,
119+
search: "",
120+
searchRegexp: false
92121
};
93122
},
94123
props: ["schema"],
95124
methods: {
96125
onRequestBodyChange(requestBody) {
97126
this.requestBody = requestBody;
98127
},
128+
onToggleSearchMode() {
129+
this.searchRegexp = !this.searchRegexp;
130+
},
99131
onSelectUrl(url) {
100132
this.requestUrl = getFirstServerUrl(this.schema) + getBasePath(this.schema) + url;
101133
this.selectedUrl = url;
@@ -139,7 +171,7 @@ export default {
139171
.logo {
140172
position: fixed;
141173
top: 0;
142-
height: 70px;
174+
height: 100px;
143175
left: 0;
144176
z-index: 1000;
145177
padding: 20px;
@@ -150,7 +182,7 @@ export default {
150182
151183
.sidebar {
152184
position: fixed;
153-
top: 70px;
185+
top: 100px;
154186
bottom: 0;
155187
left: 0;
156188
z-index: 1000;

src/app/components/PathMenu.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,28 @@
1313
</template>
1414

1515
<script>
16+
import trim from "lodash/trim";
17+
1618
export default {
1719
name: "PathMenu",
1820
props: [
1921
"schema",
22+
"search",
23+
"searchRegexp",
2024
"requestUrl"
2125
],
2226
computed: {
2327
urls() {
24-
return Object.keys(this.schema.paths);
28+
if (trim(this.searchRegexp)) {
29+
return Object.keys(this.schema.paths).filter(u => {
30+
return u.match(this.search);
31+
});
32+
} else {
33+
const search = this.search.toLowerCase();
34+
return Object.keys(this.schema.paths).filter(u => {
35+
return u.includes(search);
36+
});
37+
}
2538
}
2639
},
2740
methods: {

0 commit comments

Comments
 (0)