Skip to content

Node.js based forum software built for the modern web

fix(openapi): final fixes to schemas

Julian Lam14e5c24ec5f8
diff --git a/public/openapi/components/schemas/PostObject.yaml b/public/openapi/components/schemas/PostObject.yaml
index 563d682905..fc2da47e12 100644
--- a/public/openapi/components/schemas/PostObject.yaml
+++ b/public/openapi/components/schemas/PostObject.yaml
@@ -90,7 +90,7 @@ PostObject:
isMainPost:
type: boolean
renamed:
- type: true
+ type: boolean
tags:
type: array
items:
diff --git a/public/openapi/read/groups.yaml b/public/openapi/read/groups.yaml
index 55ef1c2c18..90a8c31d1d 100644
--- a/public/openapi/read/groups.yaml
+++ b/public/openapi/read/groups.yaml
@@ -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:
diff --git a/public/openapi/read/unread.yaml b/public/openapi/read/unread.yaml
index c6e8f16cf0..68555426e1 100644
--- a/public/openapi/read/unread.yaml
+++ b/public/openapi/read/unread.yaml
@@ -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:
diff --git a/test/api.js b/test/api.js
index 837e0f8190..2ee58fc0dd 100644
--- a/test/api.js
+++ b/test/api.js
@@ -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', () => {