Skip to content

Commit 00faf0f

Browse files
humitosstsewd
andauthored
Javascript client: search-as-you-type API response (#10196)
* Javascript client: search-as-you-type API response Return data required for search-as-you-type integration. * Update readthedocs/proxito/views/hosting.py Co-authored-by: Santos Gallegos <[email protected]> * Tests: adapt test for JSON response --------- Co-authored-by: Santos Gallegos <[email protected]>
1 parent 1baa018 commit 00faf0f

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

readthedocs/proxito/tests/test_hosting.py

+10
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ def test_get_config(self):
119119
"filepath": "/docs/index.rst",
120120
},
121121
},
122+
"search": {
123+
"api_endpoint": "/_/api/v3/search/",
124+
"default_filter": "subprojects:project/latest",
125+
"filters": [
126+
["Search only in this project", "project:project/latest"],
127+
["Search subprojects", "subprojects:project/latest"],
128+
],
129+
"project": "project",
130+
"version": "latest",
131+
},
122132
},
123133
}
124134
assert r.json() == expected

readthedocs/proxito/views/hosting.py

+17
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,23 @@ def get(self, request):
115115
"filepath": "/docs/index.rst",
116116
},
117117
},
118+
"search": {
119+
"project": project.slug,
120+
"version": version.slug,
121+
"api_endpoint": "/_/api/v3/search/",
122+
# TODO: figure it out where this data comes from
123+
"filters": [
124+
[
125+
"Search only in this project",
126+
f"project:{project.slug}/{version.slug}",
127+
],
128+
[
129+
"Search subprojects",
130+
f"subprojects:{project.slug}/{version.slug}",
131+
],
132+
],
133+
"default_filter": f"subprojects:{project.slug}/{version.slug}",
134+
},
118135
},
119136
}
120137

0 commit comments

Comments
 (0)