Skip to content

Commit c6419d7

Browse files
authored
/tags api docs (forem#19048)
* /tags api docs * Merge main
1 parent 7e9185f commit c6419d7

File tree

4 files changed

+357
-234
lines changed

4 files changed

+357
-234
lines changed

spec/requests/api/v1/docs/followed_tags_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
describe "GET /follows/tags" do
2222
path "/api/follows/tags" do
2323
get "Followed Tags" do
24-
tags "followed_tags"
24+
tags "followed_tags", "tags"
2525
description(<<-DESCRIBE.strip)
2626
This endpoint allows the client to retrieve a list of the tags they follow.
2727
DESCRIBE
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
require "rails_helper"
2+
require "swagger_helper"
3+
4+
# rubocop:disable RSpec/EmptyExampleGroup
5+
6+
describe "GET /tags" do
7+
before { create_list(:tag, 3) }
8+
9+
path "/api/tags" do
10+
get "Tags" do
11+
tags "tags"
12+
security []
13+
description "This endpoint allows the client to retrieve a list of tags that can be used to tag articles.
14+
15+
It will return tags ordered by popularity.
16+
17+
It supports pagination, each page will contain 10 tags by default."
18+
operationId "getTags"
19+
produces "application/json"
20+
parameter "$ref": "#/components/parameters/pageParam"
21+
parameter "$ref": "#/components/parameters/perPageParam10to1000"
22+
23+
response "200", "A List of all tags" do
24+
schema type: :array,
25+
items: { "$ref": "#/components/schemas/Tag" }
26+
add_examples
27+
28+
run_test!
29+
end
30+
end
31+
end
32+
end
33+
34+
# rubocop:enable RSpec/EmptyExampleGroup

spec/swagger_helper.rb

+10
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,16 @@
257257
},
258258
required: %w[id name points]
259259
},
260+
Tag: {
261+
description: "Representation of a tag",
262+
type: :object,
263+
properties: {
264+
id: { description: "Tag id", type: :integer, format: :int64 },
265+
name: { type: :string },
266+
bg_color_hex: { type: :string, nullable: true },
267+
text_color_hex: { type: :string, nullable: true }
268+
}
269+
},
260270
Page: {
261271
description: "Representation of a page object",
262272
type: :object,

0 commit comments

Comments
 (0)