mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
fix: openapi test specs
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
$ref: ../diffs.yaml#/get/responses/200/content
|
||||
@@ -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,
|
||||
|
||||
25
test/api.js
25
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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user