Document a v0 endpoint in v1 (#18493)
Co-authored-by: Fernando Valverde <fernando@fdo.cr>
This commit is contained in:
parent
985b44af5f
commit
b4a4d59581
2 changed files with 137 additions and 47 deletions
|
|
@ -18,6 +18,28 @@ RSpec.describe "Api::V1::Docs::Users", type: :request do
|
|||
user.add_role(:admin)
|
||||
end
|
||||
|
||||
describe "GET /users/:id" do
|
||||
path "/api/users/{id}" do
|
||||
get "A User" do
|
||||
tags "users"
|
||||
description "This endpoint allows the client to retrieve a single user, either by id
|
||||
or by the user's username.
|
||||
|
||||
For complete documentumenation, see the v0 API docs: https://developers.forem.com/api/v0#tag/users/operation/getUser"
|
||||
operationId "getUser"
|
||||
produces "application/json"
|
||||
parameter name: :id, in: :path, required: true
|
||||
|
||||
response(200, "successful") do
|
||||
let(:"api-key") { api_secret.secret }
|
||||
let(:id) { user.id }
|
||||
|
||||
run_test!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT /users/:id/unpublish" do
|
||||
before do
|
||||
user.add_role(:admin)
|
||||
|
|
|
|||
|
|
@ -9,8 +9,12 @@
|
|||
"/api/articles": {
|
||||
"get": {
|
||||
"summary": "Published articles",
|
||||
"security": [],
|
||||
"tags": ["articles"],
|
||||
"security": [
|
||||
|
||||
],
|
||||
"tags": [
|
||||
"articles"
|
||||
],
|
||||
"description": "This endpoint allows the client to retrieve a list of articles.\n\n\"Articles\" are all the posts that users create on DEV that typically\nshow up in the feed. They can be a blog post, a discussion question,\na help thread etc. but is referred to as article within the code.\n\nBy default it will return featured, published articles ordered\nby descending popularity.\n\nIt supports pagination, each page will contain `30` articles by default.",
|
||||
"operationId": "getArticles",
|
||||
"parameters": [
|
||||
|
|
@ -67,7 +71,11 @@
|
|||
"description": "Using this parameter will allow the client to check which articles are fresh or rising.\n If `state=fresh` the server will return fresh articles.\n If `state=rising` the server will return rising articles.\n This param can be used in conjuction with `username`, only if set to `all`.",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": ["fresh", "rising", "all"]
|
||||
"enum": [
|
||||
"fresh",
|
||||
"rising",
|
||||
"all"
|
||||
]
|
||||
},
|
||||
"example": "fresh"
|
||||
},
|
||||
|
|
@ -103,45 +111,47 @@
|
|||
"example": [
|
||||
{
|
||||
"type_of": "article",
|
||||
"id": 191,
|
||||
"title": "An Acceptable Time172",
|
||||
"description": "Shabby chic wayfarers normcore marfa carry. Schlitz kinfolk +1 kickstarter pitchfork cardigan 90's....",
|
||||
"readable_publish_date": "Nov 17",
|
||||
"slug": "an-acceptable-time172-25ik",
|
||||
"path": "/username378/an-acceptable-time172-25ik",
|
||||
"url": "http://localhost:3000/username378/an-acceptable-time172-25ik",
|
||||
"id": 243,
|
||||
"title": "This Lime Tree Bower172",
|
||||
"description": "Plaid franzen tote bag tofu dreamcatcher austin. Aesthetic pbr&b 3 wolf moon mixtape. Kickstarter...",
|
||||
"readable_publish_date": "Nov 22",
|
||||
"slug": "this-lime-tree-bower172-13d4",
|
||||
"path": "/username378/this-lime-tree-bower172-13d4",
|
||||
"url": "http://localhost:3000/username378/this-lime-tree-bower172-13d4",
|
||||
"comments_count": 0,
|
||||
"public_reactions_count": 0,
|
||||
"collection_id": null,
|
||||
"published_timestamp": "2022-11-17T09:30:31Z",
|
||||
"published_timestamp": "2022-11-22T15:41:20Z",
|
||||
"positive_reactions_count": 0,
|
||||
"cover_image": "http://localhost:3000/assets/23-33ea5a2b5af3dc15b9ed90de0b850f67e2390eaec3361d6687d3b9750c699f84.png",
|
||||
"social_image": "http://localhost:3000/assets/23-33ea5a2b5af3dc15b9ed90de0b850f67e2390eaec3361d6687d3b9750c699f84.png",
|
||||
"canonical_url": "http://localhost:3000/username378/an-acceptable-time172-25ik",
|
||||
"created_at": "2022-11-17T09:30:31Z",
|
||||
"cover_image": "http://localhost:3000/assets/38-3b0c46cc0d5367229799d282c99b2c42f33501201cac1ceb5c643f9ee11f06c6.png",
|
||||
"social_image": "http://localhost:3000/assets/38-3b0c46cc0d5367229799d282c99b2c42f33501201cac1ceb5c643f9ee11f06c6.png",
|
||||
"canonical_url": "http://localhost:3000/username378/this-lime-tree-bower172-13d4",
|
||||
"created_at": "2022-11-22T15:41:20Z",
|
||||
"edited_at": null,
|
||||
"crossposted_at": null,
|
||||
"published_at": "2022-11-17T09:30:31Z",
|
||||
"last_comment_at": "2022-11-17T09:30:31Z",
|
||||
"published_at": "2022-11-22T15:41:20Z",
|
||||
"last_comment_at": "2022-11-22T15:41:20Z",
|
||||
"reading_time_minutes": 1,
|
||||
"tag_list": ["discuss"],
|
||||
"tag_list": [
|
||||
"discuss"
|
||||
],
|
||||
"tags": "discuss",
|
||||
"user": {
|
||||
"name": "Melaine \"Quinn\" \\:/ Goodwin",
|
||||
"name": "Candis \"Brady\" \\:/ Weimann",
|
||||
"username": "username378",
|
||||
"twitter_username": "twitter378",
|
||||
"github_username": "github378",
|
||||
"user_id": 386,
|
||||
"user_id": 470,
|
||||
"website_url": null,
|
||||
"profile_image": "/uploads/user/profile_image/386/93f316c4-1287-45b3-b1c7-49861128e477.jpeg",
|
||||
"profile_image_90": "/uploads/user/profile_image/386/93f316c4-1287-45b3-b1c7-49861128e477.jpeg"
|
||||
"profile_image": "/uploads/user/profile_image/470/8d5ebdf8-aa20-48e9-b0ef-028cfacbe26f.jpeg",
|
||||
"profile_image_90": "/uploads/user/profile_image/470/8d5ebdf8-aa20-48e9-b0ef-028cfacbe26f.jpeg"
|
||||
},
|
||||
"organization": {
|
||||
"name": "Baumbach Group",
|
||||
"name": "Hansen-Turner",
|
||||
"username": "org60",
|
||||
"slug": "org60",
|
||||
"profile_image": "/uploads/organization/profile_image/65/0bccbabf-3f76-473b-8c5e-bac56178315b.png",
|
||||
"profile_image_90": "/uploads/organization/profile_image/65/0bccbabf-3f76-473b-8c5e-bac56178315b.png"
|
||||
"profile_image": "/uploads/organization/profile_image/86/d8bc51d9-ed07-4efd-9806-10901c0e488c.png",
|
||||
"profile_image_90": "/uploads/organization/profile_image/86/d8bc51d9-ed07-4efd-9806-10901c0e488c.png"
|
||||
},
|
||||
"flare_tag": {
|
||||
"name": "discuss",
|
||||
|
|
@ -165,7 +175,9 @@
|
|||
"/api/articles/{id}/unpublish": {
|
||||
"put": {
|
||||
"summary": "Unpublish an article",
|
||||
"tags": ["articles"],
|
||||
"tags": [
|
||||
"articles"
|
||||
],
|
||||
"description": "This endpoint allows the client to unpublish an article.\n\nThe user associated with the API key must have any 'admin' or 'moderator' role.\n\nThe article will be unpublished and will no longer be visible to the public. It will remain\nin the database and will set back to draft status on the author's posts dashboard. Any\nnotifications associated with the article will be deleted. Any comments on the article\nwill remain.",
|
||||
"operationId": "unpublishArticle",
|
||||
"parameters": [
|
||||
|
|
@ -224,14 +236,18 @@
|
|||
"/api/display_ads": {
|
||||
"get": {
|
||||
"summary": "display ads",
|
||||
"tags": ["display ads"],
|
||||
"tags": [
|
||||
"display ads"
|
||||
],
|
||||
"description": "This endpoint allows the client to retrieve a list of all display ads.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": []
|
||||
"example": [
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -252,7 +268,9 @@
|
|||
"/api/display_ads/{id}": {
|
||||
"get": {
|
||||
"summary": "display ad",
|
||||
"tags": ["display ads"],
|
||||
"tags": [
|
||||
"display ads"
|
||||
],
|
||||
"description": "This endpoint allows the client to retrieve a single display ad, via its id.",
|
||||
"parameters": [
|
||||
{
|
||||
|
|
@ -274,23 +292,25 @@
|
|||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"id": 10,
|
||||
"id": 5,
|
||||
"approved": false,
|
||||
"body_markdown": "Hello _hey_ Hey hey 5",
|
||||
"cached_tag_list": "",
|
||||
"clicks_count": 0,
|
||||
"created_at": "2022-11-17T10:30:32.066+01:00",
|
||||
"created_at": "2022-11-22T16:41:21.333+01:00",
|
||||
"display_to": "all",
|
||||
"impressions_count": 0,
|
||||
"name": "Display Ad 10",
|
||||
"organization_id": 66,
|
||||
"name": "Display Ad 5",
|
||||
"organization_id": 87,
|
||||
"placement_area": "sidebar_left",
|
||||
"processed_html": "<p>Hello <em>hey</em> Hey hey 5</p>",
|
||||
"published": false,
|
||||
"success_rate": 0.0,
|
||||
"type_of": "in_house",
|
||||
"updated_at": "2022-11-17T10:30:32.069+01:00",
|
||||
"tag_list": []
|
||||
"updated_at": "2022-11-22T16:41:21.336+01:00",
|
||||
"tag_list": [
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -323,7 +343,9 @@
|
|||
"/api/reactions/toggle": {
|
||||
"post": {
|
||||
"summary": "toggle reaction",
|
||||
"tags": ["reactions"],
|
||||
"tags": [
|
||||
"reactions"
|
||||
],
|
||||
"description": "This endpoint allows the client to toggle the user's reaction to a specified reactable (eg, Article, Comment, or User). For examples:\n * \"Like\"ing an Article will create a new \"like\" Reaction from the user for that Articles\n * \"Like\"ing that Article a second time will remove the \"like\" from the user",
|
||||
"parameters": [
|
||||
{
|
||||
|
|
@ -332,7 +354,11 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": ["like", "readinglist", "unicorn"]
|
||||
"enum": [
|
||||
"like",
|
||||
"readinglist",
|
||||
"unicorn"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -350,7 +376,11 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": ["Comment", "Article", "User"]
|
||||
"enum": [
|
||||
"Comment",
|
||||
"Article",
|
||||
"User"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
@ -363,7 +393,7 @@
|
|||
"result": "create",
|
||||
"category": "like",
|
||||
"id": 1,
|
||||
"reactable_id": 195,
|
||||
"reactable_id": 247,
|
||||
"reactable_type": "Article"
|
||||
}
|
||||
}
|
||||
|
|
@ -386,7 +416,9 @@
|
|||
"/api/reactions": {
|
||||
"post": {
|
||||
"summary": "create reaction",
|
||||
"tags": ["reactions"],
|
||||
"tags": [
|
||||
"reactions"
|
||||
],
|
||||
"description": "This endpoint allows the client to create a reaction to a specified reactable (eg, Article, Comment, or User). For examples:\n * \"Like\"ing an Article will create a new \"like\" Reaction from the user for that Articles\n * \"Like\"ing that Article a second time will return the previous \"like\"",
|
||||
"parameters": [
|
||||
{
|
||||
|
|
@ -395,7 +427,11 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": ["like", "readinglist", "unicorn"]
|
||||
"enum": [
|
||||
"like",
|
||||
"readinglist",
|
||||
"unicorn"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -413,7 +449,11 @@
|
|||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": ["Comment", "Article", "User"]
|
||||
"enum": [
|
||||
"Comment",
|
||||
"Article",
|
||||
"User"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
@ -426,7 +466,7 @@
|
|||
"result": "none",
|
||||
"category": "like",
|
||||
"id": 3,
|
||||
"reactable_id": 197,
|
||||
"reactable_id": 249,
|
||||
"reactable_type": "Article"
|
||||
}
|
||||
}
|
||||
|
|
@ -446,10 +486,34 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/api/users/{id}": {
|
||||
"get": {
|
||||
"summary": "A User",
|
||||
"tags": [
|
||||
"users"
|
||||
],
|
||||
"description": "This endpoint allows the client to retrieve a single user, either by id\nor by the user's username.\n\nFor complete documentumenation, see the v0 API docs: https://developers.forem.com/api/v0#tag/users/operation/getUser",
|
||||
"operationId": "getUser",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/users/{id}/unpublish": {
|
||||
"put": {
|
||||
"summary": "Unpublish a User's Articles and Comments",
|
||||
"tags": ["users"],
|
||||
"tags": [
|
||||
"users"
|
||||
],
|
||||
"description": "This endpoint allows the client to unpublish all of the articles and\ncomments created by a user.\n\nThe user associated with the API key must have any 'admin' or 'moderator' role.\n\nThis specified user's articles and comments will be unpublished and will no longer be\nvisible to the public. They will remain in the database and will set back to draft status\non the specified user's dashboard. Any notifications associated with the specified user's\narticles and comments will be deleted.\n\nNote this endpoint unpublishes articles and comments asychronously: it will return a 204 NO CONTENT\nstatus code immediately, but the articles and comments will not be unpublished until the\nrequest is completed on the server.",
|
||||
"operationId": "unpublishUser",
|
||||
"parameters": [
|
||||
|
|
@ -498,7 +562,9 @@
|
|||
"/api/users/{id}/suspend": {
|
||||
"put": {
|
||||
"summary": "Suspend a User",
|
||||
"tags": ["users"],
|
||||
"tags": [
|
||||
"users"
|
||||
],
|
||||
"description": "This endpoint allows the client to suspend a user.\n\nThe user associated with the API key must have any 'admin' or 'moderator' role.\n\nThis specified user will be assigned the 'suspended' role. Suspending a user will stop the\nuser from posting new posts and comments. It doesn't delete any of the user's content, just\nprevents them from creating new content while suspended. Users are not notified of their suspension\nin the UI, so if you want them to know about this, you must notify them.",
|
||||
"operationId": "suspendUser",
|
||||
"parameters": [
|
||||
|
|
@ -553,7 +619,9 @@
|
|||
],
|
||||
"security": [
|
||||
{
|
||||
"api-key": []
|
||||
"api-key": [
|
||||
|
||||
]
|
||||
}
|
||||
],
|
||||
"components": {
|
||||
|
|
@ -861,4 +929,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue