summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Reeder <colin@vpzom.click>2020-08-08 08:47:00 -0600
committerColin Reeder <colin@vpzom.click>2020-08-08 08:47:00 -0600
commit383592bbfc9faeeac5b8f250757c8220c81ca90e (patch)
treebabed5414c46ca4b8035633ef4251ad03567bfaf
parent3178d41ec7579e96d3d01488fd06510cdfa84b06 (diff)
Replace "like" APIs with "your_vote"
-rw-r--r--openapi/openapi.json178
-rw-r--r--src/routes/api/comments.rs11
-rw-r--r--src/routes/api/posts.rs11
3 files changed, 109 insertions, 91 deletions
diff --git a/openapi/openapi.json b/openapi/openapi.json
index d4b7329..a6df78c 100644
--- a/openapi/openapi.json
+++ b/openapi/openapi.json
@@ -248,9 +248,9 @@
"security": [{"bearer": []}]
}
},
- "/api/unstable/comments/{commentID}/like": {
+ "/api/unstable/comments/{commentID}/replies": {
"post": {
- "summary": "Like a comment",
+ "summary": "Reply to a comment",
"parameters": [
{
"name": "commentID",
@@ -259,15 +259,46 @@
"schema": {"type": "integer"}
}
],
- "responses": {
- "204": {
- "description": "Successfully liked."
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "content_text": {"type": "string"},
+ "content_markdown": {"type": "string"}
+ }
+ }
+ }
}
},
- "security": [{"bearer": []}]
+ "responses": {
+ "200": {
+ "description": "Successfully created reply.",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "required": ["id", "post"],
+ "properties": {
+ "id": {"type": "integer"},
+ "post": {
+ "type": "object",
+ "required": ["id"],
+ "properties": {
+ "id": {"type": "integer"}
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
},
- "/api/unstable/comments/{commentID}/likes": {
+ "/api/unstable/comments/{commentID}/votes": {
"get": {
"summary": "List likers of a comment",
"parameters": [
@@ -315,9 +346,9 @@
}
}
},
- "/api/unstable/comments/{commentID}/replies": {
- "post": {
- "summary": "Reply to a comment",
+ "/api/unstable/comments/{commentID}/your_vote": {
+ "put": {
+ "summary": "Like a comment",
"parameters": [
{
"name": "commentID",
@@ -326,47 +357,14 @@
"schema": {"type": "integer"}
}
],
- "requestBody": {
- "required": true,
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "content_text": {"type": "string"},
- "content_markdown": {"type": "string"}
- }
- }
- }
- }
- },
"responses": {
- "200": {
- "description": "Successfully created reply.",
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "required": ["id", "post"],
- "properties": {
- "id": {"type": "integer"},
- "post": {
- "type": "object",
- "required": ["id"],
- "properties": {
- "id": {"type": "integer"}
- }
- }
- }
- }
- }
- }
+ "204": {
+ "description": "Successfully liked."
}
- }
- }
- },
- "/api/unstable/comments/{commentID}/unlike": {
- "post": {
+ },
+ "security": [{"bearer": []}]
+ },
+ "delete": {
"summary": "Retract a like of a comment",
"parameters": [
{
@@ -903,9 +901,9 @@
"security": [{"bearer": []}]
}
},
- "/api/unstable/posts/{postID}/like": {
+ "/api/unstable/posts/{postID}/replies": {
"post": {
- "summary": "Like a post",
+ "summary": "Reply to a post",
"parameters": [
{
"name": "postID",
@@ -914,15 +912,39 @@
"schema": {"type": "integer"}
}
],
- "responses": {
- "204": {
- "description": "Successfully liked."
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "content_text": {"type": "string"},
+ "content_markdown": {"type": "string"}
+ }
+ }
+ }
}
},
- "security": [{"bearer": []}]
+ "responses": {
+ "200": {
+ "description": "Successfully created reply.",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "required": ["id", "post"],
+ "properties": {
+ "id": {"type": "integer"}
+ }
+ }
+ }
+ }
+ }
+ }
}
},
- "/api/unstable/posts/{postID}/likes": {
+ "/api/unstable/posts/{postID}/votes": {
"get": {
"summary": "List likers of a post",
"parameters": [
@@ -970,9 +992,9 @@
}
}
},
- "/api/unstable/posts/{postID}/replies": {
- "post": {
- "summary": "Reply to a post",
+ "/api/unstable/posts/{postID}/your_vote": {
+ "put": {
+ "summary": "Like a post",
"parameters": [
{
"name": "postID",
@@ -981,40 +1003,14 @@
"schema": {"type": "integer"}
}
],
- "requestBody": {
- "required": true,
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "content_text": {"type": "string"},
- "content_markdown": {"type": "string"}
- }
- }
- }
- }
- },
"responses": {
- "200": {
- "description": "Successfully created reply.",
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "required": ["id", "post"],
- "properties": {
- "id": {"type": "integer"}
- }
- }
- }
- }
+ "204": {
+ "description": "Successfully liked."
}
- }
- }
- },
- "/api/unstable/posts/{postID}/unlike": {
- "post": {
+ },
+ "security": [{"bearer": []}]
+ },
+ "delete": {
"summary": "Retract a like of a post",
"parameters": [
{
diff --git a/src/routes/api/comments.rs b/src/routes/api/comments.rs
index b608b80..f4c9fc6 100644
--- a/src/routes/api/comments.rs
+++ b/src/routes/api/comments.rs
@@ -605,6 +605,17 @@ pub fn route_comments() -> crate::RouteNode<()> {
"replies",
crate::RouteNode::new()
.with_handler_async("POST", route_unstable_comments_replies_create),
+ )
+ .with_child(
+ "votes",
+ crate::RouteNode::new()
+ .with_handler_async("GET", route_unstable_comments_likes_list),
+ )
+ .with_child(
+ "your_vote",
+ crate::RouteNode::new()
+ .with_handler_async("PUT", route_unstable_comments_like)
+ .with_handler_async("DELETE", route_unstable_comments_unlike),
),
)
}
diff --git a/src/routes/api/posts.rs b/src/routes/api/posts.rs
index c26609a..4562444 100644
--- a/src/routes/api/posts.rs
+++ b/src/routes/api/posts.rs
@@ -819,6 +819,17 @@ pub fn route_posts() -> crate::RouteNode<()> {
"replies",
crate::RouteNode::new()
.with_handler_async("POST", route_unstable_posts_replies_create),
+ )
+ .with_child(
+ "votes",
+ crate::RouteNode::new()
+ .with_handler_async("GET", route_unstable_posts_likes_list),
+ )
+ .with_child(
+ "your_vote",
+ crate::RouteNode::new()
+ .with_handler_async("PUT", route_unstable_posts_like)
+ .with_handler_async("DELETE", route_unstable_posts_unlike),
),
)
}