diff --git a/runtime/runtime_http_search.go b/runtime/runtime_http_search.go index f035e674c..eecd0effc 100644 --- a/runtime/runtime_http_search.go +++ b/runtime/runtime_http_search.go @@ -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"] diff --git a/runtime/runtime_http_search_test.go b/runtime/runtime_http_search_test.go index 4a945aec7..2675548da 100644 --- a/runtime/runtime_http_search_test.go +++ b/runtime/runtime_http_search_test.go @@ -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)) @@ -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", @@ -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{"/pets"}, + Params: map[string]string{ + "type": "http", + "service": "foo", + "path": "/pets", + "method": "GET", + }, + }, + ) }, }, { @@ -220,6 +237,7 @@ func TestIndex_Http(t *testing.T) { "type": "http", "service": "foo", "path": "/pets", + "methods": "", }, }, r.Results[0]) diff --git a/webui/src/components/dashboard/search/Http.vue b/webui/src/components/dashboard/search/Http.vue index fe416b06d..aff4dc83f 100644 --- a/webui/src/components/dashboard/search/Http.vue +++ b/webui/src/components/dashboard/search/Http.vue @@ -24,6 +24,9 @@ const type = computed(() => { return 'api' }) const methods = computed(() => { + if (!props.item.params.methods) { + return [] + } return props.item.params.methods.split(',') }) @@ -46,7 +49,7 @@ const methods = computed(() => {