it('should expose openApi descriptor', async () => { const descriptor = await request({ method: 'GET', url: `${server.info.uri}/swagger.json`, json: true }) assert(descriptor.swagger === '2.0') assert(descriptor.basePath === '/api') assert.deepStrictEqual(descriptor.info, {title: 'API documentation', version}) })
it('should handle async API with exotic parameters', async () => { const result = await request({ method: 'POST', url: `${server.info.uri}/api/sample/withExoticParameters`, body: { param1: [1, 2], param2: {c: {d: 3}}, other: 4, 3: 5, // according to arrayToObj(), param0 is 0, param2 is 1, other is 2. 4: 6 }, json: true }) assert.deepStrictEqual(result, [1, 2, 3, 4, 5, 6]) })
it('should handle sync API with exotic parameters', async () => { const result = await request({ method: 'POST', url: `${server.info.uri}/api/synchronous/withExoticParameters`, body: { param1: [1, 2], param2: {c: {d: 3}}, other: 4, 3: 5, // according to arrayToObj(), param0 is 0, param2 is 1, other is 2. 4: 6 }, json: true }) assert.deepStrictEqual(result, [1, 2, 3, 4, 5, 6]) })