mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix(openapi): final fixes to schemas
This commit is contained in:
@@ -90,7 +90,7 @@ PostObject:
|
|||||||
isMainPost:
|
isMainPost:
|
||||||
type: boolean
|
type: boolean
|
||||||
renamed:
|
renamed:
|
||||||
type: true
|
type: boolean
|
||||||
tags:
|
tags:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ get:
|
|||||||
type: string
|
type: string
|
||||||
description:
|
description:
|
||||||
type: string
|
type: string
|
||||||
deleted:
|
|
||||||
oneOf:
|
|
||||||
- type: number
|
|
||||||
- type: string
|
|
||||||
hidden:
|
hidden:
|
||||||
type: number
|
type: number
|
||||||
system:
|
system:
|
||||||
@@ -94,8 +90,6 @@ get:
|
|||||||
example: "#f44336"
|
example: "#f44336"
|
||||||
truncated:
|
truncated:
|
||||||
type: boolean
|
type: boolean
|
||||||
ownerUid:
|
|
||||||
type: number
|
|
||||||
allowGroupCreation:
|
allowGroupCreation:
|
||||||
type: boolean
|
type: boolean
|
||||||
nextStart:
|
nextStart:
|
||||||
|
|||||||
@@ -51,10 +51,13 @@ get:
|
|||||||
type: number
|
type: number
|
||||||
teaserPid:
|
teaserPid:
|
||||||
type: number
|
type: number
|
||||||
|
nullable: true
|
||||||
upvotes:
|
upvotes:
|
||||||
type: number
|
type: number
|
||||||
downvotes:
|
downvotes:
|
||||||
type: number
|
type: number
|
||||||
|
deleterUid:
|
||||||
|
type: number
|
||||||
deleted:
|
deleted:
|
||||||
type: number
|
type: number
|
||||||
locked:
|
locked:
|
||||||
@@ -84,7 +87,7 @@ get:
|
|||||||
type: string
|
type: string
|
||||||
icon:
|
icon:
|
||||||
type: string
|
type: string
|
||||||
image:
|
backgroundImage:
|
||||||
nullable: true
|
nullable: true
|
||||||
imageClass:
|
imageClass:
|
||||||
nullable: true
|
nullable: true
|
||||||
@@ -138,8 +141,22 @@ get:
|
|||||||
example: "#f44336"
|
example: "#f44336"
|
||||||
banned_until_readable:
|
banned_until_readable:
|
||||||
type: string
|
type: string
|
||||||
|
required:
|
||||||
|
- uid
|
||||||
|
- username
|
||||||
|
- userslug
|
||||||
|
- reputation
|
||||||
|
- postcount
|
||||||
|
- picture
|
||||||
|
- signature
|
||||||
|
- banned
|
||||||
|
- status
|
||||||
|
- icon:text
|
||||||
|
- icon:bgColor
|
||||||
|
- banned_until_readable
|
||||||
teaser:
|
teaser:
|
||||||
type: object
|
type: object
|
||||||
|
nullable: true
|
||||||
properties:
|
properties:
|
||||||
pid:
|
pid:
|
||||||
type: number
|
type: number
|
||||||
@@ -206,8 +223,6 @@ get:
|
|||||||
type: string
|
type: string
|
||||||
index:
|
index:
|
||||||
type: number
|
type: number
|
||||||
isQuestion:
|
|
||||||
nullable: true
|
|
||||||
topicCount:
|
topicCount:
|
||||||
type: number
|
type: number
|
||||||
title:
|
title:
|
||||||
|
|||||||
20
test/api.js
20
test/api.js
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
const SwaggerParser = require('@apidevtools/swagger-parser');
|
const SwaggerParser = require('@apidevtools/swagger-parser');
|
||||||
const request = require('request-promise-native');
|
const request = require('request-promise-native');
|
||||||
const nconf = require('nconf');
|
const nconf = require('nconf');
|
||||||
@@ -96,6 +97,12 @@ describe('Read API', async () => {
|
|||||||
title: 'Test Topic',
|
title: 'Test Topic',
|
||||||
content: 'Test topic content',
|
content: 'Test topic content',
|
||||||
});
|
});
|
||||||
|
const unprivTopic = await topics.post({
|
||||||
|
uid: unprivUid,
|
||||||
|
cid: testCategory.cid,
|
||||||
|
title: 'Test Topic 2',
|
||||||
|
content: 'Test topic 2 content',
|
||||||
|
});
|
||||||
|
|
||||||
// Create a sample flag
|
// Create a sample flag
|
||||||
await flags.create('post', 1, unprivUid, 'sample reasons', Date.now());
|
await flags.create('post', 1, unprivUid, 'sample reasons', Date.now());
|
||||||
@@ -103,6 +110,9 @@ describe('Read API', async () => {
|
|||||||
// Create a new chat room
|
// Create a new chat room
|
||||||
await messaging.newRoom(1, [2]);
|
await messaging.newRoom(1, [2]);
|
||||||
|
|
||||||
|
// Create an empty file to test DELETE /files
|
||||||
|
fs.closeSync(fs.openSync(path.resolve(nconf.get('upload_path'), 'files/test.txt'), 'w'));
|
||||||
|
|
||||||
const socketUser = require('../src/socket.io/user');
|
const socketUser = require('../src/socket.io/user');
|
||||||
// export data for admin user
|
// export data for admin user
|
||||||
await socketUser.exportProfile({ uid: adminUid }, { uid: adminUid });
|
await socketUser.exportProfile({ uid: adminUid }, { uid: adminUid });
|
||||||
@@ -142,7 +152,7 @@ describe('Read API', async () => {
|
|||||||
readApi = await SwaggerParser.dereference(readApiPath);
|
readApi = await SwaggerParser.dereference(readApiPath);
|
||||||
writeApi = await SwaggerParser.dereference(writeApiPath);
|
writeApi = await SwaggerParser.dereference(writeApiPath);
|
||||||
|
|
||||||
// generateTests(readApi, Object.keys(readApi.paths));
|
generateTests(readApi, Object.keys(readApi.paths));
|
||||||
generateTests(writeApi, Object.keys(writeApi.paths), writeApi.servers[0].url);
|
generateTests(writeApi, Object.keys(writeApi.paths), writeApi.servers[0].url);
|
||||||
|
|
||||||
function generateTests(api, paths, prefix) {
|
function generateTests(api, paths, prefix) {
|
||||||
@@ -157,9 +167,9 @@ describe('Read API', async () => {
|
|||||||
const qs = {};
|
const qs = {};
|
||||||
|
|
||||||
Object.keys(context).forEach((_method) => {
|
Object.keys(context).forEach((_method) => {
|
||||||
// if (_method !== 'get') {
|
if (api.info.title === 'NodeBB Read API' && _method !== 'get') {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
it('should have examples when parameters are present', () => {
|
it('should have examples when parameters are present', () => {
|
||||||
method = _method;
|
method = _method;
|
||||||
@@ -187,7 +197,7 @@ describe('Read API', async () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
url = nconf.get('url') + prefix + testPath;
|
url = nconf.get('url') + (prefix || '') + testPath;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('may contain a request body with application/json type if POST/PUT/DELETE', () => {
|
it('may contain a request body with application/json type if POST/PUT/DELETE', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user