diff options
author | crupest <crupest@outlook.com> | 2021-01-19 15:24:39 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-01-19 15:24:39 +0800 |
commit | fb6442f1716406c7a2da79e4a1cc42e23908d218 (patch) | |
tree | 455fbd07678b1b21a1bfa3ad7e3778b1957fd12f /BackEnd/Timeline/Controllers/SearchController.cs | |
parent | 208ae3f6371857e2b06cf789a640989f64f80a24 (diff) | |
download | timeline-fb6442f1716406c7a2da79e4a1cc42e23908d218.tar.gz timeline-fb6442f1716406c7a2da79e4a1cc42e23908d218.tar.bz2 timeline-fb6442f1716406c7a2da79e4a1cc42e23908d218.zip |
test: Add integrated tests for search api.
Diffstat (limited to 'BackEnd/Timeline/Controllers/SearchController.cs')
-rw-r--r-- | BackEnd/Timeline/Controllers/SearchController.cs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/BackEnd/Timeline/Controllers/SearchController.cs b/BackEnd/Timeline/Controllers/SearchController.cs index 915938de..dec876b6 100644 --- a/BackEnd/Timeline/Controllers/SearchController.cs +++ b/BackEnd/Timeline/Controllers/SearchController.cs @@ -28,7 +28,14 @@ namespace Timeline.Controllers _userMapper = userMapper;
}
+ /// <summary>
+ /// Search timelines whose name or title contains query string case-insensitively.
+ /// </summary>
+ /// <param name="query">The string to contain.</param>
+ /// <returns>Timelines with most related at first.</returns>
[HttpGet("timelines")]
+ [ProducesResponseType(200)]
+ [ProducesResponseType(400)]
public async Task<ActionResult<List<HttpTimeline>>> TimelineSearch([FromQuery(Name = "q"), Required(AllowEmptyStrings = false)] string query)
{
var searchResult = await _service.SearchTimeline(query);
@@ -36,7 +43,14 @@ namespace Timeline.Controllers return await _timelineMapper.MapToHttp(timelines, Url, this.GetOptionalUserId());
}
+ /// <summary>
+ /// Search users whose username or nick contains query string case-insensitively.
+ /// </summary>
+ /// <param name="query">The string to contain.</param>
+ /// <returns>Users with most related at first.</returns>
[HttpGet("users")]
+ [ProducesResponseType(200)]
+ [ProducesResponseType(400)]
public async Task<ActionResult<List<HttpUser>>> UserSearch([FromQuery(Name = "q"), Required(AllowEmptyStrings = false)] string query)
{
var searchResult = await _service.SearchUser(query);
|