Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions runtime/runtime_http_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ func getHttpSearchResult(fields map[string]string, discriminator []string) (sear
"type": strings.ToLower(result.Type),
"service": result.Domain,
"path": fields["path"],
"methods": fields["meta.methods"],
}
case "operation":
result.Domain = fields["api"]
Expand Down
28 changes: 23 additions & 5 deletions runtime/runtime_http_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func TestIndex_Http(t *testing.T) {
test: func(t *testing.T, app *runtime.App) {
cfg := openapitest.NewConfig("3.0",
openapitest.WithInfo("foo", "1.0", ""),
openapitest.WithPath("/pets"),
openapitest.WithPath("/pets", openapitest.WithOperation(http.MethodGet)),
)
app.Http.Add(toConfig(cfg))

Expand All @@ -164,10 +164,11 @@ func TestIndex_Http(t *testing.T) {
waitSearchIndex(t, func() bool {
r, err = app.Search(search.Request{QueryText: "pets", Limit: 10})
require.NoError(t, err)
return len(r.Results) == 1
return len(r.Results) == 2
})
require.Len(t, r.Results, 1)
require.Equal(t,
require.Len(t, r.Results, 2)
require.Contains(t,
r.Results,
search.ResultItem{
Type: "HTTP",
Domain: "foo",
Expand All @@ -177,9 +178,25 @@ func TestIndex_Http(t *testing.T) {
"type": "http",
"service": "foo",
"path": "/pets",
"methods": "GET",
},
},
r.Results[0])
)
require.Contains(t,
r.Results,
search.ResultItem{
Type: "HTTP",
Domain: "foo",
Title: "/pets",
Fragments: []string{"/<mark>pets</mark>"},
Params: map[string]string{
"type": "http",
"service": "foo",
"path": "/pets",
"method": "GET",
},
},
)
},
},
{
Expand Down Expand Up @@ -220,6 +237,7 @@ func TestIndex_Http(t *testing.T) {
"type": "http",
"service": "foo",
"path": "/pets",
"methods": "",
},
},
r.Results[0])
Expand Down
5 changes: 4 additions & 1 deletion webui/src/components/dashboard/search/Http.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const type = computed(() => {
return 'api'
})
const methods = computed(() => {
if (!props.item.params.methods) {
return []
}
return props.item.params.methods.split(',')
})
</script>
Expand All @@ -46,7 +49,7 @@ const methods = computed(() => {
<div class="text-muted small mb-1">
<span v-if="type !== 'api'"> {{ item.domain }} &middot; </span>
<span v-if="type === 'path'">
<span v-for="m of methods" :key="m" class="badge operation me-1 text-uppercase" :class="m">{{ m }}</span>
<span v-for="m of methods" :key="m" class="badge operation me-1 text-uppercase" :class="m.toLocaleLowerCase()">{{ m }}</span>
&middot;
</span>

Expand Down
Loading