Skip to content

Commit

Permalink
v1 articles me + published + unpublished dics (forem#18810)
Browse files Browse the repository at this point in the history
  • Loading branch information
fdocr authored Dec 8, 2022
1 parent 38b86f2 commit ef854ea
Show file tree
Hide file tree
Showing 3 changed files with 272 additions and 44 deletions.
101 changes: 100 additions & 1 deletion spec/requests/api/v1/docs/articles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,105 @@
end

describe "GET /articles/me" do
path "/api/articles/me" do
get "User's articles" do
tags "articles"
description "This endpoint allows the client to retrieve a list of published articles on behalf of an authenticated user.
\"Articles\" are all the posts that users create on DEV that typically show up in the feed. They can be a blog post, a discussion question, a help thread etc. but is referred to as article within the code.
Published articles will be in reverse chronological publication order.
It will return published articles with pagination. By default a page will contain 30 articles."
operationId "getUserArticles"
produces "application/json"
parameter "$ref": "#/components/parameters/pageParam"
parameter "$ref": "#/components/parameters/perPageParam30to1000"

response "401", "Unauthorized" do
let(:"api-key") { nil }
add_examples

run_test!
end

response "200", "A List of the authenticated user's Articles" do
let(:"api-key") { api_secret.secret }
schema type: :array,
items: { "$ref": "#/components/schemas/ArticleIndex" }
add_examples

run_test!
end
end
end

path "/api/articles/me/published" do
get "User's published articles" do
tags "articles"
description "This endpoint allows the client to retrieve a list of published articles on behalf of an authenticated user.
\"Articles\" are all the posts that users create on DEV that typically show up in the feed. They can be a blog post, a discussion question, a help thread etc. but is referred to as article within the code.
Published articles will be in reverse chronological publication order.
It will return published articles with pagination. By default a page will contain 30 articles."
operationId "getUserPublishedArticles"
produces "application/json"
parameter "$ref": "#/components/parameters/pageParam"
parameter "$ref": "#/components/parameters/perPageParam30to1000"

response "401", "Unauthorized" do
let(:"api-key") { nil }
add_examples

run_test!
end

response "200", "A List of the authenticated user's Articles" do
let(:"api-key") { api_secret.secret }
schema type: :array,
items: { "$ref": "#/components/schemas/ArticleIndex" }
add_examples

run_test!
end
end
end

path "/api/articles/me/unpublished" do
get "User's unpublished articles" do
tags "articles"
description "This endpoint allows the client to retrieve a list of unpublished articles on behalf of an authenticated user.
\"Articles\" are all the posts that users create on DEV that typically show up in the feed. They can be a blog post, a discussion question, a help thread etc. but is referred to as article within the code.
Unpublished articles will be in reverse chronological creation order.
It will return unpublished articles with pagination. By default a page will contain 30 articles."
operationId "getUserUnpublishedArticles"
produces "application/json"
parameter "$ref": "#/components/parameters/pageParam"
parameter "$ref": "#/components/parameters/perPageParam30to1000"

response "401", "Unauthorized" do
let(:"api-key") { nil }
add_examples

run_test!
end

response "200", "A List of the authenticated user's Articles" do
let(:"api-key") { api_secret.secret }
schema type: :array,
items: { "$ref": "#/components/schemas/ArticleIndex" }
add_examples

run_test!
end
end
end

path "/api/articles/me/all" do
get "User's all articles" do
tags "articles"
Expand All @@ -116,7 +215,7 @@
Unpublished articles will be at the top of the list in reverse chronological creation order. Published articles will follow in reverse chronological publication order.
By default a page will contain 30 articles."
operationId "getUserArticles"
operationId "getUserAllArticles"
produces "application/json"
parameter "$ref": "#/components/parameters/pageParam"
parameter "$ref": "#/components/parameters/perPageParam30to1000"
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/api/v1/docs/display_ads_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
body_markdown: { type: :string, description: "The text (in markdown) of the ad (required)" },
approved: { type: :boolean, description: "Ad must be both published and approved to be in rotation" },
published: { type: :boolean, description: "Ad must be both published and approved to be in rotation" },
organization_id: { type: :int32, description: "Identifies the organization to which the ad belongs" },
organization_id: { type: :integer, description: "Identifies the organization to which the ad belongs" },
display_to: { type: :string, enum: DisplayAd.display_tos.keys, default: "all",
description: "Potentially limits visitors to whom the ad is visible" },
placement_area: { type: :string, enum: DisplayAd::ALLOWED_PLACEMENT_AREAS,
Expand Down Expand Up @@ -176,7 +176,7 @@
body_markdown: { type: :string, description: "The text (in markdown) of the ad (required)" },
approved: { type: :boolean, description: "Ad must be both published and approved to be in rotation" },
published: { type: :boolean, description: "Ad must be both published and approved to be in rotation" },
organization_id: { type: :int32, description: "Identifies the organization to which the ad belongs" },
organization_id: { type: :integer, description: "Identifies the organization to which the ad belongs" },
display_to: { type: :string, enum: DisplayAd.display_tos.keys, default: "all",
description: "Potentially limits visitors to whom the ad is visible" },
placement_area: { type: :string, enum: DisplayAd::ALLOWED_PLACEMENT_AREAS,
Expand Down
Loading

0 comments on commit ef854ea

Please sign in to comment.