~vpzom/lotide

383592bbfc9faeeac5b8f250757c8220c81ca90e — Colin Reeder 11 months ago 3178d41
Replace "like" APIs with "your_vote"
3 files changed, 109 insertions(+), 91 deletions(-)

M openapi/openapi.json
M src/routes/api/comments.rs
M src/routes/api/posts.rs
M openapi/openapi.json => openapi/openapi.json +87 -91
@@ 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": [
					{

M src/routes/api/comments.rs => src/routes/api/comments.rs +11 -0
@@ 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),
            ),
    )
}

M src/routes/api/posts.rs => src/routes/api/posts.rs +11 -0
@@ 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),
                ),
        )
}