diff --git a/exam/api/Posts/Posts.php b/exam/api/Posts/Posts.php
new file mode 100644
index 0000000..1513594
--- /dev/null
+++ b/exam/api/Posts/Posts.php
@@ -0,0 +1,20 @@
+
- Requires logged in user to have admin permissions.
+ description: List all users.
security:
- BasicAuth: []
+ parameters:
+ - in: query
+ name: p
+ schema:
+ type: integer
+ minimum: 0
+ default: 0
+ description: Current page.
+ - in: query
+ name: l
+ schema:
+ type: integer
+ minimum: 0
+ maximum: 30
+ default: 10
+ description: The number of items to return.
responses:
200:
description: Success
@@ -175,46 +190,50 @@ paths:
examples:
Success:
value:
- [
- {
- "id": 1,
- "username": "Admin",
- "status": 1,
- "email": "marvin@zedat.fu-berlin.de",
- "image": "669d41fbdb56b.png",
- "isAdmin": true,
- "memberSince":
+ {
+ "pages": 1,
+ "data":
+ [
{
- "date": "2024-07-22 14:02:49.000000",
- "timezone_type": 3,
- "timezone": "Europe/Berlin",
+ "id": 1,
+ "username": "Admin",
+ "status": 1,
+ "email": "marvin@zedat.fu-berlin.de",
+ "image": "669d41fbdb56b.png",
+ "isAdmin": true,
+ "memberSince":
+ {
+ "date": "2024-07-22 14:02:49.000000",
+ "timezone_type": 3,
+ "timezone": "Europe/Berlin",
+ },
+ "postCount": 3,
},
- "postCount": 3,
- },
- {
- "id": 2,
- "username": "Max",
- "status": 1,
- "email": "max@moritz.net",
- "image": "profilbilder/max.svg",
- "isAdmin": false,
- "memberSince":
{
- "date": "2024-07-22 03:07:41.000000",
- "timezone_type": 3,
- "timezone": "Europe/Berlin",
+ "id": 2,
+ "username": "Max",
+ "status": 1,
+ "email": "max@moritz.net",
+ "image": "profilbilder/max.svg",
+ "isAdmin": false,
+ "memberSince":
+ {
+ "date": "2024-07-22 03:07:41.000000",
+ "timezone_type": 3,
+ "timezone": "Europe/Berlin",
+ },
+ "postCount": 2,
},
- "postCount": 2,
- },
- ]
+ ],
+ }
tags:
- User
/user{id}:
get:
summary: Get user
- description: Get user by ID
+ description: Get user by ID.
security:
- - BasicAuth: []
+ - BasicAuth: [isAdmin]
parameters:
- name: id
in: path
@@ -225,7 +244,7 @@ paths:
format: int14
responses:
200:
- description: Success
+ description: Success.
content:
application/json:
schema:
@@ -249,7 +268,7 @@ paths:
"postCount": 3,
}
404:
- description: User not found
+ description: User not found.
content:
application/json:
schema:
@@ -266,7 +285,7 @@ paths:
Use special ID self to update logged in user.
Requires logged in user to have admin permissions for any ID other than self.
security:
- - BasicAuth: []
+ - BasicAuth: [isAdmin]
parameters:
- name: id
in: path
@@ -282,7 +301,7 @@ paths:
$ref: "#/components/schemas/UserUpdateRequest"
responses:
200:
- description: Success
+ description: Success.
content:
application/json:
schema:
@@ -291,7 +310,7 @@ paths:
Success:
value: true
404:
- description: User not found
+ description: User not found.
content:
application/json:
schema:
@@ -300,7 +319,7 @@ paths:
User not found:
value: { "message": "User not found" }
500:
- description: Update failed
+ description: Update failed.
content:
application/json:
schema:
@@ -312,10 +331,9 @@ paths:
- User
delete:
summary: Delete user
- description: Delete user with ID.
- Requires logged in user to have admin permissions.
+ description: Delete user with ID.
security:
- - BasicAuth: []
+ - BasicAuth: [isAdmin]
parameters:
- name: id
in: path
@@ -326,7 +344,7 @@ paths:
format: int14
responses:
200:
- description: Success
+ description: Success.
content:
application/json:
schema:
@@ -335,7 +353,7 @@ paths:
Success:
value: true
404:
- description: User not found
+ description: User not found.
content:
application/json:
schema:
@@ -345,7 +363,129 @@ paths:
value: { "message": "User not found" }
tags:
- User
-
+ /posts:
+ get:
+ summary: List posts
+ description: List all posts, return full user data if authenticated.
+ security:
+ - {}
+ - BasicAuth: []
+ parameters:
+ - in: query
+ name: p
+ schema:
+ type: integer
+ minimum: 0
+ default: 0
+ description: Current page.
+ - in: query
+ name: l
+ schema:
+ type: integer
+ minimum: 0
+ maximum: 30
+ default: 10
+ description: The number of items to return.
+ responses:
+ 200:
+ description: Success.
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/PostListResponse"
+ examples:
+ Not authenticated:
+ value:
+ {
+ "pages": 1,
+ "data":
+ [
+ {
+ "id": 1,
+ "user": { "username": "Admin" },
+ "content": "Hey,\r\nGästebucher sind cool…\r\nDas Gästebuch ist freigegeben.\r\nIch hoffe auf viele Beiträge!",
+ "postedAt":
+ {
+ "date": "2020-03-03 09:03:00.000000",
+ "timezone_type": 3,
+ "timezone": "Europe/Berlin",
+ },
+ },
+ {
+ "id": 2,
+ "user": { "username": "Max" },
+ "content": "Bin über Google auf deine Seite gestoßen, danke für das geniale Gästebuch. Werde in Zukunft des Öftern vorbeischaun…\r\n\r\nLiebe Grüsse, Max",
+ "postedAt":
+ {
+ "date": "2020-03-04 12:26:40.000000",
+ "timezone_type": 3,
+ "timezone": "Europe/Berlin",
+ },
+ },
+ ],
+ }
+ Authenticated:
+ value:
+ {
+ "pages": 1,
+ "data":
+ [
+ {
+ "id": 1,
+ "user":
+ {
+ "id": 1,
+ "username": "Admin",
+ "status": 1,
+ "email": "marvin@zedat.fu-berlin.de",
+ "image": "669d41fbdb56b.png",
+ "isAdmin": true,
+ "memberSince":
+ {
+ "date": "2024-07-22 14:02:49.000000",
+ "timezone_type": 3,
+ "timezone": "Europe/Berlin",
+ },
+ "postCount": 3,
+ },
+ "content": "Hey,\r\nGästebucher sind cool…\r\nDas Gästebuch ist freigegeben.\r\nIch hoffe auf viele Beiträge!",
+ "postedAt":
+ {
+ "date": "2020-03-03 09:03:00.000000",
+ "timezone_type": 3,
+ "timezone": "Europe/Berlin",
+ },
+ },
+ {
+ "id": 2,
+ "user":
+ {
+ "id": 2,
+ "username": "Max",
+ "status": 1,
+ "email": "max@moritz.net",
+ "image": "profilbilder/max.svg",
+ "isAdmin": false,
+ "memberSince":
+ {
+ "date": "2024-07-22 03:07:41.000000",
+ "timezone_type": 3,
+ "timezone": "Europe/Berlin",
+ },
+ "postCount": 2,
+ },
+ "content": "Bin über Google auf deine Seite gestoßen, danke für das geniale Gästebuch. Werde in Zukunft des Öftern vorbeischaun…\r\n\r\nLiebe Grüsse, Max",
+ "postedAt":
+ {
+ "date": "2020-03-04 12:26:40.000000",
+ "timezone_type": 3,
+ "timezone": "Europe/Berlin",
+ },
+ },
+ ],
+ }
+ tags:
+ - Post
externalDocs:
url: https://khofmann.userpage.fu-berlin.de/phpCourse/exam/api/docs/
security: []
@@ -430,9 +570,40 @@ components:
type: string
format: uuid4
UserListResponse:
- type: array
- items:
- $ref: "#/components/schemas/UserResponse"
+ type: object
+ properties:
+ pages:
+ type: number
+ data:
+ type: array
+ items:
+ $ref: "#/components/schemas/UserResponse"
+ PostResponse:
+ type: object
+ properties:
+ id:
+ type: number
+ user:
+ $ref: "#/components/schemas/UserResponse"
+ postedAt:
+ type: object
+ properties:
+ date:
+ type: string
+ format: date-time
+ timezone_type:
+ type: number
+ timezone:
+ type: string
+ PostListResponse:
+ type: object
+ properties:
+ pages:
+ type: number
+ data:
+ type: array
+ items:
+ $ref: "#/components/schemas/PostResponse"
securitySchemes:
BasicAuth:
type: apiKey
@@ -442,3 +613,4 @@ tags:
- name: Login/Logout
- name: Register
- name: User
+ - name: Post
diff --git a/exam/api/docs/index.html b/exam/api/docs/index.html
index fc773ba..d74706a 100644
--- a/exam/api/docs/index.html
+++ b/exam/api/docs/index.html
@@ -131,6 +131,14 @@ data-styled.g32[id="sc-euGpHm"]{content:"fwfkcU,"}/*!sc*/
data-styled.g33[id="sc-pFPEP"]{content:"bMXXJy,"}/*!sc*/
.bWVgjU{position:relative;}/*!sc*/
data-styled.g37[id="sc-dJDBYC"]{content:"bWVgjU,"}/*!sc*/
+.FdjRy{position:absolute;pointer-events:none;z-index:1;top:50%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);right:8px;margin:auto;text-align:center;}/*!sc*/
+.FdjRy polyline{color:white;}/*!sc*/
+data-styled.g38[id="sc-kTYLvb"]{content:"FdjRy,"}/*!sc*/
+.dQFPeA{box-sizing:border-box;min-width:100px;outline:none;display:inline-block;border-radius:2px;border:1px solid rgba(38, 50, 56, 0.5);vertical-align:bottom;padding:2px 0px 2px 6px;position:relative;width:auto;background:white;color:#263238;font-family:Montserrat,sans-serif;font-size:0.929em;line-height:1.5em;cursor:pointer;transition:border 0.25s ease,color 0.25s ease,box-shadow 0.25s ease;}/*!sc*/
+.dQFPeA label{box-sizing:border-box;min-width:100px;outline:none;display:inline-block;font-family:Montserrat,sans-serif;color:#333333;vertical-align:bottom;width:auto;text-transform:none;padding:0 22px 0 4px;font-size:0.929em;line-height:1.5em;font-family:inherit;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}/*!sc*/
+.dQFPeA .dropdown-select{position:absolute;top:0;left:0;width:100%;height:100%;opacity:0;border:none;appearance:none;cursor:pointer;color:#333333;line-height:inherit;font-family:inherit;}/*!sc*/
+.dQFPeA:hover,.dQFPeA:focus-within{border:1px solid #32329f;color:#32329f;box-shadow:0px 0px 0px 1px #32329f;}/*!sc*/
+data-styled.g39[id="sc-dorvvM"]{content:"dQFPeA,"}/*!sc*/
.fafqZb{margin-left:10px;text-transform:none;font-size:0.929em;color:black;}/*!sc*/
data-styled.g41[id="sc-dwYcXH"]{content:"fafqZb,"}/*!sc*/
.kqJXdD{font-family:Roboto,sans-serif;font-weight:400;line-height:1.5em;}/*!sc*/
@@ -213,6 +221,10 @@ data-styled.g51[id="sc-ZubPq"]{content:"KmnOC,"}/*!sc*/
data-styled.g52[id="sc-foMnoT"]{content:"dmNpjh,"}/*!sc*/
.iLXIA-d{position:relative;}/*!sc*/
data-styled.g53[id="sc-WChnI"]{content:"iLXIA-d,"}/*!sc*/
+.hzaARH{margin:0 0 10px 0;display:block;background-color:rgba(38,50,56,0.4);border:none;padding:0.9em 1.6em 0.9em 0.9em;box-shadow:none;}/*!sc*/
+.hzaARH label{color:#ffffff;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;font-size:1em;text-transform:none;border:none;}/*!sc*/
+.hzaARH:hover,.hzaARH:focus-within{border:none;box-shadow:none;background-color:rgba(38,50,56,0.7);}/*!sc*/
+data-styled.g54[id="sc-flUsNl"]{content:"hzaARH,"}/*!sc*/
.gDrQpr{margin-top:15px;}/*!sc*/
data-styled.g56[id="sc-AmOMz"]{content:"gDrQpr,"}/*!sc*/
.bJcEcT{vertical-align:middle;font-size:13px;line-height:20px;}/*!sc*/
@@ -223,6 +235,12 @@ data-styled.g59[id="sc-cvzDha"]{content:"kDPMlG,"}/*!sc*/
data-styled.g60[id="sc-gKROGD"]{content:"etUsjc,"}/*!sc*/
.gLEAmN{color:#d41f1c;font-size:0.9em;font-weight:normal;margin-left:20px;line-height:1;}/*!sc*/
data-styled.g62[id="sc-hrDJJk"]{content:"gLEAmN,"}/*!sc*/
+.iWjUHw{border-radius:2px;word-break:break-word;background-color:rgba(51,51,51,0.05);color:rgba(51,51,51,0.9);padding:0 5px;border:1px solid rgba(51,51,51,0.1);font-family:Courier,monospace;}/*!sc*/
++{margin-left:0;}/*!sc*/
+data-styled.g66[id="sc-cDelgQ"]{content:"iWjUHw,"}/*!sc*/
+.hcQlsz{border-radius:2px;background-color:rgba(104,104,207,0.05);color:rgba(50,50,159,0.9);margin:0 5px;padding:0 5px;border:1px solid rgba(50,50,159,0.1);}/*!sc*/
++{margin-left:0;}/*!sc*/
+data-styled.g68[id="sc-fsKlOa"]{content:"hcQlsz,"}/*!sc*/
.dHStET{margin:1em 0;}/*!sc*/
.dHStET a{text-decoration:auto;color:#32329f;}/*!sc*/
.dHStET a:visited{color:#32329f;}/*!sc*/
@@ -366,7 +384,7 @@ data-styled.g137[id="sc-kvXgyf"]{content:"fBvPoH,"}/*!sc*/
trueList all posts, return full user data if authenticated.
+| p | integer >= 0 Default: 0 Current page. + |
| l | integer [ 0 .. 30 ] Default: 10 The number of items to return. + |
{- "pages": 1,
- "data": [
- {
- "id": 1,
- "user": {
- "username": "Admin"
}, - "content": "Hey,\r\nGästebucher sind cool…\r\nDas Gästebuch ist freigegeben.\r\nIch hoffe auf viele Beiträge!",
- "postedAt": {
- "date": "2020-03-03 09:03:00.000000",
- "timezone_type": 3,
- "timezone": "Europe/Berlin"
}
}, - {
- "id": 2,
- "user": {
- "username": "Max"
}, - "content": "Bin über Google auf deine Seite gestoßen, danke für das geniale Gästebuch. Werde in Zukunft des Öftern vorbeischaun…\r\n\r\nLiebe Grüsse, Max",
- "postedAt": {
- "date": "2020-03-04 12:26:40.000000",
- "timezone_type": 3,
- "timezone": "Europe/Berlin"
}
}
]
}