2021-02-04 08:12:35 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require "swagger_helper"
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe "groups" do
|
2021-02-04 08:12:35 +08:00
|
|
|
let(:admin) { Fabricate(:admin) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
Jobs.run_immediately!
|
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
path "/search.json" do
|
|
|
|
get "Search for a term" do
|
|
|
|
tags "Search"
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId "search"
|
2021-02-04 08:12:35 +08:00
|
|
|
consumes "application/json"
|
2021-08-31 01:25:34 +08:00
|
|
|
parameter(
|
|
|
|
name: :q,
|
|
|
|
in: :query,
|
|
|
|
type: :string,
|
|
|
|
example:
|
|
|
|
"api @blake #support tags:api after:2021-06-04 in:unseen in:open order:latest_topic",
|
DEV: Correctly tag heredocs (#16061)
This allows text editors to use correct syntax coloring for the heredoc sections.
Heredoc tag names we use:
languages: SQL, JS, RUBY, LUA, HTML, CSS, SCSS, SH, HBS, XML, YAML/YML, MF, ICS
other: MD, TEXT/TXT, RAW, EMAIL
2022-03-01 03:50:55 +08:00
|
|
|
description: <<~MD,
|
2021-08-31 01:25:34 +08:00
|
|
|
The query string needs to be url encoded and is made up of the following options:
|
|
|
|
- Search term. This is just a string. Usually it would be the first item in the query.
|
|
|
|
- `@<username>`: Use the `@` followed by the username to specify posts by this user.
|
|
|
|
- `#<category>`: Use the `#` followed by the category slug to search within this category.
|
|
|
|
- `tags:`: `api,solved` or for posts that have all the specified tags `api+solved`.
|
|
|
|
- `before:`: `yyyy-mm-dd`
|
|
|
|
- `after:`: `yyyy-mm-dd`
|
|
|
|
- `order:`: `latest`, `likes`, `views`, `latest_topic`
|
|
|
|
- `assigned:`: username (without `@`)
|
2022-05-24 23:31:24 +08:00
|
|
|
- `in:`: `title`, `likes`, `personal`, `messages`, `seen`, `unseen`, `posted`, `created`, `watching`, `tracking`, `bookmarks`, `assigned`, `unassigned`, `first`, `pinned`, `wiki`
|
2021-08-31 01:25:34 +08:00
|
|
|
- `with:`: `images`
|
|
|
|
- `status:`: `open`, `closed`, `public`, `archived`, `noreplies`, `single_user`, `solved`, `unsolved`
|
2023-01-10 05:46:07 +08:00
|
|
|
- `group:`: group_name or group_id
|
|
|
|
- `group_messages:`: group_name or group_id
|
2021-08-31 01:25:34 +08:00
|
|
|
- `min_posts:`: 1
|
|
|
|
- `max_posts:`: 10
|
|
|
|
- `min_views:`: 1
|
|
|
|
- `max_views:`: 10
|
|
|
|
|
|
|
|
If you are using cURL you can use the `-G` and the `--data-urlencode` flags to encode the query:
|
|
|
|
|
|
|
|
```
|
|
|
|
curl -i -sS -X GET -G "http://localhost:4200/search.json" \\
|
|
|
|
--data-urlencode 'q=wordpress @scossar #fun after:2020-01-01'
|
|
|
|
```
|
DEV: Correctly tag heredocs (#16061)
This allows text editors to use correct syntax coloring for the heredoc sections.
Heredoc tag names we use:
languages: SQL, JS, RUBY, LUA, HTML, CSS, SCSS, SH, HBS, XML, YAML/YML, MF, ICS
other: MD, TEXT/TXT, RAW, EMAIL
2022-03-01 03:50:55 +08:00
|
|
|
MD
|
2021-08-31 01:25:34 +08:00
|
|
|
)
|
|
|
|
parameter name: :page, in: :query, type: :integer, example: 1
|
2021-02-04 08:12:35 +08:00
|
|
|
|
|
|
|
produces "application/json"
|
|
|
|
response "200", "success response" do
|
|
|
|
expected_response_schema = load_spec_schema("search_response")
|
|
|
|
schema expected_response_schema
|
|
|
|
|
2021-08-31 01:25:34 +08:00
|
|
|
let(:q) { "awesome post" }
|
|
|
|
let(:page) { 1 }
|
2021-02-04 08:12:35 +08:00
|
|
|
|
2021-08-31 01:25:34 +08:00
|
|
|
run_test!
|
2021-02-04 08:12:35 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|