Skip to content

Node.js based forum software built for the modern web

docs: openapi schema for user/group exist check, session deletion

Julian Lambcccb331db35
diff --git a/public/openapi/write.yaml b/public/openapi/write.yaml
index 35fed4b3fe..c3396ea4ad 100644
--- a/public/openapi/write.yaml
+++ b/public/openapi/write.yaml
@@ -42,6 +42,8 @@ paths:
$ref: 'write/users/uid/ban.yaml'
/users/{uid}/tokens/{token}:
$ref: 'write/users/uid/tokens/token.yaml'
+ /users/{uid}/sessions/{uuid}:
+ $ref: 'write/users/uid/sessions/uuid.yaml'
/categories/:
$ref: 'write/categories.yaml'
/groups/:
diff --git a/public/openapi/write/groups/slug.yaml b/public/openapi/write/groups/slug.yaml
index eb867a6897..28077e290c 100644
--- a/public/openapi/write/groups/slug.yaml
+++ b/public/openapi/write/groups/slug.yaml
@@ -1,3 +1,20 @@
+head:
+ tags:
+ - groups
+ summary: check if a group exists
+ parameters:
+ - in: path
+ name: slug
+ schema:
+ type: string
+ required: true
+ description: group slug (that also acts as its identifier) to check
+ example: my-test-group
+ responses:
+ '200':
+ description: group found
+ '404':
+ description: group not found
delete:
tags:
- groups
diff --git a/public/openapi/write/users/uid.yaml b/public/openapi/write/users/uid.yaml
index f615c105a8..1e2878364a 100644
--- a/public/openapi/write/users/uid.yaml
+++ b/public/openapi/write/users/uid.yaml
@@ -1,3 +1,20 @@
+head:
+ tags:
+ - users
+ summary: check if a user exists
+ parameters:
+ - in: path
+ name: uid
+ schema:
+ type: integer
+ required: true
+ description: uid of the user to check
+ example: 3
+ responses:
+ '200':
+ description: user found
+ '404':
+ description: user not found
delete:
tags:
- users
diff --git a/public/openapi/write/users/uid/sessions/uuid.yaml b/public/openapi/write/users/uid/sessions/uuid.yaml
new file mode 100644
index 0000000000..4b01dee1e0
--- /dev/null
+++ b/public/openapi/write/users/uid/sessions/uuid.yaml
@@ -0,0 +1,31 @@
+delete:
+ tags:
+ - users
+ summary: revoke a user session
+ parameters:
+ - in: path
+ name: uid
+ schema:
+ type: integer
+ required: true
+ description: uid of the user's session
+ example: 3
+ - in: path
+ name: uuid
+ schema:
+ type: string
+ required: true
+ description: uuid of the user's session
+ example: 7c1a66b3-90e1-41f4-9f74-2b2edaebf917
+ responses:
+ '200':
+ description: user session revoked
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ status:
+ $ref: ../../../../components/schemas/Status.yaml#/Status
+ response:
+ type: object
\ No newline at end of file
diff --git a/src/routes/write/groups.js b/src/routes/write/groups.js
index 1f78447170..64af35bf70 100644
--- a/src/routes/write/groups.js
+++ b/src/routes/write/groups.js
@@ -10,8 +10,8 @@ const setupApiRoute = routeHelpers.setupApiRoute;
module.exports = function () {
const middlewares = [middleware.authenticate];
- setupApiRoute(router, 'head', '/:slug', [middleware.assert.group], controllers.write.groups.exists);
setupApiRoute(router, 'post', '/', [...middlewares, middleware.checkRequired.bind(null, ['name'])], controllers.write.groups.create);
+ setupApiRoute(router, 'head', '/:slug', [middleware.assert.group], controllers.write.groups.exists);
setupApiRoute(router, 'delete', '/:slug', [...middlewares, middleware.assert.group], controllers.write.groups.delete);
setupApiRoute(router, 'put', '/:slug/membership/:uid', [...middlewares, middleware.assert.group], controllers.write.groups.join);
setupApiRoute(router, 'delete', '/:slug/membership/:uid', [...middlewares, middleware.assert.group], controllers.write.groups.leave);
diff --git a/test/api.js b/test/api.js
index 5e145abc83..fd7a8fc6bd 100644
--- a/test/api.js
+++ b/test/api.js
@@ -49,6 +49,18 @@ describe('API', async () => {
example: utils.generateUUID(),
},
],
+ '/users/{uid}/sessions/{uuid}': [
+ {
+ in: 'path',
+ name: 'uid',
+ example: 1,
+ },
+ {
+ in: 'path',
+ name: 'uuid',
+ example: '', // to be defined below...
+ },
+ ],
},
};
@@ -120,7 +132,7 @@ describe('API', async () => {
await socketUser.exportPosts({ uid: adminUid }, { uid: adminUid });
await socketUser.exportUploads({ uid: adminUid }, { uid: adminUid });
// wait for export child process to complete
- await wait(5000);
+ // await wait(5000);
// Attach a search hook so /api/search is enabled
plugins.registerHook('core', {