fix(openapi): final fixes to schemas

v1.18.x
Julian Lam 4 years ago
parent b2e9e3e048
commit 14e5c24ec5

@ -90,7 +90,7 @@ PostObject:
isMainPost:
type: boolean
renamed:
type: true
type: boolean
tags:
type: array
items:

@ -20,10 +20,6 @@ get:
type: string
description:
type: string
deleted:
oneOf:
- type: number
- type: string
hidden:
type: number
system:
@ -94,8 +90,6 @@ get:
example: "#f44336"
truncated:
type: boolean
ownerUid:
type: number
allowGroupCreation:
type: boolean
nextStart:

@ -51,10 +51,13 @@ get:
type: number
teaserPid:
type: number
nullable: true
upvotes:
type: number
downvotes:
type: number
deleterUid:
type: number
deleted:
type: number
locked:
@ -84,7 +87,7 @@ get:
type: string
icon:
type: string
image:
backgroundImage:
nullable: true
imageClass:
nullable: true
@ -138,8 +141,22 @@ get:
example: "#f44336"
banned_until_readable:
type: string
required:
- uid
- username
- userslug
- reputation
- postcount
- picture
- signature
- banned
- status
- icon:text
- icon:bgColor
- banned_until_readable
teaser:
type: object
nullable: true
properties:
pid:
type: number
@ -206,8 +223,6 @@ get:
type: string
index:
type: number
isQuestion:
nullable: true
topicCount:
type: number
title:

@ -2,6 +2,7 @@
const assert = require('assert');
const path = require('path');
const fs = require('fs');
const SwaggerParser = require('@apidevtools/swagger-parser');
const request = require('request-promise-native');
const nconf = require('nconf');
@ -96,6 +97,12 @@ describe('Read API', async () => {
title: 'Test Topic',
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
await flags.create('post', 1, unprivUid, 'sample reasons', Date.now());
@ -103,6 +110,9 @@ describe('Read API', async () => {
// Create a new chat room
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');
// export data for admin user
await socketUser.exportProfile({ uid: adminUid }, { uid: adminUid });
@ -142,7 +152,7 @@ describe('Read API', async () => {
readApi = await SwaggerParser.dereference(readApiPath);
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);
function generateTests(api, paths, prefix) {
@ -157,9 +167,9 @@ describe('Read API', async () => {
const qs = {};
Object.keys(context).forEach((_method) => {
// if (_method !== 'get') {
// return;
// }
if (api.info.title === 'NodeBB Read API' && _method !== 'get') {
return;
}
it('should have examples when parameters are present', () => {
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', () => {

Loading…
Cancel
Save