diff --git a/exam/api/Posts/Posts.php b/exam/api/Posts/Posts.php index 9be186b..9c9da71 100644 --- a/exam/api/Posts/Posts.php +++ b/exam/api/Posts/Posts.php @@ -30,7 +30,7 @@ class Posts extends Api // Throw 400 error if a required one is missing. $content = Input::post("content"); // This one is optional - $limit = constrain(0, 30, intval(Input::post("limit", 10))); + $limit = constrain(0, 30, intval(Input::get("l", 10))); if (empty($content)) throw ApiError::missingField(["content"]); // Get logged in user @@ -77,9 +77,11 @@ class Posts extends Api public function delete($id): void { + // Fetch ax(0, intval(Input::get("p", 0))); + $limit = constrain(0, 30, intval(Input::get("l", 10))); // Try delete, 404 if post was not found. try { - Response::json(Post::getByID($id)->delete()); + Response::json(Post::getByID($id)->delete($limit)); } catch (Exception $err) { switch ($err->getMessage()) { case "NotFound": diff --git a/exam/api/docs/api.yaml b/exam/api/docs/api.yaml index 6de1991..f1435c6 100644 --- a/exam/api/docs/api.yaml +++ b/exam/api/docs/api.yaml @@ -281,7 +281,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/PostResponse" + $ref: "#/components/schemas/PostDeleteResponse" 404: description: Post not found. content: @@ -697,6 +697,8 @@ components: type: number post: $ref: "#/components/schemas/PostResponse" + PostDeleteResponse: + $ref: "#/components/schemas/PostCreateResponse" PostListResponse: type: object properties: diff --git a/exam/api/docs/index.html b/exam/api/docs/index.html index cf9dc73..53b6a0e 100644 --- a/exam/api/docs/index.html +++ b/exam/api/docs/index.html @@ -454,7 +454,7 @@ data-styled.g137[id="sc-kvXgyf"]{content:"fBvPoH,"}/*!sc*/ " class="sc-euGpHm sc-exayXG fwfkcU kqJXdD sc-dHrNzZ dRdjww">
Success.
{- "id": 0,
- "user": {
- "id": 0,
- "username": "string",
- "status": 0,
- "email": "string",
- "image": "string",
- "isAdmin": true,
- "memberSince": {
- "date": "2019-08-24T14:15:22Z",
- "timezone_type": 0,
- "timezone": "string"
}, - "postCount": 0
}, - "content": "string",
- "postedAt": {
- "date": "2019-08-24T14:15:22Z",
- "timezone_type": 0,
- "timezone": "string"
}
}{- "pages": 0,
- "post": {
- "id": 0,
- "user": {
- "id": 0,
- "username": "string",
- "status": 0,
- "email": "string",
- "image": "string",
- "isAdmin": true,
- "memberSince": {
- "date": "2019-08-24T14:15:22Z",
- "timezone_type": 0,
- "timezone": "string"
}, - "postCount": 0
}, - "content": "string",
- "postedAt": {
- "date": "2019-08-24T14:15:22Z",
- "timezone_type": 0,
- "timezone": "string"
}
}
}Register a new user.
| username required | string |
| email required | string |
| password required | string |
{- "id": 0,
- "username": "string",
- "status": 0,
- "email": "string",
- "image": "string",
- "isAdmin": true,
- "memberSince": {
- "date": "2019-08-24T14:15:22Z",
- "timezone_type": 0,
- "timezone": "string"
}, - "postCount": 0
}