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.yamlindex 563d682905..fc2da47e12 100644--- a/public/openapi/components/schemas/PostObject.yaml+++ b/public/openapi/components/schemas/PostObject.yaml@@ -90,7 +90,7 @@ PostObject:isMainPost:type: booleanrenamed:- type: true+ type: booleantags:type: arrayitems:diff --git a/public/openapi/read/groups.yaml b/public/openapi/read/groups.yamlindex 55ef1c2c18..90a8c31d1d 100644--- a/public/openapi/read/groups.yaml+++ b/public/openapi/read/groups.yaml@@ -20,10 +20,6 @@ get:type: stringdescription:type: string- deleted:- oneOf:- - type: number- - type: stringhidden:type: numbersystem:@@ -94,8 +90,6 @@ get:example: "#f44336"truncated:type: boolean- ownerUid:- type: numberallowGroupCreation:type: booleannextStart:diff --git a/public/openapi/read/unread.yaml b/public/openapi/read/unread.yamlindex c6e8f16cf0..68555426e1 100644--- a/public/openapi/read/unread.yaml+++ b/public/openapi/read/unread.yaml@@ -51,10 +51,13 @@ get:type: numberteaserPid:type: number+ nullable: trueupvotes:type: numberdownvotes:type: number+ deleterUid:+ type: numberdeleted:type: numberlocked:@@ -84,7 +87,7 @@ get:type: stringicon:type: string- image:+ backgroundImage:nullable: trueimageClass: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_readableteaser:type: object+ nullable: trueproperties:pid:type: number@@ -206,8 +223,6 @@ get:type: stringindex:type: number- isQuestion:- nullable: truetopicCount:type: numbertitle:diff --git a/test/api.js b/test/api.jsindex 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 flagawait flags.create('post', 1, unprivUid, 'sample reasons', Date.now());@@ -103,6 +110,9 @@ describe('Read API', async () => {// Create a new chat roomawait 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 userawait 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', () => {