From 6018e8bee562b9eb73833318b816b4d68e00df6b Mon Sep 17 00:00:00 2001 From: Kilian Hofmann Date: Sat, 27 Jul 2024 17:01:24 +0200 Subject: [PATCH] Delete return pages --- exam/api/Posts/Posts.php | 6 ++++-- exam/api/docs/api.yaml | 4 +++- exam/api/docs/index.html | 4 ++-- exam/classes/Models/Post/Post.php | 13 +++++++++++-- 4 files changed, 20 insertions(+), 7 deletions(-) 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.

Response samples

Content type
application/json
{
  • "id": 0,
  • "user": {
    },
  • "content": "string",
  • "postedAt": {
    }
}

Register

Register

Response samples

Content type
application/json
{
  • "pages": 0,
  • "post": {
    }
}

Register

Register

Register a new user.

Request Body schema: application/json
required
username
required
string
email
required
string
password
required
string

Responses

Response samples

Content type
application/json
{
  • "id": 0,
  • "username": "string",
  • "status": 0,
  • "email": "string",
  • "image": "string",
  • "isAdmin": true,
  • "memberSince": {
    },
  • "postCount": 0
}