Skip to content

Node.js based forum software built for the modern web

fix: openapi test specs

gasovedcabec378f469
diff --git a/public/openapi/write/posts/pid/diffs.yaml b/public/openapi/write/posts/pid/diffs.yaml
index 5f0046781d..ea76f7ea66 100644
--- a/public/openapi/write/posts/pid/diffs.yaml
+++ b/public/openapi/write/posts/pid/diffs.yaml
@@ -27,14 +27,14 @@ get:
timestamps:
type: array
items:
- type: number
+ type: string
revisions:
type: array
items:
type: object
properties:
timestamp:
- type: number
+ type: string
username:
type: string
editable:
diff --git a/public/openapi/write/posts/pid/diffs/timestamp.yaml b/public/openapi/write/posts/pid/diffs/timestamp.yaml
index 205c7e1e37..15d942fc26 100644
--- a/public/openapi/write/posts/pid/diffs/timestamp.yaml
+++ b/public/openapi/write/posts/pid/diffs/timestamp.yaml
@@ -22,16 +22,4 @@ delete:
'200':
description: Post diff successfully deleted
content:
- application/json:
- schema:
- type: object
- properties:
- status:
- $ref: ../../../../components/schemas/Status.yaml#/Status
- response:
- type: object
- properties: {}
- '400':
- $ref: ../../../../components/responses/400.yaml#/400
- '403':
- $ref: ../../../../components/responses/403.yaml#/403
\ No newline at end of file
+ $ref: ../diffs.yaml#/get/responses/200/content
\ No newline at end of file
diff --git a/src/api/posts.js b/src/api/posts.js
index 3801c2598b..fdef453be3 100644
--- a/src/api/posts.js
+++ b/src/api/posts.js
@@ -266,7 +266,8 @@ postsAPI.getDiffs = async (caller, data) => {
privileges.users.isModerator(caller.uid, cid),
]);
- timestamps.push(post.timestamp);
+ // timestamps returned by posts.diffs.list are strings
+ timestamps.push(String(post.timestamp));
return {
timestamps: timestamps,
diff --git a/test/api.js b/test/api.js
index a85143910d..20956ee361 100644
--- a/test/api.js
+++ b/test/api.js
@@ -18,6 +18,7 @@ const user = require('../src/user');
const groups = require('../src/groups');
const categories = require('../src/categories');
const topics = require('../src/topics');
+const posts = require('../src/posts');
const plugins = require('../src/plugins');
const flags = require('../src/flags');
const messaging = require('../src/messaging');
@@ -74,6 +75,18 @@ describe('API', async () => {
example: '', // to be defined below...
},
],
+ '/posts/{pid}/diffs/{timestamp}': [
+ {
+ in: 'path',
+ name: 'pid',
+ example: '', // to be defined below...
+ },
+ {
+ in: 'path',
+ name: 'timestamp',
+ example: '', // to be defined below...
+ },
+ ],
},
};
@@ -123,7 +136,7 @@ describe('API', async () => {
const testCategory = await categories.create({ name: 'test' });
// Post a new topic
- const testTopic = await topics.post({
+ await topics.post({
uid: adminUid,
cid: testCategory.cid,
title: 'Test Topic',
@@ -142,6 +155,16 @@ describe('API', async () => {
content: 'Test topic 3 content',
});
+ // Create a post diff
+ await posts.edit({
+ uid: adminUid,
+ pid: unprivTopic.postData.pid,
+ content: 'Test topic 2 edited content',
+ req: {},
+ });
+ mocks.delete['/posts/{pid}/diffs/{timestamp}'][0].example = unprivTopic.postData.pid;
+ mocks.delete['/posts/{pid}/diffs/{timestamp}'][1].example = (await posts.diffs.list(unprivTopic.postData.pid))[0];
+
// Create a sample flag
await flags.create('post', 1, unprivUid, 'sample reasons', Date.now());