diff --git a/package.json b/package.json index 0bd4f508..bd25736c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scripts": { "combine-coverage": "istanbul-combine packages/*/coverage/coverage*.json", "coveralls": "cat ./coverage/lcov.info | coveralls -v", - "lint": "tslint ./packages/**/*.[j,t]s", + "lint": "tslint './packages/**/*.[j,t]s'", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/packages/express-openapi/test/initialization.ts b/packages/express-openapi/test/initialization.ts index 4df41199..1e59aec6 100644 --- a/packages/express-openapi/test/initialization.ts +++ b/packages/express-openapi/test/initialization.ts @@ -2,7 +2,10 @@ import { initialize } from '../'; const expect = require('chai').expect; const express = require('express'); const path = require('path'); -const routesDir = path.resolve(__dirname, './sample-projects/basic-usage/api-routes'); +const routesDir = path.resolve( + __dirname, + './sample-projects/basic-usage/api-routes' +); const validDocument = { swagger: '2.0', info: { @@ -16,18 +19,85 @@ describe(require('../package.json').name, () => { describe('.initialize()', () => { describe('args validation', () => { [ - ['args is not an object', null, /express-openapi: args must be an object/], - ['args.app must be an express app', {}, /express-openapi: args.app must be an express app/], - ['args.apiDoc required', {app: {}}, /express-openapi: args.apiDoc is required/], - ['args.apiDoc not valid', {app: {}, apiDoc: {}, paths: []}, /express-openapi: args.apiDoc was invalid. See the output./], - ['args.paths required', {app: {}, apiDoc: validDocument}, /express-openapi: args.paths is required/], - ['args.paths non directory', {app: {}, apiDoc: validDocument, paths: 'asdasdfasdf'}, /express-openapi: args.paths contained a value that was not a path to a directory/], - ['args.paths non directory', {app: {}, apiDoc: validDocument, paths: routesDir, docsPath: true}, /express-openapi: args.docsPath must be a string when given/], - ['args.paths with invalid route', {app: {}, apiDoc: validDocument, paths: [{foo: '/foo', bar: {}}]}, /express-openapi: args.paths must consist of strings or valid route specifications/], - ['args.paths with duplicates', {app: {}, apiDoc: validDocument, paths: [{path: '/foo', module: {}}, {path: '/foo', module:{}}]}, /express-openapi: args.paths produced duplicate urls/], - ['args.errorTransformer', {app: {}, apiDoc: validDocument, paths: routesDir, errorTransformer: 'asdf'}, /express-openapi: args.errorTransformer must be a function when given/], - ['args.externalSchemas', {app: {}, apiDoc: validDocument, paths: routesDir, externalSchemas: 'asdf'}, /express-openapi: args.externalSchemas must be a object when given/], - ['args.securityHandlers', {app: {}, apiDoc: validDocument, paths: routesDir, securityHandlers: 'asdf'}, /express-openapi: args.securityHandlers must be a object when given/], + [ + 'args is not an object', + null, + /express-openapi: args must be an object/ + ], + [ + 'args.app must be an express app', + {}, + /express-openapi: args.app must be an express app/ + ], + [ + 'args.apiDoc required', + { app: {} }, + /express-openapi: args.apiDoc is required/ + ], + [ + 'args.apiDoc not valid', + { app: {}, apiDoc: {}, paths: [] }, + /express-openapi: args.apiDoc was invalid. See the output./ + ], + [ + 'args.paths required', + { app: {}, apiDoc: validDocument }, + /express-openapi: args.paths is required/ + ], + [ + 'args.paths non directory', + { app: {}, apiDoc: validDocument, paths: 'asdasdfasdf' }, + /express-openapi: args.paths contained a value that was not a path to a directory/ + ], + [ + 'args.paths non directory', + { app: {}, apiDoc: validDocument, paths: routesDir, docsPath: true }, + /express-openapi: args.docsPath must be a string when given/ + ], + [ + 'args.paths with invalid route', + { app: {}, apiDoc: validDocument, paths: [{ foo: '/foo', bar: {} }] }, + /express-openapi: args.paths must consist of strings or valid route specifications/ + ], + [ + 'args.paths with duplicates', + { + app: {}, + apiDoc: validDocument, + paths: [{ path: '/foo', module: {} }, { path: '/foo', module: {} }] + }, + /express-openapi: args.paths produced duplicate urls/ + ], + [ + 'args.errorTransformer', + { + app: {}, + apiDoc: validDocument, + paths: routesDir, + errorTransformer: 'asdf' + }, + /express-openapi: args.errorTransformer must be a function when given/ + ], + [ + 'args.externalSchemas', + { + app: {}, + apiDoc: validDocument, + paths: routesDir, + externalSchemas: 'asdf' + }, + /express-openapi: args.externalSchemas must be a object when given/ + ], + [ + 'args.securityHandlers', + { + app: {}, + apiDoc: validDocument, + paths: routesDir, + securityHandlers: 'asdf' + }, + /express-openapi: args.securityHandlers must be a object when given/ + ] ].forEach((test: [string, object, RegExp]) => { const description: string = test[0]; const args = test[1]; @@ -44,20 +114,27 @@ describe(require('../package.json').name, () => { }); }); - it('should throw an error when a route method apiDoc is invalid', function() { + it('should throw an error when a route method apiDoc is invalid', () => { expect(() => { const app = express(); initialize({ apiDoc: require('./sample-projects/with-invalid-method-doc/api-doc.js'), - app: app, + app, docsPath: '/api-docs', // See https://github.com/kogosoftwarellc/express-openapi-validation#argserrortransformer // errorTransformer: null, // we could just pass in "api-routes" if process.cwd() was set to this directory. - paths: path.resolve(__dirname, 'sample-projects', 'with-invalid-method-doc', 'api-routes') + paths: path.resolve( + __dirname, + 'sample-projects', + 'with-invalid-method-doc', + 'api-routes' + ) }); - }).to.throw(/express-openapi: args.apiDoc was invalid after populating paths. See the output./); + }).to.throw( + /express-openapi: args.apiDoc was invalid after populating paths. See the output./ + ); }); it('should not throw an error when args.validateApiDoc is false and a route method apiDoc is invalid', () => { @@ -65,16 +142,20 @@ describe(require('../package.json').name, () => { initialize({ apiDoc: require('./sample-projects/with-invalid-method-doc/api-doc.js'), - app: app, + app, docsPath: '/api-docs', validateApiDoc: false, - paths: path.resolve(__dirname, 'sample-projects', 'with-invalid-method-doc', 'api-routes') + paths: path.resolve( + __dirname, + 'sample-projects', + 'with-invalid-method-doc', + 'api-routes' + ) }); }); it('should return the built apiDoc', () => { - const expectedApiDoc = require( - './../../../test/fixtures/basic-usage-api-doc-after-initialization.json'); + const expectedApiDoc = require('./../../../test/fixtures/basic-usage-api-doc-after-initialization.json'); const initializedApp = initialize({ apiDoc: require('./sample-projects/basic-usage/api-doc.js'), app: express(), @@ -87,15 +168,17 @@ describe(require('../package.json').name, () => { it('should require referenced parameter to exist', () => { expect(() => { require('./sample-projects/with-referenced-parameter-missing/app.js'); - }).to.throw(/Invalid parameter \$ref or definition not found in apiDoc\.parameters: #\/parameters\/Boo/); - + }).to.throw( + /Invalid parameter \$ref or definition not found in apiDoc\.parameters: #\/parameters\/Boo/ + ); }); it('should require referenced response to exist', () => { expect(() => { require('./sample-projects/with-referenced-response-missing/app.js'); - }).to.throw(/Invalid response \$ref or definition not found in apiDoc.responses: #\/responses\/SuccessResponse/); - + }).to.throw( + /Invalid response \$ref or definition not found in apiDoc.responses: #\/responses\/SuccessResponse/ + ); }); it('should not throw when security handlers are defined and no method doc exists on a handler', () => { diff --git a/packages/express-openapi/test/sample-projects.ts b/packages/express-openapi/test/sample-projects.ts index eb0a0852..c75f5f96 100644 --- a/packages/express-openapi/test/sample-projects.ts +++ b/packages/express-openapi/test/sample-projects.ts @@ -20,73 +20,153 @@ describe(require('../package.json').name + ' sample-projects', () => { [ // adding additional middleware - {name: 'with-additional-middleware', url: '/v3/users/34?name=fred', - expectedStatus: 200, expectedBody: { - orderingApiDoc: 'pathModule', - apiDocAdded: true, - pathDocAdded: true, - pathModuleAdded: true - }}, + { + name: 'with-additional-middleware', + url: '/v3/users/34?name=fred', + expectedStatus: 200, + expectedBody: { + orderingApiDoc: 'pathModule', + apiDocAdded: true, + pathDocAdded: true, + pathModuleAdded: true + } + }, // not inheriting additional middleware - {name: 'with-inherit-additional-middleware-false-at-methodDoc', url: '/v3/users/34?name=fred', - expectedStatus: 200, expectedBody: { - apiDocAdded: null, - pathDocAdded: null, - pathModuleAdded: null - }}, - {name: 'with-inherit-additional-middleware-false-at-pathDoc', url: '/v3/users/34?name=fred', - expectedStatus: 200, expectedBody: { - apiDocAdded: null, - pathDocAdded: true, - pathModuleAdded: true - }}, - {name: 'with-inherit-additional-middleware-false-at-pathModule', url: '/v3/users/34?name=fred', - expectedStatus: 200, expectedBody: { - apiDocAdded: null, - pathDocAdded: null, - pathModuleAdded: true - }}, + { + name: 'with-inherit-additional-middleware-false-at-methodDoc', + url: '/v3/users/34?name=fred', + expectedStatus: 200, + expectedBody: { + apiDocAdded: null, + pathDocAdded: null, + pathModuleAdded: null + } + }, + { + name: 'with-inherit-additional-middleware-false-at-pathDoc', + url: '/v3/users/34?name=fred', + expectedStatus: 200, + expectedBody: { + apiDocAdded: null, + pathDocAdded: true, + pathModuleAdded: true + } + }, + { + name: 'with-inherit-additional-middleware-false-at-pathModule', + url: '/v3/users/34?name=fred', + expectedStatus: 200, + expectedBody: { + apiDocAdded: null, + pathDocAdded: null, + pathModuleAdded: true + } + }, // disable coercion - {name: 'with-coercion-middleware-disabled-in-methodDoc', url: '/v3/users/34?name=fred', - expectedStatus: 400, expectedBody: coercionMissingBody}, - {name: 'with-coercion-middleware-disabled-in-pathItem', url: '/v3/users/34?name=fred', - expectedStatus: 400, expectedBody: coercionMissingBody}, - {name: 'with-coercion-middleware-disabled-in-pathModule', url: '/v3/users/34?name=fred', - expectedStatus: 400, expectedBody: coercionMissingBody}, - {name: 'with-coercion-middleware-disabled-in-the-apiDoc', url: '/v3/users/34?name=fred', - expectedStatus: 400, expectedBody: coercionMissingBody}, + { + name: 'with-coercion-middleware-disabled-in-methodDoc', + url: '/v3/users/34?name=fred', + expectedStatus: 400, + expectedBody: coercionMissingBody + }, + { + name: 'with-coercion-middleware-disabled-in-pathItem', + url: '/v3/users/34?name=fred', + expectedStatus: 400, + expectedBody: coercionMissingBody + }, + { + name: 'with-coercion-middleware-disabled-in-pathModule', + url: '/v3/users/34?name=fred', + expectedStatus: 400, + expectedBody: coercionMissingBody + }, + { + name: 'with-coercion-middleware-disabled-in-the-apiDoc', + url: '/v3/users/34?name=fred', + expectedStatus: 400, + expectedBody: coercionMissingBody + }, // disable defaults - {name: 'with-defaults-middleware-disabled-in-methodDoc', url: '/v3/users/34?name=fred', - expectedStatus: 200, expectedBody: {id: 34, name: 'fred'}}, - {name: 'with-defaults-middleware-disabled-in-pathItem', url: '/v3/users/34?name=fred', - expectedStatus: 200, expectedBody: {id: 34, name: 'fred'}}, - {name: 'with-defaults-middleware-disabled-in-pathModule', url: '/v3/users/34?name=fred', - expectedStatus: 200, expectedBody: {id: 34, name: 'fred'}}, - {name: 'with-defaults-middleware-disabled-in-the-apiDoc', url: '/v3/users/34?name=fred', - expectedStatus: 200, expectedBody: {id: 34, name: 'fred'}}, + { + name: 'with-defaults-middleware-disabled-in-methodDoc', + url: '/v3/users/34?name=fred', + expectedStatus: 200, + expectedBody: { id: 34, name: 'fred' } + }, + { + name: 'with-defaults-middleware-disabled-in-pathItem', + url: '/v3/users/34?name=fred', + expectedStatus: 200, + expectedBody: { id: 34, name: 'fred' } + }, + { + name: 'with-defaults-middleware-disabled-in-pathModule', + url: '/v3/users/34?name=fred', + expectedStatus: 200, + expectedBody: { id: 34, name: 'fred' } + }, + { + name: 'with-defaults-middleware-disabled-in-the-apiDoc', + url: '/v3/users/34?name=fred', + expectedStatus: 200, + expectedBody: { id: 34, name: 'fred' } + }, // disable validation - {name: 'with-validation-middleware-disabled-in-methodDoc', url: '/v3/users/asdf?name=fred', - expectedStatus: 200, expectedBody: {age: 80, id: null, name: 'fred'}}, - {name: 'with-validation-middleware-disabled-in-pathItem', url: '/v3/users/asdf?name=fred', - expectedStatus: 200, expectedBody: {age: 80, id: null, name: 'fred'}}, - {name: 'with-validation-middleware-disabled-in-pathModule', url: '/v3/users/asdf?name=fred', - expectedStatus: 200, expectedBody: {age: 80, id: null, name: 'fred'}}, - {name: 'with-validation-middleware-disabled-in-the-apiDoc', url: '/v3/users/asdf?name=fred', - expectedStatus: 200, expectedBody: {age: 80, id: null, name: 'fred'}}, + { + name: 'with-validation-middleware-disabled-in-methodDoc', + url: '/v3/users/asdf?name=fred', + expectedStatus: 200, + expectedBody: { age: 80, id: null, name: 'fred' } + }, + { + name: 'with-validation-middleware-disabled-in-pathItem', + url: '/v3/users/asdf?name=fred', + expectedStatus: 200, + expectedBody: { age: 80, id: null, name: 'fred' } + }, + { + name: 'with-validation-middleware-disabled-in-pathModule', + url: '/v3/users/asdf?name=fred', + expectedStatus: 200, + expectedBody: { age: 80, id: null, name: 'fred' } + }, + { + name: 'with-validation-middleware-disabled-in-the-apiDoc', + url: '/v3/users/asdf?name=fred', + expectedStatus: 200, + expectedBody: { age: 80, id: null, name: 'fred' } + }, // disable all - {name: 'with-middleware-disabled-in-methodDoc', url: '/v3/users/asdf?name=fred', - expectedStatus: 200, expectedBody: {id: 'asdf', name: 'fred'}}, - {name: 'with-middleware-disabled-in-pathItem', url: '/v3/users/asdf?name=fred', - expectedStatus: 200, expectedBody: {id: 'asdf', name: 'fred'}}, - {name: 'with-middleware-disabled-in-pathModule', url: '/v3/users/asdf?name=fred', - expectedStatus: 200, expectedBody: {id: 'asdf', name: 'fred'}}, - {name: 'with-middleware-disabled-in-the-apiDoc', url: '/v3/users/asdf?name=fred', - expectedStatus: 200, expectedBody: {id: 'asdf', name: 'fred'}} + { + name: 'with-middleware-disabled-in-methodDoc', + url: '/v3/users/asdf?name=fred', + expectedStatus: 200, + expectedBody: { id: 'asdf', name: 'fred' } + }, + { + name: 'with-middleware-disabled-in-pathItem', + url: '/v3/users/asdf?name=fred', + expectedStatus: 200, + expectedBody: { id: 'asdf', name: 'fred' } + }, + { + name: 'with-middleware-disabled-in-pathModule', + url: '/v3/users/asdf?name=fred', + expectedStatus: 200, + expectedBody: { id: 'asdf', name: 'fred' } + }, + { + name: 'with-middleware-disabled-in-the-apiDoc', + url: '/v3/users/asdf?name=fred', + expectedStatus: 200, + expectedBody: { id: 'asdf', name: 'fred' } + } ].forEach(test => { describe(test.name, () => { let app; @@ -109,14 +189,30 @@ describe(require('../package.json').name + ' sample-projects', () => { [ // disable response validation - {name: 'with-response-validation-middleware-disabled-in-methodDoc', - url: '/v3/users/34?name=fred', expectedStatus: 200, expectedBody: true}, - {name: 'with-response-validation-middleware-disabled-in-pathItem', - url: '/v3/users/34?name=fred', expectedStatus: 200, expectedBody: true}, - {name: 'with-response-validation-middleware-disabled-in-pathModule', - url: '/v3/users/34?name=fred', expectedStatus: 200, expectedBody: true}, - {name: 'with-response-validation-middleware-disabled-in-the-apiDoc', - url: '/v3/users/34?name=fred', expectedStatus: 200, expectedBody: true} + { + name: 'with-response-validation-middleware-disabled-in-methodDoc', + url: '/v3/users/34?name=fred', + expectedStatus: 200, + expectedBody: true + }, + { + name: 'with-response-validation-middleware-disabled-in-pathItem', + url: '/v3/users/34?name=fred', + expectedStatus: 200, + expectedBody: true + }, + { + name: 'with-response-validation-middleware-disabled-in-pathModule', + url: '/v3/users/34?name=fred', + expectedStatus: 200, + expectedBody: true + }, + { + name: 'with-response-validation-middleware-disabled-in-the-apiDoc', + url: '/v3/users/34?name=fred', + expectedStatus: 200, + expectedBody: true + } ].forEach(test => { describe(test.name, () => { let app; @@ -138,23 +234,30 @@ describe(require('../package.json').name + ' sample-projects', () => { }); }); - glob.sync('./sample-projects/*', {cwd: __dirname}).forEach(sampleProjectPath => { - const specName = path.basename(sampleProjectPath); - const specPath = path.resolve(__dirname, sampleProjectPath, 'spec.js'); + glob + .sync('./sample-projects/*', { cwd: __dirname }) + .forEach(sampleProjectPath => { + const specName = path.basename(sampleProjectPath); + const specPath = path.resolve(__dirname, sampleProjectPath, 'spec.js'); - if ([ - // progressively move sample project tests up - 'basic-usage' - ].indexOf(specName) > -1) { - return; - } + if ( + [ + // progressively move sample project tests up + 'basic-usage' + ].indexOf(specName) > -1 + ) { + return; + } - if (fs.existsSync(specPath)) { - describe(specName, () => { - require(specPath); - }); - } - }); + if (fs.existsSync(specPath)) { + describe(specName, () => { + require(specPath); + }); + } + }); }); -require('../../../test/sample-projects.js')(require('../package.json').name, __dirname); +require('../../../test/sample-projects.js')( + require('../package.json').name, + __dirname +); diff --git a/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/api-routes/users.js b/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/api-routes/users.js index 1015fd94..4e9ffb44 100644 --- a/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/api-routes/users.js @@ -8,11 +8,16 @@ module.exports = { return next(validationError); } - res.status(204).send('').end(); + res + .status(204) + .send('') + .end(); }, - get: [function(req, res, next) { - res.status(200).json([{name: 'fred'}]); - }], + get: [ + function(req, res, next) { + res.status(200).json([{ name: 'fred' }]); + } + ], post: function(req, res, next) { res.status(500).json({}); diff --git a/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/api-routes/users/{id}.js index b1c76489..827905ce 100644 --- a/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/api-routes/users/{id}.js @@ -5,11 +5,16 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, post] + post: [ + function(req, res, next) { + next(); + }, + post + ] }; function post(req, res) { - res.status(200).json({id: req.params.id}); + res.status(200).json({ id: req.params.id }); } function get(req, res) { diff --git a/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/app.js b/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/app.js index 0f3a0894..99d4afd0 100644 --- a/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/app.js +++ b/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/app.js @@ -21,7 +21,7 @@ app.use(function(err, req, res, next) { module.exports = app; -const port = parseInt(process.argv[2]); +const port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/spec.js b/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/spec.js index fb5b1110..fb2a2a7d 100644 --- a/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/spec.js +++ b/packages/express-openapi/test/sample-projects/basic-usage-with-central-apiDoc/spec.js @@ -6,7 +6,7 @@ const request = require('supertest'); it('should expose .basePath/api-docs', function(done) { request(app) .get('/v3/api-docs') - .set("Host", "test-host") + .set('Host', 'test-host') .expect(200, expectedApiDoc, done); }); @@ -21,7 +21,7 @@ it('should use defaults, coercion, and operation parameter overriding', function .get('/v3/users/34?name=fred') .expect(200) .end(function(err, res) { - expect(res.body).to.eql({id: 34, name: 'fred', age: 80}); + expect(res.body).to.eql({ id: 34, name: 'fred', age: 80 }); done(err); }); }); @@ -29,23 +29,30 @@ it('should use defaults, coercion, and operation parameter overriding', function it('should validate input', function(done) { request(app) .get('/v3/users/34?name=barney') - .expect(400, {errors: [ + .expect( + 400, { - errorCode: 'pattern.openapi.validation', - location: 'query', - message: 'should match pattern \"^fred$\"', - path: 'name' - } - ], status: 400}, done); + errors: [ + { + errorCode: 'pattern.openapi.validation', + location: 'query', + message: 'should match pattern "^fred$"', + path: 'name' + } + ], + status: 400 + }, + done + ); }); it('should use path parameters', function(done) { request(app) .post('/v3/users/34') - .send({name: 'fred'}) + .send({ name: 'fred' }) .expect(200) .end(function(err, res) { - expect(res.body).to.eql({id: '34'}); + expect(res.body).to.eql({ id: '34' }); done(err); }); }); @@ -76,12 +83,19 @@ it('should dereference #/definitions/ for validation', function(done) { request(app) .post('/v3/users/34?name=barney') .send(user) - .expect(400, {errors: [ + .expect( + 400, { - errorCode: 'required.openapi.validation', - location: 'body', - message: 'should have required property \'name\'', - path: 'name' - } - ], status: 400}, done); + errors: [ + { + errorCode: 'required.openapi.validation', + location: 'body', + message: "should have required property 'name'", + path: 'name' + } + ], + status: 400 + }, + done + ); }); diff --git a/packages/express-openapi/test/sample-projects/basic-usage/api-doc.js b/packages/express-openapi/test/sample-projects/basic-usage/api-doc.js index d4713768..dd705095 100644 --- a/packages/express-openapi/test/sample-projects/basic-usage/api-doc.js +++ b/packages/express-openapi/test/sample-projects/basic-usage/api-doc.js @@ -3,7 +3,7 @@ module.exports = { swagger: '2.0', - host: "test-host", + host: 'test-host', // all routes will now have /v3 prefixed. basePath: '/v3', @@ -40,6 +40,6 @@ module.exports = { tags: [ // {name: 'creating'} will be inserted by ./api-routes/users.js // {name: 'fooey'} will be inserted by ./api-routes/users/{id}.js - {description: 'Everything users', name: 'users'} + { description: 'Everything users', name: 'users' } ] }; diff --git a/packages/express-openapi/test/sample-projects/basic-usage/api-routes/apiDocs.js b/packages/express-openapi/test/sample-projects/basic-usage/api-routes/apiDocs.js index ebb0971d..4e853375 100644 --- a/packages/express-openapi/test/sample-projects/basic-usage/api-routes/apiDocs.js +++ b/packages/express-openapi/test/sample-projects/basic-usage/api-routes/apiDocs.js @@ -17,10 +17,7 @@ get.apiDoc = { in: 'query', name: 'type', type: 'string', - enum: [ - 'apiDoc', - 'operationDoc' - ] + enum: ['apiDoc', 'operationDoc'] } ], responses: { @@ -31,7 +28,7 @@ get.apiDoc = { } }, default: { - description: 'The requested apiDoc.', + description: 'The requested apiDoc.' } } }; diff --git a/packages/express-openapi/test/sample-projects/basic-usage/api-routes/users.js b/packages/express-openapi/test/sample-projects/basic-usage/api-routes/users.js index 6682323a..ef3d6807 100644 --- a/packages/express-openapi/test/sample-projects/basic-usage/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/basic-usage/api-routes/users.js @@ -8,11 +8,16 @@ module.exports = { return next(validationError); } - res.status(204).send('').end(); + res + .status(204) + .send('') + .end(); }, - get: [function(req, res, next) { - res.status(200).json([{name: 'fred'}]); - }], + get: [ + function(req, res, next) { + res.status(200).json([{ name: 'fred' }]); + } + ], post: function(req, res, next) { res.status(500).json({}); @@ -42,7 +47,7 @@ module.exports.post.apiDoc = { parameters: [], responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/basic-usage/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/basic-usage/api-routes/users/{id}.js index 638a56a2..29da65e7 100644 --- a/packages/express-openapi/test/sample-projects/basic-usage/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/basic-usage/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,11 +15,16 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, post] + post: [ + function(req, res, next) { + next(); + }, + post + ] }; function post(req, res) { - res.status(200).json({id: req.params.id}); + res.status(200).json({ id: req.params.id }); } // verify that apiDoc is available with middleware @@ -39,7 +44,7 @@ post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -73,27 +78,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/basic-usage/app.js b/packages/express-openapi/test/sample-projects/basic-usage/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/basic-usage/app.js +++ b/packages/express-openapi/test/sample-projects/basic-usage/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/file-upload/api-doc.js b/packages/express-openapi/test/sample-projects/file-upload/api-doc.js index 0c0d518d..0fdba0c2 100644 --- a/packages/express-openapi/test/sample-projects/file-upload/api-doc.js +++ b/packages/express-openapi/test/sample-projects/file-upload/api-doc.js @@ -1,7 +1,7 @@ module.exports = { swagger: '2.0', - host: "test-host", + host: 'test-host', basePath: '/v3', info: { @@ -13,7 +13,5 @@ module.exports = { paths: {}, - tags: [ - {description: 'Drafts', name: 'Drafts'} - ] + tags: [{ description: 'Drafts', name: 'Drafts' }] }; diff --git a/packages/express-openapi/test/sample-projects/file-upload/api-routes/fileupload.js b/packages/express-openapi/test/sample-projects/file-upload/api-routes/fileupload.js index 72b1eb30..f2b75e85 100644 --- a/packages/express-openapi/test/sample-projects/file-upload/api-routes/fileupload.js +++ b/packages/express-openapi/test/sample-projects/file-upload/api-routes/fileupload.js @@ -6,47 +6,45 @@ module.exports = { module.exports.post.apiDoc = { summary: "Form file upload. Accepts a form file upload named 'file'.", - operationId: "FormDraftFileUpload", + operationId: 'FormDraftFileUpload', - tags: ["Drafts"], - consumes: [ - "multipart/form-data" - ], + tags: ['Drafts'], + consumes: ['multipart/form-data'], parameters: [ { - name: "process_intel", - in: "formData", - description: "Whether or not to transform intel files.", - type: "boolean", + name: 'process_intel', + in: 'formData', + description: 'Whether or not to transform intel files.', + type: 'boolean', default: false }, { - name: "overwrite", - in: "formData", - description: "Whether or not to replace an existing file.", - type: "boolean", + name: 'overwrite', + in: 'formData', + description: 'Whether or not to replace an existing file.', + type: 'boolean', default: true }, { - name: "basepath", - in: "formData", - description: "Root directory to place files.", - type: "string", - default: "" + name: 'basepath', + in: 'formData', + description: 'Root directory to place files.', + type: 'string', + default: '' }, { - name: "file", - in: "formData", - description: "The file to upload", - type: "file" + name: 'file', + in: 'formData', + description: 'The file to upload', + type: 'file' } ], responses: { 200: { - "description": "OK" + description: 'OK' }, 400: { - "description": "BAD" + description: 'BAD' } } -}; \ No newline at end of file +}; diff --git a/packages/express-openapi/test/sample-projects/file-upload/app.js b/packages/express-openapi/test/sample-projects/file-upload/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/file-upload/app.js +++ b/packages/express-openapi/test/sample-projects/file-upload/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/file-upload/spec.js b/packages/express-openapi/test/sample-projects/file-upload/spec.js index 9897327e..e9f6cb69 100644 --- a/packages/express-openapi/test/sample-projects/file-upload/spec.js +++ b/packages/express-openapi/test/sample-projects/file-upload/spec.js @@ -10,4 +10,4 @@ it('should upload a file', function(done) { request(app) .post('/v3/fileupload') .expect(200, {}, done); -}); \ No newline at end of file +}); diff --git a/packages/express-openapi/test/sample-projects/securityHandlers-without-a-method-doc/app.js b/packages/express-openapi/test/sample-projects/securityHandlers-without-a-method-doc/app.js index bf515132..18b37de5 100644 --- a/packages/express-openapi/test/sample-projects/securityHandlers-without-a-method-doc/app.js +++ b/packages/express-openapi/test/sample-projects/securityHandlers-without-a-method-doc/app.js @@ -7,8 +7,7 @@ openapi.initialize({ apiDoc: require('./api-doc.js'), app: app, paths: path.resolve(__dirname, 'api-routes'), - securityHandlers: { - } + securityHandlers: {} }); app.use(function(err, req, res, next) { diff --git a/packages/express-openapi/test/sample-projects/with-additional-middleware/api-doc.js b/packages/express-openapi/test/sample-projects/with-additional-middleware/api-doc.js index 54534700..bce0ce24 100644 --- a/packages/express-openapi/test/sample-projects/with-additional-middleware/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-additional-middleware/api-doc.js @@ -1,17 +1,19 @@ // args.apiDoc needs to be a js object. This file could be a json file, but we can't add // comments in json files. module.exports = { - 'x-express-openapi-additional-middleware': [/* generate a warning */ null, - function(req, res, next) { - // assure ordering of middleware is preserved - req.apiDocAdded = false; - next(); - }, - function(req, res, next) { - req.orderingApiDoc = 'apiDoc'; - req.apiDocAdded = true; - next(); - }], + 'x-express-openapi-additional-middleware': [ + /* generate a warning */ null, + function(req, res, next) { + // assure ordering of middleware is preserved + req.apiDocAdded = false; + next(); + }, + function(req, res, next) { + req.orderingApiDoc = 'apiDoc'; + req.apiDocAdded = true; + next(); + } + ], swagger: '2.0', @@ -35,13 +37,12 @@ module.exports = { next(); }, function(req, res, next) { - req.pathDocAdded = true; - next(); - }] + req.pathDocAdded = true; + next(); + } + ] } }, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-additional-middleware/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-additional-middleware/api-routes/users/{id}.js index c6d8c2e3..d2bfdd00 100644 --- a/packages/express-openapi/test/sample-projects/with-additional-middleware/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-additional-middleware/api-routes/users/{id}.js @@ -19,7 +19,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], get: get @@ -52,20 +52,21 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { default: { - description: 'showing that additional middleware should have been added at all levels.', + description: + 'showing that additional middleware should have been added at all levels.', schema: { properties: { apiDocAdded: { diff --git a/packages/express-openapi/test/sample-projects/with-additional-middleware/app.js b/packages/express-openapi/test/sample-projects/with-additional-middleware/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-additional-middleware/app.js +++ b/packages/express-openapi/test/sample-projects/with-additional-middleware/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-doc.js b/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-doc.js index f538299b..13e7c6b1 100644 --- a/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-doc.js @@ -39,6 +39,6 @@ module.exports = { tags: [ // {name: 'creating'} will be inserted by ./api-routes/users.js // {name: 'fooey'} will be inserted by ./api-routes/users/{id}.js - {description: 'Everything users', name: 'users'} + { description: 'Everything users', name: 'users' } ] }; diff --git a/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-routes/apiDocs.js b/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-routes/apiDocs.js index 16e307f0..407a5719 100644 --- a/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-routes/apiDocs.js +++ b/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-routes/apiDocs.js @@ -18,10 +18,7 @@ get.apiDoc = { in: 'query', name: 'type', type: 'string', - enum: [ - 'apiDoc', - 'operationDoc' - ] + enum: ['apiDoc', 'operationDoc'] } ], responses: { @@ -32,7 +29,7 @@ get.apiDoc = { } }, default: { - description: 'The requested apiDoc.', + description: 'The requested apiDoc.' } } }; diff --git a/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-routes/users.js b/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-routes/users.js index 6682323a..ef3d6807 100644 --- a/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-routes/users.js @@ -8,11 +8,16 @@ module.exports = { return next(validationError); } - res.status(204).send('').end(); + res + .status(204) + .send('') + .end(); }, - get: [function(req, res, next) { - res.status(200).json([{name: 'fred'}]); - }], + get: [ + function(req, res, next) { + res.status(200).json([{ name: 'fred' }]); + } + ], post: function(req, res, next) { res.status(500).json({}); @@ -42,7 +47,7 @@ module.exports.post.apiDoc = { parameters: [], responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-routes/users/{id}.js index c0ee0e69..25002d02 100644 --- a/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/api-routes/users/{id}.js @@ -1,6 +1,6 @@ module.exports = function() { function post(req, res) { - res.status(200).json({id: req.params.id}); + res.status(200).json({ id: req.params.id }); } // verify that apiDoc is available with middleware @@ -20,7 +20,7 @@ module.exports = function() { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -54,27 +54,27 @@ module.exports = function() { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { - $ref: "#/definitions/User" + $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -90,7 +90,7 @@ module.exports = function() { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -99,6 +99,11 @@ module.exports = function() { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, post] + post: [ + function(req, res, next) { + next(); + }, + post + ] }; }; diff --git a/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/app.js b/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/app.js +++ b/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/spec.js b/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/spec.js index 92a6a3fd..bb3069f0 100644 --- a/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/spec.js +++ b/packages/express-openapi/test/sample-projects/with-apiDoc-as-array-method-handler-property/spec.js @@ -10,6 +10,6 @@ before(function() { it('should expose .basePath/api-docs', function(done) { request(app) .get('/v3/api-docs') - .set("Host", "test-host") + .set('Host', 'test-host') .expect(200, expectedApiDoc, done); }); diff --git a/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/api-doc.js b/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/api-doc.js index f7b64eb1..af7854e4 100644 --- a/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/api-doc.js @@ -25,10 +25,7 @@ module.exports = { type: 'string', name: 'foo', required: true, - enum: [ - 'success', - 'error' - ] + enum: ['success', 'error'] } }, diff --git a/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/api-routes/foo.js b/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/api-routes/foo.js index 4c65de54..d2fe2dec 100644 --- a/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/api-routes/foo.js +++ b/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/api-routes/foo.js @@ -5,9 +5,7 @@ module.exports = { } ], get: function(req, res, next) { - var statusCode = req.query.foo === 'success' ? - 200 : - 500; + var statusCode = req.query.foo === 'success' ? 200 : 500; var errors = res.validateResponse(statusCode, req.query.boo); if (errors) { errors.status = 500; @@ -15,7 +13,9 @@ module.exports = { } }, // handling no method doc - post: function() {} + post: function() { + return; + } }; module.exports.get.apiDoc = { diff --git a/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/app.js b/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/app.js +++ b/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/spec.js b/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/spec.js index 10311076..c3c3fc72 100644 --- a/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/spec.js +++ b/packages/express-openapi/test/sample-projects/with-apiDoc-parameters-and-responses/spec.js @@ -9,36 +9,44 @@ before(function() { it('should use parameter references', function(done) { request(app) .get('/v3/foo?name=barney') - .expect(400, { - status: 400, - errors:[ - { - path: 'boo', - errorCode: 'required.openapi.validation', - message: 'should have required property \'boo\'', - location:'query' - }, - { - path: 'foo', - errorCode: 'required.openapi.validation', - message: 'should have required property \'foo\'', - location: 'query' - } - ] - }, done); + .expect( + 400, + { + status: 400, + errors: [ + { + path: 'boo', + errorCode: 'required.openapi.validation', + message: "should have required property 'boo'", + location: 'query' + }, + { + path: 'foo', + errorCode: 'required.openapi.validation', + message: "should have required property 'foo'", + location: 'query' + } + ] + }, + done + ); }); it('should use response references', function(done) { request(app) .get('/v3/foo?foo=error&boo=success') - .expect(500, { - errors: [ - { - errorCode: 'enum.openapi.responseValidation', - message: 'response should be equal to one of the allowed values' - } - ], - message: 'The response was not valid.', - status: 500 - }, done); + .expect( + 500, + { + errors: [ + { + errorCode: 'enum.openapi.responseValidation', + message: 'response should be equal to one of the allowed values' + } + ], + message: 'The response was not valid.', + status: 500 + }, + done + ); }); diff --git a/packages/express-openapi/test/sample-projects/with-case-insensitive-params/api-doc.js b/packages/express-openapi/test/sample-projects/with-case-insensitive-params/api-doc.js index 26950ec2..1efdea42 100644 --- a/packages/express-openapi/test/sample-projects/with-case-insensitive-params/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-case-insensitive-params/api-doc.js @@ -5,5 +5,5 @@ module.exports = { title: 'Testing case insensitive params.', version: '1.0.0' }, - paths: {}, + paths: {} }; diff --git a/packages/express-openapi/test/sample-projects/with-case-insensitive-params/api-routes/testParam.js b/packages/express-openapi/test/sample-projects/with-case-insensitive-params/api-routes/testParam.js index 8cdfdae5..f866c304 100644 --- a/packages/express-openapi/test/sample-projects/with-case-insensitive-params/api-routes/testParam.js +++ b/packages/express-openapi/test/sample-projects/with-case-insensitive-params/api-routes/testParam.js @@ -15,13 +15,13 @@ GET.apiDoc = { in: 'query', name: 'testParam', required: true, - type: 'string', + type: 'string' }, { in: 'query', name: 'testParam1', required: true, - type: 'string', + type: 'string' } ], responses: { diff --git a/packages/express-openapi/test/sample-projects/with-case-insensitive-params/app.js b/packages/express-openapi/test/sample-projects/with-case-insensitive-params/app.js index 66bfd92a..9616e321 100644 --- a/packages/express-openapi/test/sample-projects/with-case-insensitive-params/app.js +++ b/packages/express-openapi/test/sample-projects/with-case-insensitive-params/app.js @@ -19,7 +19,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-methodDoc/api-doc.js b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-methodDoc/api-doc.js index 63ca30e2..1535ab28 100644 --- a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-methodDoc/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-methodDoc/api-doc.js @@ -34,7 +34,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-methodDoc/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-methodDoc/api-routes/users/{id}.js index 0c58d62c..cb309baf 100644 --- a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-methodDoc/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-methodDoc/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -71,27 +76,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-methodDoc/app.js b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-methodDoc/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-methodDoc/app.js +++ b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-methodDoc/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathItem/api-doc.js b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathItem/api-doc.js index a30fec49..ccd9ce25 100644 --- a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathItem/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathItem/api-doc.js @@ -38,7 +38,5 @@ module.exports = { } }, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathItem/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathItem/api-routes/users/{id}.js index 0c00e4e2..3f23c7d5 100644 --- a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathItem/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathItem/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -70,27 +75,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathItem/app.js b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathItem/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathItem/app.js +++ b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathItem/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathModule/api-doc.js b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathModule/api-doc.js index 63ca30e2..1535ab28 100644 --- a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathModule/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathModule/api-doc.js @@ -34,7 +34,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathModule/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathModule/api-routes/users/{id}.js index edbf4ca7..bbfedcce 100644 --- a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathModule/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathModule/api-routes/users/{id}.js @@ -8,7 +8,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -17,9 +17,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -38,7 +43,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -72,27 +77,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathModule/app.js b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathModule/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathModule/app.js +++ b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-pathModule/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-the-apiDoc/api-doc.js b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-the-apiDoc/api-doc.js index 699bd177..6bdd185b 100644 --- a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-the-apiDoc/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-the-apiDoc/api-doc.js @@ -36,7 +36,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js index 0c00e4e2..3f23c7d5 100644 --- a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -70,27 +75,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-the-apiDoc/app.js b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-the-apiDoc/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-the-apiDoc/app.js +++ b/packages/express-openapi/test/sample-projects/with-coercion-middleware-disabled-in-the-apiDoc/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-consumes-middleware/api-doc.js b/packages/express-openapi/test/sample-projects/with-consumes-middleware/api-doc.js index 05e1d820..f6ba3472 100644 --- a/packages/express-openapi/test/sample-projects/with-consumes-middleware/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-consumes-middleware/api-doc.js @@ -6,17 +6,14 @@ module.exports = { // all routes will now have /v3 prefixed. basePath: '/v3', - consumes: [ - 'text/text' - ], + consumes: ['text/text'], info: { title: 'express-openapi sample project', version: '3.0.0' }, - definitions: { - }, + definitions: {}, // paths are derived from args.routes. These are filled in by fs-routes. paths: {} diff --git a/packages/express-openapi/test/sample-projects/with-consumes-middleware/app.js b/packages/express-openapi/test/sample-projects/with-consumes-middleware/app.js index 35f67867..f0cca3cc 100644 --- a/packages/express-openapi/test/sample-projects/with-consumes-middleware/app.js +++ b/packages/express-openapi/test/sample-projects/with-consumes-middleware/app.js @@ -19,7 +19,7 @@ openapi.initialize({ module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-customFormats/api-routes/foo.js b/packages/express-openapi/test/sample-projects/with-customFormats/api-routes/foo.js index f8906868..2d900a35 100644 --- a/packages/express-openapi/test/sample-projects/with-customFormats/api-routes/foo.js +++ b/packages/express-openapi/test/sample-projects/with-customFormats/api-routes/foo.js @@ -1,12 +1,13 @@ module.exports = { get: function(req, res) { - res.status(200).json({name: req.query.foo}); + res.status(200).json({ name: req.query.foo }); }, post: function(req, res) { - var validationResult = res.validateResponse(200, {name: req.query.foo}); + var validationResult = res.validateResponse(200, { name: req.query.foo }); res.status(validationResult ? 400 : 200).json({ - errors: (validationResult || {errors: []}).errors}); + errors: (validationResult || { errors: [] }).errors + }); } }; diff --git a/packages/express-openapi/test/sample-projects/with-customFormats/app.js b/packages/express-openapi/test/sample-projects/with-customFormats/app.js index 73cdb80e..fc8c5b9f 100644 --- a/packages/express-openapi/test/sample-projects/with-customFormats/app.js +++ b/packages/express-openapi/test/sample-projects/with-customFormats/app.js @@ -25,7 +25,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-customFormats/spec.js b/packages/express-openapi/test/sample-projects/with-customFormats/spec.js index 01299ea9..493da10c 100644 --- a/packages/express-openapi/test/sample-projects/with-customFormats/spec.js +++ b/packages/express-openapi/test/sample-projects/with-customFormats/spec.js @@ -10,20 +10,27 @@ describe('input validation', function() { it('should fail input', function(done) { request(app) .get('/v3/foo?foo=barney') - .expect(400, {errors: [ + .expect( + 400, { - errorCode: 'format.openapi.validation', - location: 'query', - message: 'should match format "foo"', - path: 'foo' - } - ], status: 400}, done); + errors: [ + { + errorCode: 'format.openapi.validation', + location: 'query', + message: 'should match format "foo"', + path: 'foo' + } + ], + status: 400 + }, + done + ); }); it('should accept input', function(done) { request(app) .get('/v3/foo?foo=foo') - .expect(200, {name: 'foo'}, done); + .expect(200, { name: 'foo' }, done); }); }); @@ -31,18 +38,24 @@ describe('response validation', function() { it('should fail', function(done) { request(app) .post('/v3/foo?foo=barney') - .expect(400, {errors: [ + .expect( + 400, { - errorCode: 'format.openapi.responseValidation', - message: 'name should match format "foo"', - path: 'name' - } - ]}, done); + errors: [ + { + errorCode: 'format.openapi.responseValidation', + message: 'name should match format "foo"', + path: 'name' + } + ] + }, + done + ); }); it('should pass', function(done) { request(app) .post('/v3/foo?foo=foo') - .expect(200, {errors: []}, done); + .expect(200, { errors: [] }, done); }); }); diff --git a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-methodDoc/api-doc.js b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-methodDoc/api-doc.js index 63ca30e2..1535ab28 100644 --- a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-methodDoc/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-methodDoc/api-doc.js @@ -34,7 +34,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-methodDoc/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-methodDoc/api-routes/users/{id}.js index f3a93e21..6db4b8a1 100644 --- a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-methodDoc/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-methodDoc/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -71,27 +76,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-methodDoc/app.js b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-methodDoc/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-methodDoc/app.js +++ b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-methodDoc/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathItem/api-doc.js b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathItem/api-doc.js index 1526f0a9..0117baea 100644 --- a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathItem/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathItem/api-doc.js @@ -38,7 +38,5 @@ module.exports = { } }, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathItem/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathItem/api-routes/users/{id}.js index 0c00e4e2..3f23c7d5 100644 --- a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathItem/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathItem/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -70,27 +75,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathItem/app.js b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathItem/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathItem/app.js +++ b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathItem/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathModule/api-doc.js b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathModule/api-doc.js index 63ca30e2..1535ab28 100644 --- a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathModule/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathModule/api-doc.js @@ -34,7 +34,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathModule/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathModule/api-routes/users/{id}.js index 213dc846..3074ef97 100644 --- a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathModule/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathModule/api-routes/users/{id}.js @@ -8,7 +8,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -17,9 +17,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -38,7 +43,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -72,27 +77,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathModule/app.js b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathModule/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathModule/app.js +++ b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-pathModule/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-the-apiDoc/api-doc.js b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-the-apiDoc/api-doc.js index 4d1d0196..b95b0461 100644 --- a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-the-apiDoc/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-the-apiDoc/api-doc.js @@ -36,7 +36,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js index 0c00e4e2..3f23c7d5 100644 --- a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -70,27 +75,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-the-apiDoc/app.js b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-the-apiDoc/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-the-apiDoc/app.js +++ b/packages/express-openapi/test/sample-projects/with-defaults-middleware-disabled-in-the-apiDoc/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-errorMiddleware/app.js b/packages/express-openapi/test/sample-projects/with-errorMiddleware/app.js index a6df7ffa..3266a38c 100644 --- a/packages/express-openapi/test/sample-projects/with-errorMiddleware/app.js +++ b/packages/express-openapi/test/sample-projects/with-errorMiddleware/app.js @@ -27,7 +27,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-errorTransformer/api-doc.js b/packages/express-openapi/test/sample-projects/with-errorTransformer/api-doc.js index 0e901a48..3ef191fb 100644 --- a/packages/express-openapi/test/sample-projects/with-errorTransformer/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-errorTransformer/api-doc.js @@ -28,7 +28,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-errorTransformer/api-routes/users.js b/packages/express-openapi/test/sample-projects/with-errorTransformer/api-routes/users.js index 9419d51e..1a0e9e67 100644 --- a/packages/express-openapi/test/sample-projects/with-errorTransformer/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/with-errorTransformer/api-routes/users.js @@ -1,8 +1,10 @@ // Showing that you don't need to have apiDoc defined on methodHandlers. module.exports = { - get: [function(req, res, next) { - res.status(200).json([{name: 'fred'}]); - }], + get: [ + function(req, res, next) { + res.status(200).json([{ name: 'fred' }]); + } + ], post: function(req, res, next) { res.status(500).json({}); @@ -15,7 +17,7 @@ module.exports.post.apiDoc = { parameters: [], responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-errorTransformer/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-errorTransformer/api-routes/users/{id}.js index 208b74f4..c92d7c08 100644 --- a/packages/express-openapi/test/sample-projects/with-errorTransformer/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-errorTransformer/api-routes/users/{id}.js @@ -4,9 +4,14 @@ module.exports = { // or they may also be an array of middleware + the method handler. This allows // for flexible middleware management. express-openapi middleware generated from // the .apiDoc.parameters is prepended to this array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(500).json('only one user is returned by this API.'); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(500).json('only one user is returned by this API.'); + } + ] }; module.exports.post.apiDoc = { @@ -25,7 +30,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -59,28 +64,28 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-errorTransformer/app.js b/packages/express-openapi/test/sample-projects/with-errorTransformer/app.js index 731a36de..3954dc6d 100644 --- a/packages/express-openapi/test/sample-projects/with-errorTransformer/app.js +++ b/packages/express-openapi/test/sample-projects/with-errorTransformer/app.js @@ -11,7 +11,7 @@ openapi.initialize({ app: app, // See https://github.com/kogosoftwarellc/express-openapi-validation#argserrortransformer errorTransformer: function(error) { - return {fooError: 'oh yea'}; + return { fooError: 'oh yea' }; }, // we could just pass in "api-routes" if process.cwd() was set to this directory. paths: path.resolve(__dirname, 'api-routes') diff --git a/packages/express-openapi/test/sample-projects/with-errorTransformer/spec.js b/packages/express-openapi/test/sample-projects/with-errorTransformer/spec.js index 602ef4c6..f6da3adb 100644 --- a/packages/express-openapi/test/sample-projects/with-errorTransformer/spec.js +++ b/packages/express-openapi/test/sample-projects/with-errorTransformer/spec.js @@ -9,7 +9,5 @@ before(function() { it('should transform errors', function(done) { request(app) .get('/v3/users/34?name=barney') - .expect(400, {errors: [ - {fooError: 'oh yea'} - ], status: 400}, done); + .expect(400, { errors: [{ fooError: 'oh yea' }], status: 400 }, done); }); diff --git a/packages/express-openapi/test/sample-projects/with-exposeApiDocs-set-to-false/api-doc.js b/packages/express-openapi/test/sample-projects/with-exposeApiDocs-set-to-false/api-doc.js index 0e901a48..3ef191fb 100644 --- a/packages/express-openapi/test/sample-projects/with-exposeApiDocs-set-to-false/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-exposeApiDocs-set-to-false/api-doc.js @@ -28,7 +28,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-exposeApiDocs-set-to-false/api-routes/users.js b/packages/express-openapi/test/sample-projects/with-exposeApiDocs-set-to-false/api-routes/users.js index 9419d51e..1a0e9e67 100644 --- a/packages/express-openapi/test/sample-projects/with-exposeApiDocs-set-to-false/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/with-exposeApiDocs-set-to-false/api-routes/users.js @@ -1,8 +1,10 @@ // Showing that you don't need to have apiDoc defined on methodHandlers. module.exports = { - get: [function(req, res, next) { - res.status(200).json([{name: 'fred'}]); - }], + get: [ + function(req, res, next) { + res.status(200).json([{ name: 'fred' }]); + } + ], post: function(req, res, next) { res.status(500).json({}); @@ -15,7 +17,7 @@ module.exports.post.apiDoc = { parameters: [], responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-exposeApiDocs-set-to-false/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-exposeApiDocs-set-to-false/api-routes/users/{id}.js index 208b74f4..c92d7c08 100644 --- a/packages/express-openapi/test/sample-projects/with-exposeApiDocs-set-to-false/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-exposeApiDocs-set-to-false/api-routes/users/{id}.js @@ -4,9 +4,14 @@ module.exports = { // or they may also be an array of middleware + the method handler. This allows // for flexible middleware management. express-openapi middleware generated from // the .apiDoc.parameters is prepended to this array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(500).json('only one user is returned by this API.'); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(500).json('only one user is returned by this API.'); + } + ] }; module.exports.post.apiDoc = { @@ -25,7 +30,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -59,28 +64,28 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-express-mount-after-initialize/app.js b/packages/express-openapi/test/sample-projects/with-express-mount-after-initialize/app.js index 2abc7308..d2f1b967 100644 --- a/packages/express-openapi/test/sample-projects/with-express-mount-after-initialize/app.js +++ b/packages/express-openapi/test/sample-projects/with-express-mount-after-initialize/app.js @@ -24,7 +24,7 @@ parentApp.use('/api', app); module.exports = parentApp; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { parentApp.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-express-mount-before-initialize/app.js b/packages/express-openapi/test/sample-projects/with-express-mount-before-initialize/app.js index 69b39d82..c0417a79 100644 --- a/packages/express-openapi/test/sample-projects/with-express-mount-before-initialize/app.js +++ b/packages/express-openapi/test/sample-projects/with-express-mount-before-initialize/app.js @@ -23,7 +23,7 @@ parentApp.use(function(err, req, res, next) { module.exports = parentApp; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { parentApp.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-express-mount-deeply-nested/app.js b/packages/express-openapi/test/sample-projects/with-express-mount-deeply-nested/app.js index c0fca0c9..c987469a 100644 --- a/packages/express-openapi/test/sample-projects/with-express-mount-deeply-nested/app.js +++ b/packages/express-openapi/test/sample-projects/with-express-mount-deeply-nested/app.js @@ -21,13 +21,12 @@ parentApp.use(function(err, req, res, next) { res.status(err.status).json(err); }); - parentApp.use('/parent', app); grandparentApp.use('/grandparent', parentApp); module.exports = grandparentApp; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { parentApp.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-express-mount-on-router/app.js b/packages/express-openapi/test/sample-projects/with-express-mount-on-router/app.js index a4b52668..b5989f67 100644 --- a/packages/express-openapi/test/sample-projects/with-express-mount-on-router/app.js +++ b/packages/express-openapi/test/sample-projects/with-express-mount-on-router/app.js @@ -24,7 +24,7 @@ parentApp.use('/api', app); module.exports = parentApp; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { parentApp.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-external-schema-references/api-doc.js b/packages/express-openapi/test/sample-projects/with-external-schema-references/api-doc.js index 6a072c98..6e05160a 100644 --- a/packages/express-openapi/test/sample-projects/with-external-schema-references/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-external-schema-references/api-doc.js @@ -22,12 +22,12 @@ module.exports = { parameters: { User: { - "in": 'body', + in: 'body', name: 'user', - schema: {$ref: 'http://example.com/user'} + schema: { $ref: 'http://example.com/user' } }, userId: { - "in": 'path', + in: 'path', name: 'userId', type: 'string', required: true @@ -37,11 +37,11 @@ module.exports = { responses: { Forbidden: { description: 'Access denied', - schema: {$ref: 'http://example.com/error#/schema'} + schema: { $ref: 'http://example.com/error#/schema' } }, Error: { description: 'Error', - schema: {$ref: 'http://example.com/error#/schema'} + schema: { $ref: 'http://example.com/error#/schema' } } }, @@ -50,8 +50,5 @@ module.exports = { // tags is optional, and is generated / sorted by the tags defined in your path // docs. This API also defines 2 tags in operations: "creating" and "fooey". - tags: [ - {name: 'fooey'}, - {name: 'users'} - ] + tags: [{ name: 'fooey' }, { name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-external-schema-references/api-routes/users.js b/packages/express-openapi/test/sample-projects/with-external-schema-references/api-routes/users.js index 81396da4..e1418323 100644 --- a/packages/express-openapi/test/sample-projects/with-external-schema-references/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/with-external-schema-references/api-routes/users.js @@ -1,8 +1,7 @@ module.exports = { get: function(req, res, next) { - var statusCode; - switch(req.query.status) { + switch (req.query.status) { case 'success': statusCode = 200; break; @@ -19,13 +18,18 @@ module.exports = { statusCode = 500; } - var errors = res.validateResponse(statusCode, statusCode == 200 ? [{}] : {}); + var errors = res.validateResponse( + statusCode, + statusCode === 200 ? [{}] : {} + ); if (errors) { throw errors; } }, // handling no method doc - post: function() {} + post: function() { + return; + } }; module.exports.get.apiDoc = { @@ -33,41 +37,44 @@ module.exports.get.apiDoc = { operationId: 'listUser', parameters: [ { - "in": "query", - name: "status", - type: "string", - "enum": ["success", "method-not-allowed", "forbidden", "tea-pod", "error"] + in: 'query', + name: 'status', + type: 'string', + enum: ['success', 'method-not-allowed', 'forbidden', 'tea-pod', 'error'] } ], responses: { // following 3 status are references external schema through local ref. - 200: {// in child schema + 200: { + // in child schema description: 'List of users', schema: { type: 'array', - items: { $ref: '#/definitions/User'} + items: { $ref: '#/definitions/User' } } }, - 405: {// self schema + 405: { + // self schema description: 'Method not allowed', - schema: { $ref: '#/definitions/Error'} + schema: { $ref: '#/definitions/Error' } }, - 403: {// through response definition + 403: { + // through response definition $ref: '#/responses/Forbidden' }, // following 2 status are references external schema directly. - 418: {// in child schema + 418: { + // in child schema description: 'I am a tea pod', schema: { type: 'object', - allOf: [ - { $ref: 'http://example.com/tea-pod' } - ] + allOf: [{ $ref: 'http://example.com/tea-pod' }] } }, - default: {// self schema + default: { + // self schema description: 'Error', - schema: { $ref: 'http://example.com/error#/schema'} + schema: { $ref: 'http://example.com/error#/schema' } } } }; @@ -77,9 +84,9 @@ module.exports.post.apiDoc = { operationId: 'createUser', parameters: [ { - in: "body", + in: 'body', name: 'user', - schema: { $ref: "http://example.com/user"} + schema: { $ref: 'http://example.com/user' } } ], responses: { diff --git a/packages/express-openapi/test/sample-projects/with-external-schema-references/api-routes/users/{userId}.js b/packages/express-openapi/test/sample-projects/with-external-schema-references/api-routes/users/{userId}.js index 7b46dc4e..5a1bfe4d 100644 --- a/packages/express-openapi/test/sample-projects/with-external-schema-references/api-routes/users/{userId}.js +++ b/packages/express-openapi/test/sample-projects/with-external-schema-references/api-routes/users/{userId}.js @@ -7,7 +7,9 @@ module.exports = { $ref: '#/parameters/userId' } ], - put: function(req, res, next) {}, + put: function(req, res, next) { + return; + }, delete: function(req, res, next) { res.status(500).end('error'); } @@ -28,9 +30,9 @@ module.exports.delete.apiDoc = { operationId: 'deleteUser', parameters: [ { - in: "body", - name: "user", - schema: { $ref: "#/definitions/User"} + in: 'body', + name: 'user', + schema: { $ref: '#/definitions/User' } } ], responses: { diff --git a/packages/express-openapi/test/sample-projects/with-external-schema-references/app.js b/packages/express-openapi/test/sample-projects/with-external-schema-references/app.js index 8689f966..6edc5718 100644 --- a/packages/express-openapi/test/sample-projects/with-external-schema-references/app.js +++ b/packages/express-openapi/test/sample-projects/with-external-schema-references/app.js @@ -13,7 +13,7 @@ openapi.initialize({ app: app, paths: path.resolve(__dirname, 'api-routes'), externalSchemas: { - 'http://example.com/error':{ + 'http://example.com/error': { description: 'An error occurred.', schema: { type: 'string', @@ -24,15 +24,15 @@ openapi.initialize({ description: 'User schema definition', required: ['name'], properties: { - name: { type: "string" }, - age: { type: "integer", format: 'int32' } + name: { type: 'string' }, + age: { type: 'integer', format: 'int32' } } }, 'http://example.com/tea-pod': { description: 'Tea pod schema definition', required: ['content'], properties: { - content: { description: 'content in litter', type: "integer" } + content: { description: 'content in litter', type: 'integer' } } } } @@ -45,7 +45,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-external-schema-references/spec.js b/packages/express-openapi/test/sample-projects/with-external-schema-references/spec.js index 5222f218..f4a729ac 100644 --- a/packages/express-openapi/test/sample-projects/with-external-schema-references/spec.js +++ b/packages/express-openapi/test/sample-projects/with-external-schema-references/spec.js @@ -10,7 +10,7 @@ before(function() { it('should expose .basePath/api-docs', function(done) { request(app) .get('/v3/api-docs') - .set("Host", "test-host") + .set('Host', 'test-host') .expect(200, expectedApiDoc, done); }); @@ -18,137 +18,169 @@ it('should use direct references in parameter', function(done) { request(app) .post('/v3/users') .send({}) - .expect(400, { - status: 400, - errors:[ - { - path: 'name', - errorCode: 'required.openapi.validation', - message: 'should have required property \'name\'', - location:'body' - } - ] - }, done); + .expect( + 400, + { + status: 400, + errors: [ + { + path: 'name', + errorCode: 'required.openapi.validation', + message: "should have required property 'name'", + location: 'body' + } + ] + }, + done + ); }); it('should use external references through local schema definition', function(done) { request(app) .delete('/v3/users/foo') .send({}) - .expect(400, { - status: 400, - errors:[ - { - path: 'name', - errorCode: 'required.openapi.validation', - message: 'should have required property \'name\'', - location:'body' - } - ] - }, done); + .expect( + 400, + { + status: 400, + errors: [ + { + path: 'name', + errorCode: 'required.openapi.validation', + message: "should have required property 'name'", + location: 'body' + } + ] + }, + done + ); }); it('should use external references through local parameters definition', function(done) { request(app) .put('/v3/users/foo') .send({}) - .expect(400, { - status: 400, - errors:[ - { - path: 'name', - errorCode: 'required.openapi.validation', - message: 'should have required property \'name\'', - location:'body' - } - ] - }, done); + .expect( + 400, + { + status: 400, + errors: [ + { + path: 'name', + errorCode: 'required.openapi.validation', + message: "should have required property 'name'", + location: 'body' + } + ] + }, + done + ); }); it('should use schema references through local schema definition reference in child schema of response', function(done) { request(app) .get('/v3/users?status=success') - .expect(500, { - errors: [ - { - errorCode: "required.openapi.responseValidation", - message: "response[0] should have required property \'name\'", - path: "response[0]" - } - ], - message: 'The response was not valid.', - status: 500 - }, done); + .expect( + 500, + { + errors: [ + { + errorCode: 'required.openapi.responseValidation', + message: "response[0] should have required property 'name'", + path: 'response[0]' + } + ], + message: 'The response was not valid.', + status: 500 + }, + done + ); }); it('should use schema references through local schema definition reference in response', function(done) { request(app) .get('/v3/users?status=method-not-allowed') - .expect(500, { - errors: [ - { - errorCode: "type.openapi.responseValidation", - message: "response should be string" - }, - { - errorCode: 'enum.openapi.responseValidation', - message: 'response should be equal to one of the allowed values' - } - ], - message: 'The response was not valid.', - status: 500 - }, done); + .expect( + 500, + { + errors: [ + { + errorCode: 'type.openapi.responseValidation', + message: 'response should be string' + }, + { + errorCode: 'enum.openapi.responseValidation', + message: 'response should be equal to one of the allowed values' + } + ], + message: 'The response was not valid.', + status: 500 + }, + done + ); }); it('should use schema references through local response definition reference', function(done) { request(app) .get('/v3/users?status=forbidden') - .expect(500, { - errors: [ - { - errorCode: "type.openapi.responseValidation", - message: "response should be string" - }, - { - errorCode: 'enum.openapi.responseValidation', - message: 'response should be equal to one of the allowed values' - } - ], - message: 'The response was not valid.', - status: 500 - }, done); + .expect( + 500, + { + errors: [ + { + errorCode: 'type.openapi.responseValidation', + message: 'response should be string' + }, + { + errorCode: 'enum.openapi.responseValidation', + message: 'response should be equal to one of the allowed values' + } + ], + message: 'The response was not valid.', + status: 500 + }, + done + ); }); it('should use schema references in child schema of response', function(done) { request(app) .get('/v3/users?status=tea-pod') - .expect(500, { - errors: [ - { - errorCode: "required.openapi.responseValidation", - message: "response should have required property \'content\'" - } - ], - message: 'The response was not valid.', - status: 500 - }, done); + .expect( + 500, + { + errors: [ + { + errorCode: 'required.openapi.responseValidation', + message: "response should have required property 'content'" + } + ], + message: 'The response was not valid.', + status: 500 + }, + done + ); }); it('should use schema references in response', function(done) { request(app) .get('/v3/users?status=error') - .expect(500, { - errors: [ - { - errorCode: "type.openapi.responseValidation", - message: "response should be string" - }, - { - errorCode: 'enum.openapi.responseValidation', - message: 'response should be equal to one of the allowed values' - } - ], - message: 'The response was not valid.', - status: 500 - }, done); + .expect( + 500, + { + errors: [ + { + errorCode: 'type.openapi.responseValidation', + message: 'response should be string' + }, + { + errorCode: 'enum.openapi.responseValidation', + message: 'response should be equal to one of the allowed values' + } + ], + message: 'The response was not valid.', + status: 500 + }, + done + ); }); diff --git a/packages/express-openapi/test/sample-projects/with-http-style-methods/api-doc.js b/packages/express-openapi/test/sample-projects/with-http-style-methods/api-doc.js index f538299b..13e7c6b1 100644 --- a/packages/express-openapi/test/sample-projects/with-http-style-methods/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-http-style-methods/api-doc.js @@ -39,6 +39,6 @@ module.exports = { tags: [ // {name: 'creating'} will be inserted by ./api-routes/users.js // {name: 'fooey'} will be inserted by ./api-routes/users/{id}.js - {description: 'Everything users', name: 'users'} + { description: 'Everything users', name: 'users' } ] }; diff --git a/packages/express-openapi/test/sample-projects/with-http-style-methods/api-routes/users.js b/packages/express-openapi/test/sample-projects/with-http-style-methods/api-routes/users.js index 8037b490..6c7e7200 100644 --- a/packages/express-openapi/test/sample-projects/with-http-style-methods/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/with-http-style-methods/api-routes/users.js @@ -38,7 +38,7 @@ GET.apiDoc = { parameters: [], responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -53,7 +53,7 @@ POST.apiDoc = { parameters: [], responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-http-style-methods/app.js b/packages/express-openapi/test/sample-projects/with-http-style-methods/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-http-style-methods/app.js +++ b/packages/express-openapi/test/sample-projects/with-http-style-methods/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-methodDoc/api-doc.js b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-methodDoc/api-doc.js index 6f884005..d82edf4b 100644 --- a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-methodDoc/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-methodDoc/api-doc.js @@ -1,11 +1,13 @@ // args.apiDoc needs to be a js object. This file could be a json file, but we can't add // comments in json files. module.exports = { - 'x-express-openapi-additional-middleware': [/* generate a warning */ null, - function(req, res, next) { - req.apiDocAdded = true; - next(); - }], + 'x-express-openapi-additional-middleware': [ + /* generate a warning */ null, + function(req, res, next) { + req.apiDocAdded = true; + next(); + } + ], swagger: '2.0', @@ -22,14 +24,14 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: { '/users/{id}': { - 'x-express-openapi-additional-middleware': [function(req, res, next) { - req.pathDocAdded = true; - next(); - }] + 'x-express-openapi-additional-middleware': [ + function(req, res, next) { + req.pathDocAdded = true; + next(); + } + ] } }, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-methodDoc/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-methodDoc/api-routes/users/{id}.js index d2719f6e..19946e51 100644 --- a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-methodDoc/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-methodDoc/api-routes/users/{id}.js @@ -1,8 +1,10 @@ module.exports = { - 'x-express-openapi-additional-middleware': [function(req, res, next) { - req.pathModuleAdded = true; - next(); - }], + 'x-express-openapi-additional-middleware': [ + function(req, res, next) { + req.pathModuleAdded = true; + next(); + } + ], // parameters for all operations in this path parameters: [ @@ -11,7 +13,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], get: get @@ -44,20 +46,21 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { default: { - description: 'showing that additional middleware should have been added at all levels.', + description: + 'showing that additional middleware should have been added at all levels.', schema: { properties: { apiDocAdded: { diff --git a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-methodDoc/app.js b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-methodDoc/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-methodDoc/app.js +++ b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-methodDoc/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathDoc/api-doc.js b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathDoc/api-doc.js index db5778e0..ff709b1a 100644 --- a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathDoc/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathDoc/api-doc.js @@ -1,11 +1,13 @@ // args.apiDoc needs to be a js object. This file could be a json file, but we can't add // comments in json files. module.exports = { - 'x-express-openapi-additional-middleware': [/* generate a warning */ null, - function(req, res, next) { - req.apiDocAdded = true; - next(); - }], + 'x-express-openapi-additional-middleware': [ + /* generate a warning */ null, + function(req, res, next) { + req.apiDocAdded = true; + next(); + } + ], swagger: '2.0', @@ -23,14 +25,14 @@ module.exports = { paths: { '/users/{id}': { 'x-express-openapi-inherit-additional-middleware': false, - 'x-express-openapi-additional-middleware': [function(req, res, next) { - req.pathDocAdded = true; - next(); - }] + 'x-express-openapi-additional-middleware': [ + function(req, res, next) { + req.pathDocAdded = true; + next(); + } + ] } }, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathDoc/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathDoc/api-routes/users/{id}.js index 6b0285ea..96a6f270 100644 --- a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathDoc/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathDoc/api-routes/users/{id}.js @@ -1,8 +1,10 @@ module.exports = { - 'x-express-openapi-additional-middleware': [function(req, res, next) { - req.pathModuleAdded = true; - next(); - }], + 'x-express-openapi-additional-middleware': [ + function(req, res, next) { + req.pathModuleAdded = true; + next(); + } + ], // parameters for all operations in this path parameters: [ @@ -11,7 +13,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], get: get @@ -43,20 +45,21 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { default: { - description: 'showing that additional middleware should have been added at all levels.', + description: + 'showing that additional middleware should have been added at all levels.', schema: { properties: { apiDocAdded: { diff --git a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathDoc/app.js b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathDoc/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathDoc/app.js +++ b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathDoc/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathModule/api-doc.js b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathModule/api-doc.js index 6f884005..d82edf4b 100644 --- a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathModule/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathModule/api-doc.js @@ -1,11 +1,13 @@ // args.apiDoc needs to be a js object. This file could be a json file, but we can't add // comments in json files. module.exports = { - 'x-express-openapi-additional-middleware': [/* generate a warning */ null, - function(req, res, next) { - req.apiDocAdded = true; - next(); - }], + 'x-express-openapi-additional-middleware': [ + /* generate a warning */ null, + function(req, res, next) { + req.apiDocAdded = true; + next(); + } + ], swagger: '2.0', @@ -22,14 +24,14 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: { '/users/{id}': { - 'x-express-openapi-additional-middleware': [function(req, res, next) { - req.pathDocAdded = true; - next(); - }] + 'x-express-openapi-additional-middleware': [ + function(req, res, next) { + req.pathDocAdded = true; + next(); + } + ] } }, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathModule/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathModule/api-routes/users/{id}.js index 894f0e08..3a58969e 100644 --- a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathModule/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathModule/api-routes/users/{id}.js @@ -1,9 +1,11 @@ module.exports = { 'x-express-openapi-inherit-additional-middleware': false, - 'x-express-openapi-additional-middleware': [function(req, res, next) { - req.pathModuleAdded = true; - next(); - }], + 'x-express-openapi-additional-middleware': [ + function(req, res, next) { + req.pathModuleAdded = true; + next(); + } + ], // parameters for all operations in this path parameters: [ @@ -12,7 +14,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], get: get @@ -44,20 +46,21 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { default: { - description: 'showing that additional middleware should have been added at all levels.', + description: + 'showing that additional middleware should have been added at all levels.', schema: { properties: { apiDocAdded: { diff --git a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathModule/app.js b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathModule/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathModule/app.js +++ b/packages/express-openapi/test/sample-projects/with-inherit-additional-middleware-false-at-pathModule/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-invalid-method-doc/api-doc.js b/packages/express-openapi/test/sample-projects/with-invalid-method-doc/api-doc.js index f0b636bf..8b02df2d 100644 --- a/packages/express-openapi/test/sample-projects/with-invalid-method-doc/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-invalid-method-doc/api-doc.js @@ -27,7 +27,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-invalid-method-doc/api-routes/users.js b/packages/express-openapi/test/sample-projects/with-invalid-method-doc/api-routes/users.js index 21577720..85a8027d 100644 --- a/packages/express-openapi/test/sample-projects/with-invalid-method-doc/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/with-invalid-method-doc/api-routes/users.js @@ -1,8 +1,10 @@ // Showing that you don't need to have apiDoc defined on methodHandlers. module.exports = { - get: [function(req, res, next) { - res.status(200).json([{name: 'fred'}]); - }], + get: [ + function(req, res, next) { + res.status(200).json([{ name: 'fred' }]); + } + ], post: function(req, res, next) { res.status(500).json({}); diff --git a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-methodDoc/api-doc.js b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-methodDoc/api-doc.js index 63ca30e2..1535ab28 100644 --- a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-methodDoc/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-methodDoc/api-doc.js @@ -34,7 +34,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-methodDoc/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-methodDoc/api-routes/users/{id}.js index 8d2b5953..0bb398cd 100644 --- a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-methodDoc/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-methodDoc/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -71,27 +76,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-methodDoc/app.js b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-methodDoc/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-methodDoc/app.js +++ b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-methodDoc/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathItem/api-doc.js b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathItem/api-doc.js index c51f03b7..d783e8d5 100644 --- a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathItem/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathItem/api-doc.js @@ -38,7 +38,5 @@ module.exports = { } }, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathItem/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathItem/api-routes/users/{id}.js index 0c00e4e2..3f23c7d5 100644 --- a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathItem/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathItem/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -70,27 +75,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathItem/app.js b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathItem/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathItem/app.js +++ b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathItem/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathModule/api-doc.js b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathModule/api-doc.js index 63ca30e2..1535ab28 100644 --- a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathModule/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathModule/api-doc.js @@ -34,7 +34,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathModule/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathModule/api-routes/users/{id}.js index 8b835aa5..621c73d5 100644 --- a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathModule/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathModule/api-routes/users/{id}.js @@ -8,7 +8,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -17,9 +17,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -38,7 +43,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -72,27 +77,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathModule/app.js b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathModule/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathModule/app.js +++ b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-pathModule/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-the-apiDoc/api-doc.js b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-the-apiDoc/api-doc.js index 4614c023..ff457cb2 100644 --- a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-the-apiDoc/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-the-apiDoc/api-doc.js @@ -36,7 +36,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js index 0c00e4e2..3f23c7d5 100644 --- a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -70,27 +75,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-the-apiDoc/app.js b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-the-apiDoc/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-the-apiDoc/app.js +++ b/packages/express-openapi/test/sample-projects/with-middleware-disabled-in-the-apiDoc/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-doc.js b/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-doc.js index 45899bb0..399e8e89 100644 --- a/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-doc.js @@ -47,7 +47,7 @@ module.exports = { // tags is optional, and is generated / sorted by the tags defined in your path // docs. This API also defines 2 tags in operations: "creating" and "fooey". tags: [ - {description: 'Everything users', name: 'users'}, - {description: 'Everything virtual machines', name: 'vm'} + { description: 'Everything users', name: 'users' }, + { description: 'Everything virtual machines', name: 'vm' } ] }; diff --git a/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-routes/users/{id}@{org}.js b/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-routes/users/{id}@{org}.js index c6fb32cd..1d71c77a 100644 --- a/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-routes/users/{id}@{org}.js +++ b/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-routes/users/{id}@{org}.js @@ -19,27 +19,27 @@ get.apiDoc = { in: 'path', type: 'string', required: true, - description: 'user\'s id' + description: "user's id" }, { name: 'org', in: 'path', type: 'string', required: true, - description: 'user\'s organization.', + description: "user's organization.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-routes/{region}-{az}/{id}.js b/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-routes/{region}-{az}/{id}.js index 263990c0..bf635fae 100644 --- a/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-routes/{region}-{az}/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-routes/{region}-{az}/{id}.js @@ -48,7 +48,7 @@ get.apiDoc = { }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-routes/{region}-{az}/{id}.{type}.js b/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-routes/{region}-{az}/{id}.{type}.js index f032dfa4..16d8d113 100644 --- a/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-routes/{region}-{az}/{id}.{type}.js +++ b/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/api-routes/{region}-{az}/{id}.{type}.js @@ -57,7 +57,7 @@ get.apiDoc = { }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/app.js b/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/app.js +++ b/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/spec.js b/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/spec.js index e49d5731..ba59b972 100644 --- a/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/spec.js +++ b/packages/express-openapi/test/sample-projects/with-multiple-named-parameter-in-a-path-part/spec.js @@ -7,36 +7,45 @@ before(function() { app = require('./app.js'); }); -it('should have a resource with multiple named parameters as resource basename', function (done) { +it('should have a resource with multiple named parameters as resource basename', function(done) { request(app) .get('/v3/users/foo@bar') .expect(200) - .expect({ - id: 'foo', - org: 'bar' - }, done); + .expect( + { + id: 'foo', + org: 'bar' + }, + done + ); }); -it('should have a resource with multiple named parameters as a resource directory name', function (done) { +it('should have a resource with multiple named parameters as a resource directory name', function(done) { request(app) .get('/v3/foo-bar/boo') .expect(200) - .expect({ - id: 'boo', - region: 'foo', - az: 'bar' - }, done); + .expect( + { + id: 'boo', + region: 'foo', + az: 'bar' + }, + done + ); }); -it('should have a resource with multiple named parameters as both of directory and base name', function (done) { +it('should have a resource with multiple named parameters as both of directory and base name', function(done) { request(app) .get('/v3/foo-bar/boo.png') .expect(404) - .expect({ - message: 'file not found', - id: 'boo', - region: 'foo', - az: 'bar', - type: 'png' - }, done); -}); \ No newline at end of file + .expect( + { + message: 'file not found', + id: 'boo', + region: 'foo', + az: 'bar', + type: 'png' + }, + done + ); +}); diff --git a/packages/express-openapi/test/sample-projects/with-path-ignore/app.js b/packages/express-openapi/test/sample-projects/with-path-ignore/app.js index caa6fac2..03fb5bb5 100644 --- a/packages/express-openapi/test/sample-projects/with-path-ignore/app.js +++ b/packages/express-openapi/test/sample-projects/with-path-ignore/app.js @@ -12,7 +12,7 @@ openapi.initialize({ apiDoc: require('./api-doc.js'), app: app, paths: path.resolve(__dirname, 'api-routes'), - pathsIgnore: new RegExp('\.(spec|test)$') + pathsIgnore: new RegExp('.(spec|test)$') }); app.use(function(err, req, res, next) { @@ -21,7 +21,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-path-security/api-routes/boo.js b/packages/express-openapi/test/sample-projects/with-path-security/api-routes/boo.js index e3d748bc..b3f0b22a 100644 --- a/packages/express-openapi/test/sample-projects/with-path-security/api-routes/boo.js +++ b/packages/express-openapi/test/sample-projects/with-path-security/api-routes/boo.js @@ -9,6 +9,6 @@ module.exports.get.apiDoc = { operationId: 'getBoo', parameters: [], responses: { - 204: {description: 'testing security'} + 204: { description: 'testing security' } } }; diff --git a/packages/express-openapi/test/sample-projects/with-path-security/api-routes/fail.js b/packages/express-openapi/test/sample-projects/with-path-security/api-routes/fail.js index b0e07588..52e9ab49 100644 --- a/packages/express-openapi/test/sample-projects/with-path-security/api-routes/fail.js +++ b/packages/express-openapi/test/sample-projects/with-path-security/api-routes/fail.js @@ -9,6 +9,6 @@ module.exports.get.apiDoc = { operationId: 'getFail', parameters: [], responses: { - 204: {description: 'testing security'} + 204: { description: 'testing security' } } }; diff --git a/packages/express-openapi/test/sample-projects/with-path-security/api-routes/foo.js b/packages/express-openapi/test/sample-projects/with-path-security/api-routes/foo.js index 8a1f71df..13a3b619 100644 --- a/packages/express-openapi/test/sample-projects/with-path-security/api-routes/foo.js +++ b/packages/express-openapi/test/sample-projects/with-path-security/api-routes/foo.js @@ -9,6 +9,6 @@ module.exports.get.apiDoc = { operationId: 'getFoo', parameters: [], responses: { - 204: {description: 'testing security'} + 204: { description: 'testing security' } } }; diff --git a/packages/express-openapi/test/sample-projects/with-path-security/api-routes/fooo.js b/packages/express-openapi/test/sample-projects/with-path-security/api-routes/fooo.js index 2e56a842..806044d7 100644 --- a/packages/express-openapi/test/sample-projects/with-path-security/api-routes/fooo.js +++ b/packages/express-openapi/test/sample-projects/with-path-security/api-routes/fooo.js @@ -9,7 +9,7 @@ module.exports.get.apiDoc = { operationId: 'getFooo', parameters: [], responses: { - 204: {description: 'testing security'} + 204: { description: 'testing security' } }, security: [] }; diff --git a/packages/express-openapi/test/sample-projects/with-path-security/app.js b/packages/express-openapi/test/sample-projects/with-path-security/app.js index d6ccbfe0..aff5a01f 100644 --- a/packages/express-openapi/test/sample-projects/with-path-security/app.js +++ b/packages/express-openapi/test/sample-projects/with-path-security/app.js @@ -7,9 +7,9 @@ openapi.initialize({ apiDoc: require('./api-doc.js'), app: app, pathSecurity: [ - [/^\/fa/, [{auth1: []}]], - [/^\/fo/, [{auth2: []}]], - [/^\/q/, [{booAuth: []}]] + [/^\/fa/, [{ auth1: [] }]], + [/^\/fo/, [{ auth2: [] }]], + [/^\/q/, [{ booAuth: [] }]] ], paths: path.resolve(__dirname, 'api-routes'), securityHandlers: { diff --git a/packages/express-openapi/test/sample-projects/with-path-security/spec.js b/packages/express-openapi/test/sample-projects/with-path-security/spec.js index 9925db25..a3cbcb11 100644 --- a/packages/express-openapi/test/sample-projects/with-path-security/spec.js +++ b/packages/express-openapi/test/sample-projects/with-path-security/spec.js @@ -11,7 +11,9 @@ describe('when pathSecurity matches the path', function() { request(app) .get('/v3/fail') .expect(401, 'failed auth1', function(err, results) { - expect(results.res.headers['www-authenticate']).to.equal('Basic realm=foo'); + expect(results.res.headers['www-authenticate']).to.equal( + 'Basic realm=foo' + ); done(err); }); }); @@ -20,7 +22,9 @@ describe('when pathSecurity matches the path', function() { request(app) .get('/v3/foo') .expect(401, 'failed auth2', function(err, results) { - expect(results.res.headers['www-authenticate']).to.equal('Basic realm=foo'); + expect(results.res.headers['www-authenticate']).to.equal( + 'Basic realm=foo' + ); done(err); }); }); @@ -34,7 +38,7 @@ describe('when pathSecurity matches the path', function() { it('should be added to the apiDoc', function(done) { request(app) .get('/v3/api-docs') - .set("Host", "test-host") + .set('Host', 'test-host') .expect(200) .end(function(err, result) { expect(result.body).to.eql(require('./fixtures/expected-api-doc.json')); diff --git a/packages/express-openapi/test/sample-projects/with-promises/api-doc.js b/packages/express-openapi/test/sample-projects/with-promises/api-doc.js index f538299b..13e7c6b1 100644 --- a/packages/express-openapi/test/sample-projects/with-promises/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-promises/api-doc.js @@ -39,6 +39,6 @@ module.exports = { tags: [ // {name: 'creating'} will be inserted by ./api-routes/users.js // {name: 'fooey'} will be inserted by ./api-routes/users/{id}.js - {description: 'Everything users', name: 'users'} + { description: 'Everything users', name: 'users' } ] }; diff --git a/packages/express-openapi/test/sample-projects/with-promises/api-routes/users.js b/packages/express-openapi/test/sample-projects/with-promises/api-routes/users.js index 472281dd..29cf8dc2 100644 --- a/packages/express-openapi/test/sample-projects/with-promises/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/with-promises/api-routes/users.js @@ -11,7 +11,7 @@ module.exports = { function(req, res, next) { return new Promise(function(resolve, reject) { setTimeout(function() { - resolve([{name: 'fred'}]); + resolve([{ name: 'fred' }]); }, 1000); }).then(function(people) { res.status(200).json(people); @@ -35,7 +35,7 @@ module.exports.post.apiDoc = { parameters: [], responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-promises/app.js b/packages/express-openapi/test/sample-projects/with-promises/app.js index ce431532..28a80cff 100644 --- a/packages/express-openapi/test/sample-projects/with-promises/app.js +++ b/packages/express-openapi/test/sample-projects/with-promises/app.js @@ -21,7 +21,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-promises/spec.js b/packages/express-openapi/test/sample-projects/with-promises/spec.js index 609b6d0f..8585866a 100644 --- a/packages/express-openapi/test/sample-projects/with-promises/spec.js +++ b/packages/express-openapi/test/sample-projects/with-promises/spec.js @@ -11,7 +11,7 @@ it('should allow responses', function(done) { .get('/v3/users') .expect(200) .end(function(err, res) { - expect(res.body).to.eql([{name: 'fred'}]); + expect(res.body).to.eql([{ name: 'fred' }]); done(err); }); }); @@ -19,7 +19,7 @@ it('should allow responses', function(done) { it('should use catch errors', function(done) { request(app) .post('/v3/users') - .send({name: 'fred'}) + .send({ name: 'fred' }) .expect(400) .end(function(err, res) { expect(res.body).to.eql('something was missing'); diff --git a/packages/express-openapi/test/sample-projects/with-referenced-parameter-missing/api-doc.js b/packages/express-openapi/test/sample-projects/with-referenced-parameter-missing/api-doc.js index d4f5850f..fb44fb00 100644 --- a/packages/express-openapi/test/sample-projects/with-referenced-parameter-missing/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-referenced-parameter-missing/api-doc.js @@ -13,8 +13,7 @@ module.exports = { definitions: {}, - parameters: { - }, + parameters: {}, responses: { SuccessResponse: { diff --git a/packages/express-openapi/test/sample-projects/with-referenced-parameter-missing/api-routes/foo.js b/packages/express-openapi/test/sample-projects/with-referenced-parameter-missing/api-routes/foo.js index a36f9d5c..f0afa41d 100644 --- a/packages/express-openapi/test/sample-projects/with-referenced-parameter-missing/api-routes/foo.js +++ b/packages/express-openapi/test/sample-projects/with-referenced-parameter-missing/api-routes/foo.js @@ -5,14 +5,14 @@ module.exports = { } ], get: function(req, res, next) { - var statusCode = req.query.foo === 'success' ? - 200 : - 500; + var statusCode = req.query.foo === 'success' ? 200 : 500; var errors = res.validateResponse(statusCode, req.query.boo); res.status(statusCode).json(errors); }, // handling no method doc - post: function() {} + post: function() { + return; + } }; module.exports.get.apiDoc = { diff --git a/packages/express-openapi/test/sample-projects/with-referenced-parameter-missing/app.js b/packages/express-openapi/test/sample-projects/with-referenced-parameter-missing/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-referenced-parameter-missing/app.js +++ b/packages/express-openapi/test/sample-projects/with-referenced-parameter-missing/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-referenced-response-missing/api-doc.js b/packages/express-openapi/test/sample-projects/with-referenced-response-missing/api-doc.js index 9e29bbe1..934c2856 100644 --- a/packages/express-openapi/test/sample-projects/with-referenced-response-missing/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-referenced-response-missing/api-doc.js @@ -25,10 +25,7 @@ module.exports = { type: 'string', name: 'foo', required: true, - enum: [ - 'success', - 'error' - ] + enum: ['success', 'error'] } }, diff --git a/packages/express-openapi/test/sample-projects/with-referenced-response-missing/api-routes/foo.js b/packages/express-openapi/test/sample-projects/with-referenced-response-missing/api-routes/foo.js index a36f9d5c..f0afa41d 100644 --- a/packages/express-openapi/test/sample-projects/with-referenced-response-missing/api-routes/foo.js +++ b/packages/express-openapi/test/sample-projects/with-referenced-response-missing/api-routes/foo.js @@ -5,14 +5,14 @@ module.exports = { } ], get: function(req, res, next) { - var statusCode = req.query.foo === 'success' ? - 200 : - 500; + var statusCode = req.query.foo === 'success' ? 200 : 500; var errors = res.validateResponse(statusCode, req.query.boo); res.status(statusCode).json(errors); }, // handling no method doc - post: function() {} + post: function() { + return; + } }; module.exports.get.apiDoc = { diff --git a/packages/express-openapi/test/sample-projects/with-referenced-response-missing/app.js b/packages/express-openapi/test/sample-projects/with-referenced-response-missing/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-referenced-response-missing/app.js +++ b/packages/express-openapi/test/sample-projects/with-referenced-response-missing/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-methodDoc/api-doc.js b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-methodDoc/api-doc.js index 63ca30e2..1535ab28 100644 --- a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-methodDoc/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-methodDoc/api-doc.js @@ -34,7 +34,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-methodDoc/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-methodDoc/api-routes/users/{id}.js index ba49ead4..6c094ce2 100644 --- a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-methodDoc/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-methodDoc/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -67,27 +72,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-methodDoc/app.js b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-methodDoc/app.js index c91d5b3a..965dd847 100644 --- a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-methodDoc/app.js +++ b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-methodDoc/app.js @@ -21,7 +21,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathItem/api-doc.js b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathItem/api-doc.js index 86eaf137..9873c2c0 100644 --- a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathItem/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathItem/api-doc.js @@ -38,7 +38,5 @@ module.exports = { } }, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathItem/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathItem/api-routes/users/{id}.js index e0464009..81386463 100644 --- a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathItem/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathItem/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -66,27 +71,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathItem/app.js b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathItem/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathItem/app.js +++ b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathItem/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathModule/api-doc.js b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathModule/api-doc.js index 63ca30e2..1535ab28 100644 --- a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathModule/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathModule/api-doc.js @@ -34,7 +34,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathModule/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathModule/api-routes/users/{id}.js index 2d687c20..d9353f2e 100644 --- a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathModule/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathModule/api-routes/users/{id}.js @@ -8,7 +8,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -17,9 +17,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -38,7 +43,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -68,27 +73,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathModule/app.js b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathModule/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathModule/app.js +++ b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-pathModule/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-the-apiDoc/api-doc.js b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-the-apiDoc/api-doc.js index 91730d1e..652130e5 100644 --- a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-the-apiDoc/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-the-apiDoc/api-doc.js @@ -36,7 +36,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js index e0464009..81386463 100644 --- a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -66,27 +71,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-the-apiDoc/app.js b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-the-apiDoc/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-the-apiDoc/app.js +++ b/packages/express-openapi/test/sample-projects/with-response-validation-middleware-disabled-in-the-apiDoc/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-doc.js b/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-doc.js index f538299b..13e7c6b1 100644 --- a/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-doc.js @@ -39,6 +39,6 @@ module.exports = { tags: [ // {name: 'creating'} will be inserted by ./api-routes/users.js // {name: 'fooey'} will be inserted by ./api-routes/users/{id}.js - {description: 'Everything users', name: 'users'} + { description: 'Everything users', name: 'users' } ] }; diff --git a/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-routes/apiDocs.js b/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-routes/apiDocs.js index ebb0971d..4e853375 100644 --- a/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-routes/apiDocs.js +++ b/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-routes/apiDocs.js @@ -17,10 +17,7 @@ get.apiDoc = { in: 'query', name: 'type', type: 'string', - enum: [ - 'apiDoc', - 'operationDoc' - ] + enum: ['apiDoc', 'operationDoc'] } ], responses: { @@ -31,7 +28,7 @@ get.apiDoc = { } }, default: { - description: 'The requested apiDoc.', + description: 'The requested apiDoc.' } } }; diff --git a/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-routes/users.js b/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-routes/users.js index 6682323a..ef3d6807 100644 --- a/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-routes/users.js @@ -8,11 +8,16 @@ module.exports = { return next(validationError); } - res.status(204).send('').end(); + res + .status(204) + .send('') + .end(); }, - get: [function(req, res, next) { - res.status(200).json([{name: 'fred'}]); - }], + get: [ + function(req, res, next) { + res.status(200).json([{ name: 'fred' }]); + } + ], post: function(req, res, next) { res.status(500).json({}); @@ -42,7 +47,7 @@ module.exports.post.apiDoc = { parameters: [], responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-routes/users/{id}.js index 638a56a2..29da65e7 100644 --- a/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,11 +15,16 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, post] + post: [ + function(req, res, next) { + next(); + }, + post + ] }; function post(req, res) { - res.status(200).json({id: req.params.id}); + res.status(200).json({ id: req.params.id }); } // verify that apiDoc is available with middleware @@ -39,7 +44,7 @@ post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -73,27 +78,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/app.js b/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/app.js index b30a8bb2..890e05d2 100644 --- a/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/app.js +++ b/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/app.js @@ -9,8 +9,8 @@ app.use(cors()); app.use(bodyParser.json()); var paths = [ - { path: '/apiDocs', module: require('./api-routes/apiDocs') }, - { path: '/users', module: require('./api-routes/users') }, + { path: '/apiDocs', module: require('./api-routes/apiDocs') }, + { path: '/users', module: require('./api-routes/users') }, { path: '/users/{id}', module: require('./api-routes/users/{id}') } ]; @@ -26,7 +26,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/spec.js b/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/spec.js index 7668fe9f..5346ee49 100644 --- a/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/spec.js +++ b/packages/express-openapi/test/sample-projects/with-route-specs-using-modules/spec.js @@ -10,7 +10,7 @@ before(function() { it('should expose .basePath/api-docs', function(done) { request(app) .get('/v3/api-docs') - .set("Host", "test-host") + .set('Host', 'test-host') .expect(200, expectedApiDoc, done); }); @@ -25,7 +25,7 @@ it('should use defaults, coercion, and operation parameter overriding', function .get('/v3/users/34?name=fred') .expect(200) .end(function(err, res) { - expect(res.body).to.eql({id: 34, name: 'fred', age: 80}); + expect(res.body).to.eql({ id: 34, name: 'fred', age: 80 }); done(err); }); }); @@ -33,23 +33,30 @@ it('should use defaults, coercion, and operation parameter overriding', function it('should validate input', function(done) { request(app) .get('/v3/users/34?name=barney') - .expect(400, {errors: [ + .expect( + 400, { - errorCode: 'pattern.openapi.validation', - location: 'query', - message: 'should match pattern \"^fred$\"', - path: 'name' - } - ], status: 400}, done); + errors: [ + { + errorCode: 'pattern.openapi.validation', + location: 'query', + message: 'should match pattern "^fred$"', + path: 'name' + } + ], + status: 400 + }, + done + ); }); it('should use path parameters', function(done) { request(app) .post('/v3/users/34') - .send({name: 'fred'}) + .send({ name: 'fred' }) .expect(200) .end(function(err, res) { - expect(res.body).to.eql({id: '34'}); + expect(res.body).to.eql({ id: '34' }); done(err); }); }); @@ -82,12 +89,19 @@ it('should dereference #/definitions/ for validation', function(done) { request(app) .post('/v3/users/34?name=barney') .send(user) - .expect(400, {errors: [ + .expect( + 400, { - errorCode: 'required.openapi.validation', - location: 'body', - message: 'should have required property \'name\'', - path: 'name' - } - ], status: 400}, done); + errors: [ + { + errorCode: 'required.openapi.validation', + location: 'body', + message: "should have required property 'name'", + path: 'name' + } + ], + status: 400 + }, + done + ); }); diff --git a/packages/express-openapi/test/sample-projects/with-routes-array/spec.js b/packages/express-openapi/test/sample-projects/with-routes-array/spec.js index 65514d3c..3840df1a 100644 --- a/packages/express-openapi/test/sample-projects/with-routes-array/spec.js +++ b/packages/express-openapi/test/sample-projects/with-routes-array/spec.js @@ -21,7 +21,7 @@ it('should expose the second set of routes', function(done) { it('should be added to the apiDoc', function(done) { request(app) .get('/v3/api-docs') - .set("Host", "test-host") + .set('Host', 'test-host') .expect(200) .end(function(err, result) { expect(result.body).to.eql(require('./fixtures/expected-api-doc.json')); diff --git a/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/api-routes/boo.js b/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/api-routes/boo.js index 4c7bdc81..6ed08037 100644 --- a/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/api-routes/boo.js +++ b/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/api-routes/boo.js @@ -1,7 +1,7 @@ module.exports = function( - /* I can inject the parameters in any order */injected2, - injected1 /* and add comments */ ) { - + /* I can inject the parameters in any order */ injected2, + injected1 /* and add comments */ +) { var doc = { get: function(req, res, next) { res.status(200).send('boo'); @@ -22,5 +22,3 @@ module.exports = function( }; return doc; }; - - diff --git a/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/api-routes/foo.js b/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/api-routes/foo.js index 7f62b791..2c0c56fc 100644 --- a/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/api-routes/foo.js +++ b/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/api-routes/foo.js @@ -1,17 +1,16 @@ module.exports = function(/*no params*/) { - var doc = { get: function(req, res, next) { res.status(200).send('foo'); } }; doc.get.apiDoc = { - description: "Get foo.", + description: 'Get foo.', operationId: 'getFoo', parameters: [], responses: { 200: { - description: "foo", + description: 'foo', schema: { type: 'string' } @@ -20,5 +19,3 @@ module.exports = function(/*no params*/) { }; return doc; }; - - diff --git a/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/app.js b/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/app.js index 21acd6ad..79e64f99 100644 --- a/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/app.js +++ b/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/app.js @@ -4,16 +4,17 @@ var openapi = require('../../../'); var path = require('path'); openapi.initialize({ - apiDoc: require('./api-doc.js'), - app: app, - paths: [ - path.resolve(__dirname, 'api-routes'), - ], - dependencies: {injected1: {description: "Get boo."}, injected2: {description: "boo"}} + apiDoc: require('./api-doc.js'), + app: app, + paths: [path.resolve(__dirname, 'api-routes')], + dependencies: { + injected1: { description: 'Get boo.' }, + injected2: { description: 'boo' } + } }); -app.use(function (err, req, res, next) { - console.log(err); +app.use(function(err, req, res, next) { + console.log(err); }); module.exports = app; diff --git a/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/spec.js b/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/spec.js index aacf1aba..5300399d 100644 --- a/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/spec.js +++ b/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object/spec.js @@ -15,7 +15,7 @@ it('should expose the first set of routes', function(done) { it('should be added to the apiDoc', function(done) { request(app) .get('/v3/api-docs') - .set("Host", "test-host") + .set('Host', 'test-host') .expect(200) .end(function(err, result) { expect(result.body).to.eql(require('./fixtures/expected-api-doc.json')); diff --git a/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object2/api-routes/boo.js b/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object2/api-routes/boo.js index 4c7bdc81..6ed08037 100644 --- a/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object2/api-routes/boo.js +++ b/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object2/api-routes/boo.js @@ -1,7 +1,7 @@ module.exports = function( - /* I can inject the parameters in any order */injected2, - injected1 /* and add comments */ ) { - + /* I can inject the parameters in any order */ injected2, + injected1 /* and add comments */ +) { var doc = { get: function(req, res, next) { res.status(200).send('boo'); @@ -22,5 +22,3 @@ module.exports = function( }; return doc; }; - - diff --git a/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object2/api-routes/foo.js b/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object2/api-routes/foo.js index 46741ddd..1c3a4876 100644 --- a/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object2/api-routes/foo.js +++ b/packages/express-openapi/test/sample-projects/with-routes-dependency-injection-object2/api-routes/foo.js @@ -1,17 +1,16 @@ module.exports = function(iamnotinjected) { - var doc = { get: function(req, res, next) { res.status(200).send('foo'); } }; doc.get.apiDoc = { - description: "Get foo.", + description: 'Get foo.', operationId: 'getFoo', parameters: [], responses: { 200: { - description: "foo", + description: 'foo', schema: { type: 'string' } @@ -20,5 +19,3 @@ module.exports = function(iamnotinjected) { }; return doc; }; - - diff --git a/packages/express-openapi/test/sample-projects/with-schema-extension/api-doc.js b/packages/express-openapi/test/sample-projects/with-schema-extension/api-doc.js index 87369fe7..a5f6aa30 100644 --- a/packages/express-openapi/test/sample-projects/with-schema-extension/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-schema-extension/api-doc.js @@ -3,7 +3,7 @@ module.exports = { swagger: '2.0', - host: "test-host", + host: 'test-host', // all routes will now have /v3 prefixed. basePath: '/v3', @@ -17,10 +17,10 @@ module.exports = { schema: { properties: { oneOf: { - type: "array", + type: 'array', minItems: 1, items: { - $ref: "#/definitions/schema" + $ref: '#/definitions/schema' } } } @@ -35,10 +35,7 @@ module.exports = { User: { properties: { name: { - oneOf: [ - { type: 'string' }, - { type: 'null' } - ] + oneOf: [{ type: 'string' }, { type: 'null' }] }, friends: { type: 'array', @@ -59,6 +56,6 @@ module.exports = { tags: [ // {name: 'creating'} will be inserted by ./api-routes/users.js // {name: 'fooey'} will be inserted by ./api-routes/users/{id}.js - {description: 'Everything users', name: 'users'} + { description: 'Everything users', name: 'users' } ] }; diff --git a/packages/express-openapi/test/sample-projects/with-schema-extension/api-routes/apiDocs.js b/packages/express-openapi/test/sample-projects/with-schema-extension/api-routes/apiDocs.js index ebb0971d..4e853375 100644 --- a/packages/express-openapi/test/sample-projects/with-schema-extension/api-routes/apiDocs.js +++ b/packages/express-openapi/test/sample-projects/with-schema-extension/api-routes/apiDocs.js @@ -17,10 +17,7 @@ get.apiDoc = { in: 'query', name: 'type', type: 'string', - enum: [ - 'apiDoc', - 'operationDoc' - ] + enum: ['apiDoc', 'operationDoc'] } ], responses: { @@ -31,7 +28,7 @@ get.apiDoc = { } }, default: { - description: 'The requested apiDoc.', + description: 'The requested apiDoc.' } } }; diff --git a/packages/express-openapi/test/sample-projects/with-schema-extension/api-routes/users.js b/packages/express-openapi/test/sample-projects/with-schema-extension/api-routes/users.js index 6682323a..ef3d6807 100644 --- a/packages/express-openapi/test/sample-projects/with-schema-extension/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/with-schema-extension/api-routes/users.js @@ -8,11 +8,16 @@ module.exports = { return next(validationError); } - res.status(204).send('').end(); + res + .status(204) + .send('') + .end(); }, - get: [function(req, res, next) { - res.status(200).json([{name: 'fred'}]); - }], + get: [ + function(req, res, next) { + res.status(200).json([{ name: 'fred' }]); + } + ], post: function(req, res, next) { res.status(500).json({}); @@ -42,7 +47,7 @@ module.exports.post.apiDoc = { parameters: [], responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-schema-extension/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-schema-extension/api-routes/users/{id}.js index 638a56a2..29da65e7 100644 --- a/packages/express-openapi/test/sample-projects/with-schema-extension/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-schema-extension/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,11 +15,16 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, post] + post: [ + function(req, res, next) { + next(); + }, + post + ] }; function post(req, res) { - res.status(200).json({id: req.params.id}); + res.status(200).json({ id: req.params.id }); } // verify that apiDoc is available with middleware @@ -39,7 +44,7 @@ post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -73,27 +78,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-schema-extension/app.js b/packages/express-openapi/test/sample-projects/with-schema-extension/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-schema-extension/app.js +++ b/packages/express-openapi/test/sample-projects/with-schema-extension/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-schema-extension/spec.js b/packages/express-openapi/test/sample-projects/with-schema-extension/spec.js index bc97cfaa..36d49152 100644 --- a/packages/express-openapi/test/sample-projects/with-schema-extension/spec.js +++ b/packages/express-openapi/test/sample-projects/with-schema-extension/spec.js @@ -10,7 +10,7 @@ before(function() { it('should expose .basePath/api-docs', function(done) { request(app) .get('/v3/api-docs') - .set("Host", "test-host") + .set('Host', 'test-host') .expect(200, expectedApiDoc, done); }); @@ -25,7 +25,7 @@ it('should use defaults, coercion, and operation parameter overriding', function .get('/v3/users/34?name=fred') .expect(200) .end(function(err, res) { - expect(res.body).to.eql({id: 34, name: 'fred', age: 80}); + expect(res.body).to.eql({ id: 34, name: 'fred', age: 80 }); done(err); }); }); @@ -33,23 +33,30 @@ it('should use defaults, coercion, and operation parameter overriding', function it('should validate input', function(done) { request(app) .get('/v3/users/34?name=barney') - .expect(400, {errors: [ + .expect( + 400, { - errorCode: 'pattern.openapi.validation', - location: 'query', - message: 'should match pattern \"^fred$\"', - path: 'name' - } - ], status: 400}, done); + errors: [ + { + errorCode: 'pattern.openapi.validation', + location: 'query', + message: 'should match pattern "^fred$"', + path: 'name' + } + ], + status: 400 + }, + done + ); }); it('should use path parameters', function(done) { request(app) .post('/v3/users/34') - .send({name: null}) + .send({ name: null }) .expect(200) .end(function(err, res) { - expect(res.body).to.eql({id: '34'}); + expect(res.body).to.eql({ id: '34' }); done(err); }); }); @@ -80,12 +87,19 @@ it('should dereference #/definitions/ for validation', function(done) { request(app) .post('/v3/users/34?name=barney') .send(user) - .expect(400, {errors: [ + .expect( + 400, { - errorCode: 'required.openapi.validation', - location: 'body', - message: 'should have required property \'name\'', - path: 'name' - } - ], status: 400}, done); + errors: [ + { + errorCode: 'required.openapi.validation', + location: 'body', + message: "should have required property 'name'", + path: 'name' + } + ], + status: 400 + }, + done + ); }); diff --git a/packages/express-openapi/test/sample-projects/with-securityFilter/api-doc.js b/packages/express-openapi/test/sample-projects/with-securityFilter/api-doc.js index 4e6fe6d6..f2dae01d 100644 --- a/packages/express-openapi/test/sample-projects/with-securityFilter/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-securityFilter/api-doc.js @@ -21,8 +21,8 @@ module.exports = { } } }, - required: [ 'name' ] - }, + required: ['name'] + } }, paths: {}, tags: [ diff --git a/packages/express-openapi/test/sample-projects/with-securityFilter/api-routes/users.js b/packages/express-openapi/test/sample-projects/with-securityFilter/api-routes/users.js index db0e3ef3..0a06b1a4 100644 --- a/packages/express-openapi/test/sample-projects/with-securityFilter/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/with-securityFilter/api-routes/users.js @@ -1,3 +1,5 @@ module.exports = { - get: function(req, res, next) {} + get: function(req, res, next) { + return; + } }; diff --git a/packages/express-openapi/test/sample-projects/with-securityFilter/app.js b/packages/express-openapi/test/sample-projects/with-securityFilter/app.js index 13f9a5ab..dabeb185 100644 --- a/packages/express-openapi/test/sample-projects/with-securityFilter/app.js +++ b/packages/express-openapi/test/sample-projects/with-securityFilter/app.js @@ -13,7 +13,7 @@ openapi.initialize({ app: app, paths: path.resolve(__dirname, 'api-routes'), securityFilter: function(req, res, next) { - if (req.headers['authorization'] !== 'Basic foo') { + if (req.headers.authorization !== 'Basic foo') { return next({ message: 'not authenticated to view api docs', status: 400 @@ -29,7 +29,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-securityHandlers/api-routes/boo.js b/packages/express-openapi/test/sample-projects/with-securityHandlers/api-routes/boo.js index 98730851..f1ed5edd 100644 --- a/packages/express-openapi/test/sample-projects/with-securityHandlers/api-routes/boo.js +++ b/packages/express-openapi/test/sample-projects/with-securityHandlers/api-routes/boo.js @@ -9,6 +9,6 @@ module.exports.get.apiDoc = { operationId: 'getBoo', parameters: [], responses: { - 204: {description: 'testing security'} + 204: { description: 'testing security' } } }; diff --git a/packages/express-openapi/test/sample-projects/with-securityHandlers/api-routes/fail.js b/packages/express-openapi/test/sample-projects/with-securityHandlers/api-routes/fail.js index 58d07386..12527c33 100644 --- a/packages/express-openapi/test/sample-projects/with-securityHandlers/api-routes/fail.js +++ b/packages/express-openapi/test/sample-projects/with-securityHandlers/api-routes/fail.js @@ -14,6 +14,6 @@ module.exports.get.apiDoc = { } ], responses: { - 204: {description: 'testing security'} + 204: { description: 'testing security' } } }; diff --git a/packages/express-openapi/test/sample-projects/with-securityHandlers/api-routes/foo.js b/packages/express-openapi/test/sample-projects/with-securityHandlers/api-routes/foo.js index 3903a457..a84c2896 100644 --- a/packages/express-openapi/test/sample-projects/with-securityHandlers/api-routes/foo.js +++ b/packages/express-openapi/test/sample-projects/with-securityHandlers/api-routes/foo.js @@ -14,6 +14,6 @@ module.exports.get.apiDoc = { } ], responses: { - 204: {description: 'testing security'} + 204: { description: 'testing security' } } }; diff --git a/packages/express-openapi/test/sample-projects/with-securityHandlers/spec.js b/packages/express-openapi/test/sample-projects/with-securityHandlers/spec.js index 40ec6ab5..df7d4fce 100644 --- a/packages/express-openapi/test/sample-projects/with-securityHandlers/spec.js +++ b/packages/express-openapi/test/sample-projects/with-securityHandlers/spec.js @@ -27,7 +27,9 @@ describe('when authentication fails', function() { request(app) .get('/v3/fail') .expect(401, '', function(err, results) { - expect(results.res.headers['www-authenticate']).to.equal('Basic realm=foo'); + expect(results.res.headers['www-authenticate']).to.equal( + 'Basic realm=foo' + ); done(err); }); }); diff --git a/packages/express-openapi/test/sample-projects/with-trailing-slash-in-basePath/api-routes/users.js b/packages/express-openapi/test/sample-projects/with-trailing-slash-in-basePath/api-routes/users.js index 78265717..c4bd7354 100644 --- a/packages/express-openapi/test/sample-projects/with-trailing-slash-in-basePath/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/with-trailing-slash-in-basePath/api-routes/users.js @@ -11,7 +11,7 @@ module.exports = { function(req, res, next) { return new Promise(function(resolve, reject) { setTimeout(function() { - resolve([{name: 'fred'}]); + resolve([{ name: 'fred' }]); }, 1000); }).then(function(people) { res.status(200).json(people); diff --git a/packages/express-openapi/test/sample-projects/with-trailing-slash-in-basePath/app.js b/packages/express-openapi/test/sample-projects/with-trailing-slash-in-basePath/app.js index 439afb78..4643db45 100644 --- a/packages/express-openapi/test/sample-projects/with-trailing-slash-in-basePath/app.js +++ b/packages/express-openapi/test/sample-projects/with-trailing-slash-in-basePath/app.js @@ -22,7 +22,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-trailing-slash-in-basePath/spec.js b/packages/express-openapi/test/sample-projects/with-trailing-slash-in-basePath/spec.js index 7ceb7258..42ff11b1 100644 --- a/packages/express-openapi/test/sample-projects/with-trailing-slash-in-basePath/spec.js +++ b/packages/express-openapi/test/sample-projects/with-trailing-slash-in-basePath/spec.js @@ -17,7 +17,7 @@ describe('with trailing slash in basePath', () => { it('should expose routes', function(done) { request(app) .post('/v3/users') - .send({name: 'fred'}) + .send({ name: 'fred' }) .expect(400) .end(function(err, res) { expect(res.body).to.eql('something was missing'); diff --git a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-methodDoc/api-doc.js b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-methodDoc/api-doc.js index 63ca30e2..1535ab28 100644 --- a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-methodDoc/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-methodDoc/api-doc.js @@ -34,7 +34,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-methodDoc/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-methodDoc/api-routes/users/{id}.js index 49f80ed2..2a78e820 100644 --- a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-methodDoc/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-methodDoc/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -71,27 +76,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-methodDoc/app.js b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-methodDoc/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-methodDoc/app.js +++ b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-methodDoc/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathItem/api-doc.js b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathItem/api-doc.js index 103621ce..aa7ea3d5 100644 --- a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathItem/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathItem/api-doc.js @@ -38,7 +38,5 @@ module.exports = { } }, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathItem/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathItem/api-routes/users/{id}.js index 0c00e4e2..3f23c7d5 100644 --- a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathItem/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathItem/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -70,27 +75,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathItem/app.js b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathItem/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathItem/app.js +++ b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathItem/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathModule/api-doc.js b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathModule/api-doc.js index 63ca30e2..1535ab28 100644 --- a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathModule/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathModule/api-doc.js @@ -34,7 +34,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathModule/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathModule/api-routes/users/{id}.js index 0316aea2..6f8b5c77 100644 --- a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathModule/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathModule/api-routes/users/{id}.js @@ -8,7 +8,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -17,9 +17,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -38,7 +43,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -72,27 +77,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathModule/app.js b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathModule/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathModule/app.js +++ b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-pathModule/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-the-apiDoc/api-doc.js b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-the-apiDoc/api-doc.js index 19ca6cc4..c88c10bd 100644 --- a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-the-apiDoc/api-doc.js +++ b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-the-apiDoc/api-doc.js @@ -36,7 +36,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js index 0c00e4e2..3f23c7d5 100644 --- a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-the-apiDoc/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,9 +15,14 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(200).json({id: req.params.id}); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(200).json({ id: req.params.id }); + } + ] }; module.exports.post.apiDoc = { @@ -36,7 +41,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -70,27 +75,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-the-apiDoc/app.js b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-the-apiDoc/app.js index 4aa4350d..d4d1d198 100644 --- a/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-the-apiDoc/app.js +++ b/packages/express-openapi/test/sample-projects/with-validation-middleware-disabled-in-the-apiDoc/app.js @@ -20,7 +20,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-yaml/api-routes/users.js b/packages/express-openapi/test/sample-projects/with-yaml/api-routes/users.js index 78265717..c4bd7354 100644 --- a/packages/express-openapi/test/sample-projects/with-yaml/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/with-yaml/api-routes/users.js @@ -11,7 +11,7 @@ module.exports = { function(req, res, next) { return new Promise(function(resolve, reject) { setTimeout(function() { - resolve([{name: 'fred'}]); + resolve([{ name: 'fred' }]); }, 1000); }).then(function(people) { res.status(200).json(people); diff --git a/packages/express-openapi/test/sample-projects/with-yaml/app.js b/packages/express-openapi/test/sample-projects/with-yaml/app.js index 439afb78..4643db45 100644 --- a/packages/express-openapi/test/sample-projects/with-yaml/app.js +++ b/packages/express-openapi/test/sample-projects/with-yaml/app.js @@ -22,7 +22,7 @@ app.use(function(err, req, res, next) { module.exports = app; -var port = parseInt(process.argv[2]); +var port = parseInt(process.argv[2], 10); if (port) { app.listen(port); } diff --git a/packages/express-openapi/test/sample-projects/with-yaml/spec.js b/packages/express-openapi/test/sample-projects/with-yaml/spec.js index a79df49b..dcee59f2 100644 --- a/packages/express-openapi/test/sample-projects/with-yaml/spec.js +++ b/packages/express-openapi/test/sample-projects/with-yaml/spec.js @@ -12,7 +12,7 @@ describe('with yaml apiDoc and yaml operationDoc', () => { .get('/v3/users') .expect(200) .end(function(err, res) { - expect(res.body).to.eql([{name: 'fred'}]); + expect(res.body).to.eql([{ name: 'fred' }]); done(err); }); }); @@ -20,7 +20,7 @@ describe('with yaml apiDoc and yaml operationDoc', () => { it('should use catch errors', function(done) { request(app) .post('/v3/users') - .send({name: 'fred'}) + .send({ name: 'fred' }) .expect(400) .end(function(err, res) { expect(res.body).to.eql('something was missing'); diff --git a/packages/express-openapi/test/sample-projects/without-basePath-and-different-docsPath/api-doc.js b/packages/express-openapi/test/sample-projects/without-basePath-and-different-docsPath/api-doc.js index d0f5f269..97cf0169 100644 --- a/packages/express-openapi/test/sample-projects/without-basePath-and-different-docsPath/api-doc.js +++ b/packages/express-openapi/test/sample-projects/without-basePath-and-different-docsPath/api-doc.js @@ -25,7 +25,5 @@ module.exports = { // paths are derived from args.routes. These are filled in by fs-routes. paths: {}, - tags: [ - {name: 'users'} - ] + tags: [{ name: 'users' }] }; diff --git a/packages/express-openapi/test/sample-projects/without-basePath-and-different-docsPath/api-routes/users.js b/packages/express-openapi/test/sample-projects/without-basePath-and-different-docsPath/api-routes/users.js index 9419d51e..1a0e9e67 100644 --- a/packages/express-openapi/test/sample-projects/without-basePath-and-different-docsPath/api-routes/users.js +++ b/packages/express-openapi/test/sample-projects/without-basePath-and-different-docsPath/api-routes/users.js @@ -1,8 +1,10 @@ // Showing that you don't need to have apiDoc defined on methodHandlers. module.exports = { - get: [function(req, res, next) { - res.status(200).json([{name: 'fred'}]); - }], + get: [ + function(req, res, next) { + res.status(200).json([{ name: 'fred' }]); + } + ], post: function(req, res, next) { res.status(500).json({}); @@ -15,7 +17,7 @@ module.exports.post.apiDoc = { parameters: [], responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/express-openapi/test/sample-projects/without-basePath-and-different-docsPath/api-routes/users/{id}.js b/packages/express-openapi/test/sample-projects/without-basePath-and-different-docsPath/api-routes/users/{id}.js index 208b74f4..c92d7c08 100644 --- a/packages/express-openapi/test/sample-projects/without-basePath-and-different-docsPath/api-routes/users/{id}.js +++ b/packages/express-openapi/test/sample-projects/without-basePath-and-different-docsPath/api-routes/users/{id}.js @@ -4,9 +4,14 @@ module.exports = { // or they may also be an array of middleware + the method handler. This allows // for flexible middleware management. express-openapi middleware generated from // the .apiDoc.parameters is prepended to this array. - post: [function(req, res, next) {next();}, function(req, res) { - res.status(500).json('only one user is returned by this API.'); - }] + post: [ + function(req, res, next) { + next(); + }, + function(req, res) { + res.status(500).json('only one user is returned by this API.'); + } + ] }; module.exports.post.apiDoc = { @@ -25,7 +30,7 @@ module.exports.post.apiDoc = { responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -59,28 +64,28 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/fetch-openapi/bin/fetch-openapi.js b/packages/fetch-openapi/bin/fetch-openapi.js index 666ddcd0..14165bfc 100755 --- a/packages/fetch-openapi/bin/fetch-openapi.js +++ b/packages/fetch-openapi/bin/fetch-openapi.js @@ -1,5 +1,5 @@ #!/usr/bin/env node - +/* tslint:disable:no-shadowed-variable */ var chalk = require('chalk'); var cli = require('commander'); var errHandler = require('err-handler'); @@ -11,11 +11,25 @@ var request = require('request'); cli .version(require('../package.json').version) - .description('This script requests an OpenAPI document and processes it with fetch-openapi.') - .option('--api-doc-file-path [file path]', 'The local path to your OpenAPI document E.G. ./schemas/v2/swagger.json') - .option('--api-doc-url [url]', 'The URL to your OpenAPI document E.G. http://petstore.swagger.io/v2/swagger.json') - .option('--output-file-path [file path]', 'The path to the file generated by fetch-openapi. If it currently exists it will be overwritten.') - .option('--preset [preset]', 'May be one of the following values: es6, node (default)') + .description( + 'This script requests an OpenAPI document and processes it with fetch-openapi.' + ) + .option( + '--api-doc-file-path [file path]', + 'The local path to your OpenAPI document E.G. ./schemas/v2/swagger.json' + ) + .option( + '--api-doc-url [url]', + 'The URL to your OpenAPI document E.G. http://petstore.swagger.io/v2/swagger.json' + ) + .option( + '--output-file-path [file path]', + 'The path to the file generated by fetch-openapi. If it currently exists it will be overwritten.' + ) + .option( + '--preset [preset]', + 'May be one of the following values: es6, node (default)' + ) .option('--verbose', 'Outputs more information than is normally needed.') .parse(process.argv); @@ -45,26 +59,32 @@ var options = { }; var sdk; - if (apiDocFilePath) { var apiDoc; try { apiDoc = require(apiDocFilePath); } catch (e) { debug(e); - error('Could not import api doc at path "' + apiDocFilePath + '". Does it exist?'); + error( + 'Could not import api doc at path "' + + apiDocFilePath + + '". Does it exist?' + ); return; } generateSdk(apiDoc); } else { - request({url: apiDocUrl, json: true}, errHandler(error, function (err, res, body) { - if (res.statusCode !== 200) { - debug('statusCode is ' + res.statusCode); - error('Bad satus code for "' + apiDocUrl + '". Does it exist?'); - } - generateSdk(body); - })); + request( + { url: apiDocUrl, json: true }, + errHandler(error, function(err, res, body) { + if (res.statusCode !== 200) { + debug('statusCode is ' + res.statusCode); + error('Bad satus code for "' + apiDocUrl + '". Does it exist?'); + } + generateSdk(body); + }) + ); } function generateSdk(apiDoc) { @@ -73,13 +93,19 @@ function generateSdk(apiDoc) { sdk = fetchOpenApi(apiDoc, options); debug('sdk is\n' + sdk); } catch (e) { - error('Received the following error when generating the client: ' + e.message); + error( + 'Received the following error when generating the client: ' + e.message + ); } - fs.writeFile(outputFilePath, sdk, errHandler(error, function() { - msg('SDK written to ' + outputFilePath); - exit(0); - })); + fs.writeFile( + outputFilePath, + sdk, + errHandler(error, function() { + msg('SDK written to ' + outputFilePath); + exit(0); + }) + ); } function error(msg) { diff --git a/packages/fetch-openapi/test/index.spec.js b/packages/fetch-openapi/test/index.spec.js index 46e35daf..4c3e3991 100644 --- a/packages/fetch-openapi/test/index.spec.js +++ b/packages/fetch-openapi/test/index.spec.js @@ -5,7 +5,7 @@ var path = require('path'); var sut = require('../index'); describe('fetch-openapi', function() { - glob.sync('./fixtures/*', {cwd: __dirname}).forEach(function(dirPath) { + glob.sync('./fixtures/*', { cwd: __dirname }).forEach(function(dirPath) { var specName = path.basename(dirPath).replace(/-/g, ' '); var inputPath = path.resolve(__dirname, dirPath, './input.json'); var optionsPath = path.resolve(__dirname, dirPath, './options.js'); @@ -24,7 +24,8 @@ describe('fetch-openapi', function() { } else { it('should output an api service factory', function() { expect(sut(require(inputPath), options)).to.equal( - fs.readFileSync(outputPath, 'utf8')); + fs.readFileSync(outputPath, 'utf8') + ); }); if (process.version.indexOf('v0.') !== 0 && options.preset === 'node') { @@ -47,7 +48,7 @@ describe('fetch-openapi', function() { describe('when an unknown preset is used', function() { it('should throw an error', function() { expect(function() { - sut({}, {preset: 'asdf'}); + sut({}, { preset: 'asdf' }); }).to.throw(/preset/); }); }); diff --git a/packages/fs-routes/test/test.ts b/packages/fs-routes/test/test.ts index 7e8b034b..519c0b42 100644 --- a/packages/fs-routes/test/test.ts +++ b/packages/fs-routes/test/test.ts @@ -4,7 +4,7 @@ const path = require('path'); const testDir = path.resolve(__dirname, '..', 'test-dir'); function assertRoutes(routes) { - var output = [ + const output = [ { path: testDir + '/home.js', route: '/home' @@ -39,27 +39,33 @@ describe('fs-routes', () => { describe('when run against a directory twice', () => { it('should workd', () => { - assertRoutes(fsRoutes('test-dir'));// caching - assertRoutes(fsRoutes('test-dir'));// caching + assertRoutes(fsRoutes('test-dir')); // caching + assertRoutes(fsRoutes('test-dir')); // caching }); }); describe('when run with a file match pattern', () => { it('should work', () => { - assert.deepEqual(fsRoutes('test-dir', {glob: '**/*.ts', indexFileRegExp: /(?:query)?\.ts$/}), [ - { - path: testDir + '/hom.a.ts', - route: '/hom.a' - }, - { - path: testDir + '/home.ts', - route: '/home' - }, - { - path: testDir + '/users/query.ts', - route: '/users/' - } - ]); + assert.deepEqual( + fsRoutes('test-dir', { + glob: '**/*.ts', + indexFileRegExp: /(?:query)?\.ts$/ + }), + [ + { + path: testDir + '/hom.a.ts', + route: '/hom.a' + }, + { + path: testDir + '/home.ts', + route: '/home' + }, + { + path: testDir + '/users/query.ts', + route: '/users/' + } + ] + ); }); }); }); diff --git a/packages/koa-openapi/test/sample-projects/basic-usage/api-doc.js b/packages/koa-openapi/test/sample-projects/basic-usage/api-doc.js index d4713768..dd705095 100644 --- a/packages/koa-openapi/test/sample-projects/basic-usage/api-doc.js +++ b/packages/koa-openapi/test/sample-projects/basic-usage/api-doc.js @@ -3,7 +3,7 @@ module.exports = { swagger: '2.0', - host: "test-host", + host: 'test-host', // all routes will now have /v3 prefixed. basePath: '/v3', @@ -40,6 +40,6 @@ module.exports = { tags: [ // {name: 'creating'} will be inserted by ./api-routes/users.js // {name: 'fooey'} will be inserted by ./api-routes/users/{id}.js - {description: 'Everything users', name: 'users'} + { description: 'Everything users', name: 'users' } ] }; diff --git a/packages/koa-openapi/test/sample-projects/basic-usage/api-routes/apiDocs.js b/packages/koa-openapi/test/sample-projects/basic-usage/api-routes/apiDocs.js index 84fc387c..6a60dead 100644 --- a/packages/koa-openapi/test/sample-projects/basic-usage/api-routes/apiDocs.js +++ b/packages/koa-openapi/test/sample-projects/basic-usage/api-routes/apiDocs.js @@ -4,9 +4,9 @@ module.exports = { function get(ctx) { if (ctx.query.type === 'apiDoc') { - return ctx.body = ctx.state.apiDoc; + return (ctx.body = ctx.state.apiDoc); } - return ctx.body = ctx.state.operationDoc; + return (ctx.body = ctx.state.operationDoc); } get.apiDoc = { @@ -18,10 +18,7 @@ get.apiDoc = { in: 'query', name: 'type', type: 'string', - enum: [ - 'apiDoc', - 'operationDoc' - ] + enum: ['apiDoc', 'operationDoc'] } ], responses: { @@ -32,7 +29,7 @@ get.apiDoc = { } }, default: { - description: 'The requested apiDoc.', + description: 'The requested apiDoc.' } } }; diff --git a/packages/koa-openapi/test/sample-projects/basic-usage/api-routes/users.js b/packages/koa-openapi/test/sample-projects/basic-usage/api-routes/users.js index d86fa6fe..e2a452b0 100644 --- a/packages/koa-openapi/test/sample-projects/basic-usage/api-routes/users.js +++ b/packages/koa-openapi/test/sample-projects/basic-usage/api-routes/users.js @@ -10,10 +10,12 @@ module.exports = { ctx.status = 204; }, - get: [function(ctx, next) { - ctx.status = 200; - ctx.body = [{name: 'fred'}]; - }], + get: [ + function(ctx, next) { + ctx.status = 200; + ctx.body = [{ name: 'fred' }]; + } + ], post: function(ctx, next) { ctx.throw(); @@ -43,7 +45,7 @@ module.exports.post.apiDoc = { parameters: [], responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/koa-openapi/test/sample-projects/basic-usage/api-routes/users/{id}.js b/packages/koa-openapi/test/sample-projects/basic-usage/api-routes/users/{id}.js index 590f26a8..a3bd73f1 100644 --- a/packages/koa-openapi/test/sample-projects/basic-usage/api-routes/users/{id}.js +++ b/packages/koa-openapi/test/sample-projects/basic-usage/api-routes/users/{id}.js @@ -6,7 +6,7 @@ module.exports = { in: 'path', type: 'string', required: true, - description: 'Fred\'s age.' + description: "Fred's age." } ], // method handlers may just be the method handler... @@ -15,12 +15,17 @@ module.exports = { // for flexible middleware management. express-openapi middleware generated from // the .parameters + .apiDoc.parameters is prepended to this // array. - post: [function(ctx, next) {}, post] + post: [ + function(ctx, next) { + return; + }, + post + ] }; function post(ctx) { ctx.status = 200; - ctx.body = {id: ctx.params.id}; + ctx.body = { id: ctx.params.id }; } // verify that apiDoc is available with middleware @@ -37,9 +42,9 @@ post.apiDoc = { } } ], -responses: { + responses: { default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } @@ -74,27 +79,27 @@ get.apiDoc = { in: 'path', type: 'integer', required: true, - description: 'Fred\'s age.' + description: "Fred's age." }, { name: 'age', in: 'query', type: 'integer', - description: 'Fred\'s age.', + description: "Fred's age.", default: 80 } ], responses: { 200: { - description: "Requested user", + description: 'Requested user', schema: { $ref: '#/definitions/User' } }, default: { - description: "Unexpected error", + description: 'Unexpected error', schema: { $ref: '#/definitions/Error' } diff --git a/packages/koa-openapi/test/sample-projects/basic-usage/app.js b/packages/koa-openapi/test/sample-projects/basic-usage/app.js index d1bf32a1..36a23591 100644 --- a/packages/koa-openapi/test/sample-projects/basic-usage/app.js +++ b/packages/koa-openapi/test/sample-projects/basic-usage/app.js @@ -9,12 +9,12 @@ var openapi = require('../../../'); app.use(async (ctx, next) => { try { await next(); - } catch(e) { + } catch (e) { ctx.status = e.status; if (e.errors) { ctx.body = { status: e.status || 500, - errors: e.errors, + errors: e.errors }; } } diff --git a/packages/openapi-default-setter/test/data-driven.ts b/packages/openapi-default-setter/test/data-driven.ts index 715a0229..2389f269 100644 --- a/packages/openapi-default-setter/test/data-driven.ts +++ b/packages/openapi-default-setter/test/data-driven.ts @@ -5,13 +5,14 @@ const baseDir = path.resolve(__dirname, 'data-driven'); import Sut from '../'; describe(require('../package.json').name, () => { - glob.sync('*.js', {cwd: baseDir}).forEach((fixture) => { + glob.sync('*.js', { cwd: baseDir }).forEach(fixture => { const testName = path.basename(fixture, '.js').replace(/-/g, ' '); fixture = require(path.resolve(baseDir, fixture)); it('should ' + testName, () => { if (fixture.constructorError) { expect(() => { + /* tslint:disable-next-line:no-unused-expression */ new Sut(fixture.args); }).to.throw(fixture.constructorError); return; diff --git a/packages/openapi-framework/src/types.ts b/packages/openapi-framework/src/types.ts index fbb8ffa1..a3e64d1a 100644 --- a/packages/openapi-framework/src/types.ts +++ b/packages/openapi-framework/src/types.ts @@ -1,9 +1,12 @@ -import { OpenAPI, OpenAPIV2, OpenAPIV3, IJsonSchema } from 'openapi-types'; import { IOpenAPIDefaultSetter } from 'openapi-default-setter'; import { IOpenAPIRequestCoercer } from 'openapi-request-coercer'; import { IOpenAPIRequestValidator } from 'openapi-request-validator'; import { IOpenAPIResponseValidator } from 'openapi-response-validator'; -import { IOpenAPISecurityHandler, SecurityHandlers } from 'openapi-security-handler'; +import { + IOpenAPISecurityHandler, + SecurityHandlers +} from 'openapi-security-handler'; +import { IJsonSchema, OpenAPI, OpenAPIV2, OpenAPIV3 } from 'openapi-types'; export { OpenAPIFrameworkArgs, @@ -12,19 +15,20 @@ export { }; // TODO move this to openapi-request-validator -type OpenAPIErrorTransformer = ({}, {}) => Object +type OpenAPIErrorTransformer = ({}, {}) => object; -type PathSecurityTuple = [RegExp, SecurityRequirement[]] +type PathSecurityTuple = [RegExp, SecurityRequirement[]]; interface SecurityRequirement { - [name: string]: SecurityScope[] + [name: string]: SecurityScope[]; } -type SecurityScope = string +type SecurityScope = string; -interface SecurityHandlerCallback { - (error: SecurityHandlerError, result: boolean): void; -} +type SecurityHandlerCallback = ( + error: SecurityHandlerError, + result: boolean +) => void; interface SecurityHandlerError { status?: number; @@ -33,68 +37,68 @@ interface SecurityHandlerError { } export interface OpenAPIFrameworkPathObject { - path?: string - module?: any + path?: string; + module?: any; } export interface IOpenAPIFramework { - featureType: string - loggingPrefix: string - name: string + featureType: string; + loggingPrefix: string; + name: string; } interface OpenAPIFrameworkConstructorArgs extends OpenAPIFrameworkArgs { - featureType: string - name: string + featureType: string; + name: string; } interface OpenAPIFrameworkArgs { - apiDoc: OpenAPIV2.Document | OpenAPIV3.Document | string - customFormats?: {string: (any) => boolean} - dependencies?: {[service:string]: any} - enableObjectCoercion?: boolean - errorTransformer?: OpenAPIErrorTransformer - externalSchemas?: {string: IJsonSchema} - pathSecurity?: PathSecurityTuple[] - paths: string | Array - pathsIgnore?: RegExp + apiDoc: OpenAPIV2.Document | OpenAPIV3.Document | string; + customFormats?: { string: (arg: any) => boolean }; + dependencies?: { [service: string]: any }; + enableObjectCoercion?: boolean; + errorTransformer?: OpenAPIErrorTransformer; + externalSchemas?: { string: IJsonSchema }; + pathSecurity?: PathSecurityTuple[]; + paths: string | OpenAPIFrameworkPathObject[]; + pathsIgnore?: RegExp; routesGlob?: string; routesIndexFileRegExp?: RegExp; - securityHandlers?: SecurityHandlers;// TODO define the handlers more here - validateApiDoc?: boolean + securityHandlers?: SecurityHandlers; // TODO define the handlers more here + validateApiDoc?: boolean; } export interface OpenAPIFrameworkAPIContext { - basePath: string + basePath: string; // TODO fill this out - getApiDoc(): any + getApiDoc(): any; } export interface OpenAPIFrameworkPathContext { - basePath: string + basePath: string; // TODO fill this out - getApiDoc(): any - getPathDoc(): any + getApiDoc(): any; + getPathDoc(): any; } export interface OpenAPIFrameworkOperationContext { - additionalFeatures: Array - allowsFeatures: boolean - apiDoc: any - basePath: string - consumes: Array + additionalFeatures: any[]; + allowsFeatures: boolean; + apiDoc: any; + basePath: string; + consumes: string[]; features: { - coercer?: IOpenAPIRequestCoercer - defaultSetter?: IOpenAPIDefaultSetter - requestValidator?: IOpenAPIRequestValidator - responseValidator?: IOpenAPIResponseValidator - securityHandler?: IOpenAPISecurityHandler - } - methodName: string - methodParameters: Array - operationDoc: any - operationHandler: any - path: string + coercer?: IOpenAPIRequestCoercer; + defaultSetter?: IOpenAPIDefaultSetter; + requestValidator?: IOpenAPIRequestValidator; + responseValidator?: IOpenAPIResponseValidator; + securityHandler?: IOpenAPISecurityHandler; + }; + methodName: string; + methodParameters: any[]; + operationDoc: any; + operationHandler: any; + path: string; } export interface OpenAPIFrameworkVisitor { diff --git a/packages/openapi-framework/src/util.ts b/packages/openapi-framework/src/util.ts index adffc9dc..17e6ef52 100644 --- a/packages/openapi-framework/src/util.ts +++ b/packages/openapi-framework/src/util.ts @@ -29,9 +29,9 @@ export const METHOD_ALIASES = { }; export function addOperationTagToApiDoc(apiDoc, tag) { - const apiDocTags = (apiDoc.tags || []); - const availableTags = apiDocTags.map(tag => { - return tag && tag.name; + const apiDocTags = apiDoc.tags || []; + const availableTags = apiDocTags.map(t => { + return t && t.name; }); if (availableTags.indexOf(tag) === -1) { @@ -44,38 +44,69 @@ export function addOperationTagToApiDoc(apiDoc, tag) { } function allows(docs, prop, val) { - return ![].slice.call(docs).filter(byProperty(prop, val)) - .length; + return ![].slice.call(docs).filter(byProperty(prop, val)).length; } export function allowsCoercionFeature(framework: IOpenAPIFramework, ...docs) { - return allows(arguments, `x-${framework.name}-disable-coercion-${framework.featureType}`, true); + return allows( + arguments, + `x-${framework.name}-disable-coercion-${framework.featureType}`, + true + ); } export function allowsDefaultsFeature(framework: IOpenAPIFramework, ...docs) { - return allows(arguments, `x-${framework.name}-disable-defaults-${framework.featureType}`, true); + return allows( + arguments, + `x-${framework.name}-disable-defaults-${framework.featureType}`, + true + ); } export function allowsFeatures(framework: IOpenAPIFramework, ...docs) { - return allows(docs, `x-${framework.name}-disable-${framework.featureType}`, true); + return allows( + docs, + `x-${framework.name}-disable-${framework.featureType}`, + true + ); } -export function allowsResponseValidationFeature(framework: IOpenAPIFramework, ...docs) { - return allows(arguments, `x-${framework.name}-disable-response-validation-${framework.featureType}`, - true); +export function allowsResponseValidationFeature( + framework: IOpenAPIFramework, + ...docs +) { + return allows( + arguments, + `x-${framework.name}-disable-response-validation-${framework.featureType}`, + true + ); } export function allowsValidationFeature(framework: IOpenAPIFramework, ...docs) { - return allows(docs, `x-${framework.name}-disable-validation-${framework.featureType}`, true); + return allows( + docs, + `x-${framework.name}-disable-validation-${framework.featureType}`, + true + ); } export function assertRegExpAndSecurity(framework, tuple) { if (!Array.isArray(tuple)) { - throw new Error(`${framework.name}args.pathSecurity expects an array of tuples.`); + throw new Error( + `${framework.name}args.pathSecurity expects an array of tuples.` + ); } else if (!(tuple[0] instanceof RegExp)) { - throw new Error(`${framework.name}args.pathSecurity tuples expect the first argument to be a RegExp.`); + throw new Error( + `${ + framework.name + }args.pathSecurity tuples expect the first argument to be a RegExp.` + ); } else if (!Array.isArray(tuple[1])) { - throw new Error(`${framework.name}args.pathSecurity tuples expect the second argument to be a security Array.`); + throw new Error( + `${ + framework.name + }args.pathSecurity tuples expect the second argument to be a security Array.` + ); } } @@ -99,8 +130,12 @@ function byProperty(property, value) { } export function byRoute(a, b) { - if(isDynamicRoute(a.path) && !isDynamicRoute(b.path)) return 1; - if(!isDynamicRoute(a.path) && isDynamicRoute(b.path)) return -1; + if (isDynamicRoute(a.path) && !isDynamicRoute(b.path)) { + return 1; + } + if (!isDynamicRoute(a.path) && isDynamicRoute(b.path)) { + return -1; + } // invert compare to keep that /{foo} does not beat /{foo}.{bar} return -1 * a.path.localeCompare(b.path); @@ -117,8 +152,12 @@ export function copy(obj) { export function getAdditionalFeatures(framework: IOpenAPIFramework, ...docs) { const additionalFeatures = []; let index = docs.length - 1; - const inheritProperty = `x-${framework.name}-inherit-additional-${framework.featureType}`; - const additionalProperty = `x-${framework.name}-additional-${framework.featureType}`; + const inheritProperty = `x-${framework.name}-inherit-additional-${ + framework.featureType + }`; + const additionalProperty = `x-${framework.name}-additional-${ + framework.featureType + }`; while (index > 0) { --index; @@ -137,7 +176,9 @@ export function getAdditionalFeatures(framework: IOpenAPIFramework, ...docs) { return true; } else { console.warn( - `${framework.loggingPrefix}Ignoring ${feature} as ${framework.featureType} in ${additionalProperty} array.` + `${framework.loggingPrefix}Ignoring ${feature} as ${ + framework.featureType + } in ${additionalProperty} array.` ); return false; } @@ -151,7 +192,7 @@ export function getAdditionalFeatures(framework: IOpenAPIFramework, ...docs) { } export function getSecurityDefinitionByPath(openapiPath, pathSecurity) { - for (let i = pathSecurity.length; i--;) { + for (let i = pathSecurity.length; i--; ) { const tuple = pathSecurity[i]; if (tuple[0].test(openapiPath)) { return tuple[1]; @@ -160,9 +201,11 @@ export function getSecurityDefinitionByPath(openapiPath, pathSecurity) { } export function getMethodDoc(operationHandler) { - const doc = operationHandler.apiDoc || (Array.isArray(operationHandler) ? - operationHandler.slice(-1)[0].apiDoc : - null); + const doc = + operationHandler.apiDoc || + (Array.isArray(operationHandler) + ? operationHandler.slice(-1)[0].apiDoc + : null); if (doc) { return copy(doc); @@ -175,7 +218,8 @@ export function handleFilePath(filePath) { if (typeof filePath === 'string') { const absolutePath = path.resolve(process.cwd(), filePath); if (fs.existsSync(absolutePath)) { - try { // json or module + try { + // json or module return require(absolutePath); } catch (e) { return fs.readFileSync(absolutePath, 'utf8'); @@ -186,9 +230,9 @@ export function handleFilePath(filePath) { } export function handleYaml(apiDoc) { - return typeof apiDoc === 'string' ? - jsYaml.safeLoad(apiDoc, {json: true}) : - apiDoc; + return typeof apiDoc === 'string' + ? jsYaml.safeLoad(apiDoc, { json: true }) + : apiDoc; } export function injectDependencies(handlers, dependencies) { @@ -199,10 +243,14 @@ export function injectDependencies(handlers, dependencies) { } export function isDynamicRoute(route) { - return route.indexOf("{")>0; + return route.indexOf('{') > 0; } -export function resolveParameterRefs(framework: IOpenAPIFramework, parameters, definitions) { +export function resolveParameterRefs( + framework: IOpenAPIFramework, + parameters, + definitions +) { return parameters.map(parameter => { if (typeof parameter.$ref === 'string') { const match = PARAMETER_REF_REGEX.exec(parameter.$ref); @@ -210,7 +258,11 @@ export function resolveParameterRefs(framework: IOpenAPIFramework, parameters, d if (!definition) { throw new Error( - `${framework.name}: Invalid parameter $ref or definition not found in apiDoc.parameters: ${parameter.$ref}` + `${ + framework.name + }: Invalid parameter $ref or definition not found in apiDoc.parameters: ${ + parameter.$ref + }` ); } @@ -221,7 +273,12 @@ export function resolveParameterRefs(framework: IOpenAPIFramework, parameters, d }); } -export function resolveResponseRefs(framework: IOpenAPIFramework, responses, apiDoc, route) { +export function resolveResponseRefs( + framework: IOpenAPIFramework, + responses, + apiDoc, + route +) { return Object.keys(responses).reduce((resolvedResponses, responseCode) => { const response = responses[responseCode]; @@ -231,7 +288,11 @@ export function resolveResponseRefs(framework: IOpenAPIFramework, responses, api if (!definition) { throw new Error( - `${framework.name}: Invalid response $ref or definition not found in apiDoc.responses: ${response.$ref}` + `${ + framework.name + }: Invalid response $ref or definition not found in apiDoc.responses: ${ + response.$ref + }` ); } diff --git a/packages/openapi-framework/test/constructor.ts b/packages/openapi-framework/test/constructor.ts index fd9c3aee..ef25cb82 100644 --- a/packages/openapi-framework/test/constructor.ts +++ b/packages/openapi-framework/test/constructor.ts @@ -1,5 +1,6 @@ -import 'mocha'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import 'mocha'; import OpenapiFramework from '../'; const fs = require('fs'); const path = require('path'); @@ -12,9 +13,12 @@ describe('OpenapiFramework', () => { describe('instantiating', () => { let options; - beforeEach(function() { + beforeEach(() => { options = { - apiDoc: fs.readFileSync(path.resolve(__dirname, './fixtures/apiDoc-valid.yml'), 'utf8'), + apiDoc: fs.readFileSync( + path.resolve(__dirname, './fixtures/apiDoc-valid.yml'), + 'utf8' + ), featureType: 'middleware', name: 'express-openapi', paths: './test/fixtures/paths' @@ -35,14 +39,9 @@ describe('OpenapiFramework', () => { }); }); - [ - 'apiDoc', - 'featureType', - 'name', - 'paths' - ].forEach(spec => { + ['apiDoc', 'featureType', 'name', 'paths'].forEach(spec => { describe(`when options.${spec} is missing`, () => { - beforeEach(function() { + beforeEach(() => { delete options[spec]; }); @@ -60,7 +59,7 @@ describe('OpenapiFramework', () => { ['securityHandlers', 'object'] ].forEach(spec => { describe(`when options.${spec[0]} is of the wrong type`, () => { - beforeEach(function() { + beforeEach(() => { options[spec[0]] = void 0; }); @@ -73,7 +72,7 @@ describe('OpenapiFramework', () => { }); describe('when apiDoc is an object representing a valid apiDoc', () => { - beforeEach(function() { + beforeEach(() => { options.apiDoc = require('./fixtures/apiDoc-valid.js'); }); @@ -82,13 +81,9 @@ describe('OpenapiFramework', () => { }); }); - [ - 'yml', - 'js', - 'json' - ].forEach(file => { + ['yml', 'js', 'json'].forEach(file => { describe(`when apiDoc is a path to a valid ${file} file`, () => { - beforeEach(function() { + beforeEach(() => { options.apiDoc = `./test/fixtures/apiDoc-valid.${file}`; }); @@ -152,7 +147,7 @@ describe('OpenapiFramework', () => { describe('apiDoc validation', () => { describe('when enabled', () => { describe('when apiDoc is invalid', () => { - beforeEach(function() { + beforeEach(() => { options.apiDoc = 'asdfasdf'; }); @@ -171,12 +166,12 @@ describe('OpenapiFramework', () => { }); describe('when disabled', () => { - beforeEach(function() { + beforeEach(() => { options.validateApiDoc = false; }); describe('when apiDoc is invalid', () => { - beforeEach(function() { + beforeEach(() => { options.apiDoc = 'asdfasdf'; }); diff --git a/packages/openapi-framework/test/sample-projects/empty-paths-array/spec.ts b/packages/openapi-framework/test/sample-projects/empty-paths-array/spec.ts index 69ed1223..b7995472 100644 --- a/packages/openapi-framework/test/sample-projects/empty-paths-array/spec.ts +++ b/packages/openapi-framework/test/sample-projects/empty-paths-array/spec.ts @@ -4,12 +4,12 @@ const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: [], + paths: [] }); }); diff --git a/packages/openapi-framework/test/sample-projects/empty-paths-dir/spec.ts b/packages/openapi-framework/test/sample-projects/empty-paths-dir/spec.ts index b79278c3..15f65398 100644 --- a/packages/openapi-framework/test/sample-projects/empty-paths-dir/spec.ts +++ b/packages/openapi-framework/test/sample-projects/empty-paths-dir/spec.ts @@ -4,12 +4,12 @@ const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); diff --git a/packages/openapi-framework/test/sample-projects/missing-module-in-paths-item/spec.ts b/packages/openapi-framework/test/sample-projects/missing-module-in-paths-item/spec.ts index f3cf6a35..9adaa252 100644 --- a/packages/openapi-framework/test/sample-projects/missing-module-in-paths-item/spec.ts +++ b/packages/openapi-framework/test/sample-projects/missing-module-in-paths-item/spec.ts @@ -1,22 +1,24 @@ -import OpenapiFramework from '../../../'; import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: [{ path: 'asdf' }], + paths: [{ path: 'asdf' }] }); }); it('should throw an error', () => { expect(() => { framework.initialize({}); - }).to.throw('some-framework: args.paths must consist of strings or valid route specifications'); + }).to.throw( + 'some-framework: args.paths must consist of strings or valid route specifications' + ); }); }); diff --git a/packages/openapi-framework/test/sample-projects/missing-path-in-paths-item/spec.ts b/packages/openapi-framework/test/sample-projects/missing-path-in-paths-item/spec.ts index fe703650..a4941f8b 100644 --- a/packages/openapi-framework/test/sample-projects/missing-path-in-paths-item/spec.ts +++ b/packages/openapi-framework/test/sample-projects/missing-path-in-paths-item/spec.ts @@ -1,22 +1,24 @@ -import OpenapiFramework from '../../../'; import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: [{ module: true }], + paths: [{ module: true }] }); }); it('should throw an error', () => { expect(() => { framework.initialize({}); - }).to.throw('some-framework: args.paths must consist of strings or valid route specifications'); + }).to.throw( + 'some-framework: args.paths must consist of strings or valid route specifications' + ); }); }); diff --git a/packages/openapi-framework/test/sample-projects/missing-paths-dir/spec.ts b/packages/openapi-framework/test/sample-projects/missing-paths-dir/spec.ts index ac890462..2867ed59 100644 --- a/packages/openapi-framework/test/sample-projects/missing-paths-dir/spec.ts +++ b/packages/openapi-framework/test/sample-projects/missing-paths-dir/spec.ts @@ -1,22 +1,24 @@ -import OpenapiFramework from '../../../'; import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'frankenstein-api'), + paths: path.resolve(__dirname, 'frankenstein-api') }); }); it('should throw', () => { expect(() => { framework.initialize({}); - }).to.throw('some-framework: args.paths contained a value that was not a path to a directory'); + }).to.throw( + 'some-framework: args.paths contained a value that was not a path to a directory' + ); }); }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc-no-validation/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc-no-validation/paths/foo.js index a3e3476c..77ed8e3e 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc-no-validation/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc-no-validation/paths/foo.js @@ -1,8 +1,8 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = {}; diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc-no-validation/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc-no-validation/spec.ts index 3b407c8a..b67c9124 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc-no-validation/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc-no-validation/spec.ts @@ -1,17 +1,17 @@ -import OpenapiFramework from '../../../'; import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', paths: path.resolve(__dirname, 'paths'), - validateApiDoc: false, + validateApiDoc: false }); }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc/paths/foo.js index a3e3476c..77ed8e3e 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc/paths/foo.js @@ -1,8 +1,8 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = {}; diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc/spec.ts index ee291c7f..3b404336 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-invalid-method-doc/spec.ts @@ -1,16 +1,16 @@ -import OpenapiFramework from '../../../'; import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -22,6 +22,8 @@ describe(path.basename(__dirname), () => { expect(apiDoc.paths).to.have.property('/foo'); } }); - }).to.throw('some-framework: args.apiDoc was invalid after populating paths. See the output.'); + }).to.throw( + 'some-framework: args.apiDoc was invalid after populating paths. See the output.' + ); }); }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-no-method-doc/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-no-method-doc/paths/foo.js index 6932621e..7d62ff68 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-no-method-doc/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-no-method-doc/paths/foo.js @@ -1,7 +1,7 @@ module.exports = { - GET, + GET }; function GET() { - + return; } diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-no-method-doc/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-no-method-doc/spec.ts index f1eb85f4..cefcf229 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-no-method-doc/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-no-method-doc/spec.ts @@ -1,16 +1,16 @@ -import OpenapiFramework from '../../../'; import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -18,7 +18,7 @@ describe(path.basename(__dirname), () => { framework.initialize({ visitApi(ctx) { const apiDoc = ctx.getApiDoc(); - expect(apiDoc.paths['/foo']).to.eql({ parameters: [] }) + expect(apiDoc.paths['/foo']).to.eql({ parameters: [] }); } }); }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-path-parameters/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-path-parameters/paths/foo.js index 676544be..dd5807e3 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-path-parameters/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-path-parameters/paths/foo.js @@ -1,7 +1,9 @@ module.exports = { - parameters: [{ - name: 'color', - in: 'query', - type: 'string', - }] + parameters: [ + { + name: 'color', + in: 'query', + type: 'string' + } + ] }; diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-path-parameters/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-path-parameters/spec.ts index 588334b2..7acab0ac 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-path-parameters/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-path-parameters/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -18,11 +19,13 @@ describe(path.basename(__dirname), () => { framework.initialize({ visitApi(ctx) { const apiDoc = ctx.getApiDoc(); - expect(apiDoc.paths['/foo'].parameters).to.eql([{ - name: 'color', - in: 'query', - type: 'string', - }]); + expect(apiDoc.paths['/foo'].parameters).to.eql([ + { + name: 'color', + in: 'query', + type: 'string' + } + ]); } }); }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-pathsIgnore/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-pathsIgnore/spec.ts index 4b6b2b61..1331089a 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-pathsIgnore/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-pathsIgnore/spec.ts @@ -1,17 +1,18 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', paths: path.resolve(__dirname, 'paths'), - pathsIgnore: /^\/foo/, + pathsIgnore: /^\/foo/ }); }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-operationDoc-security/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-operationDoc-security/paths/foo.js index bd519949..0f6ce3f3 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-operationDoc-security/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-operationDoc-security/paths/foo.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { responses: { @@ -12,7 +12,5 @@ GET.apiDoc = { schema: {} } }, - security: [ - {basic: []} - ] + security: [{ basic: [] }] }; diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-operationDoc-security/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-operationDoc-security/spec.ts index 645012d8..65259dad 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-operationDoc-security/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-operationDoc-security/spec.ts @@ -1,18 +1,21 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', paths: path.resolve(__dirname, 'paths'), securityHandlers: { - basic: function() {return true;} + basic() { + return true; + } } }); }); @@ -39,10 +42,10 @@ describe(path.basename(__dirname), () => { }, security: [ { - basic: [], + basic: [] } - ], - }, + ] + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-pathSecurity/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-pathSecurity/paths/foo.js index 9e6b28cd..ee27c4fe 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-pathSecurity/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-pathSecurity/paths/foo.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-pathSecurity/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-pathSecurity/spec.ts index 6e28b039..e3ecd92c 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-pathSecurity/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions-and-pathSecurity/spec.ts @@ -1,22 +1,22 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', paths: path.resolve(__dirname, 'paths'), - pathSecurity: [ - [/.+/, [{ basic: [] }]], - [/^awes/, [{ basic: [] }]] - ], + pathSecurity: [[/.+/, [{ basic: [] }]], [/^awes/, [{ basic: [] }]]], securityHandlers: { - basic: function() {return true;} + basic() { + return true; + } } }); }); @@ -43,10 +43,10 @@ describe(path.basename(__dirname), () => { }, security: [ { - basic: [], + basic: [] } - ], - }, + ] + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions/paths/foo.js index 9e6b28cd..ee27c4fe 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions/paths/foo.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions/spec.ts index a9c84dbf..72eff152 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers-and-securityDefinitions/spec.ts @@ -1,18 +1,21 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', paths: path.resolve(__dirname, 'paths'), securityHandlers: { - basic: function() {return true;} + basic() { + return true; + } } }); }); @@ -36,8 +39,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers/paths/foo.js index 9e6b28cd..ee27c4fe 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers/paths/foo.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers/spec.ts index 5002318c..6ed8a7d9 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-security-and-securityHandlers/spec.ts @@ -1,18 +1,21 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', paths: path.resolve(__dirname, 'paths'), securityHandlers: { - basic: function() {return true;} + basic() { + return true; + } } }); }); @@ -36,8 +39,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-security/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-security/paths/foo.js index 9e6b28cd..ee27c4fe 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-security/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-security/paths/foo.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-security/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-security/spec.ts index 1c2e7754..a9ab1d65 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-security/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-security/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -33,8 +34,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-and-apiDoc-consumes/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-and-apiDoc-consumes/paths/foo.js index ba27c3db..9d7028f2 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-and-apiDoc-consumes/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-and-apiDoc-consumes/paths/foo.js @@ -1,9 +1,9 @@ module.exports = { - PUT, + PUT }; function PUT() { - + return; } PUT.apiDoc = { @@ -13,5 +13,5 @@ PUT.apiDoc = { schema: {} } }, - tags: [ 'testing', 'example' ], + tags: ['testing', 'example'] }; diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-and-apiDoc-consumes/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-and-apiDoc-consumes/spec.ts index 7694b658..ae4cd792 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-and-apiDoc-consumes/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-and-apiDoc-consumes/spec.ts @@ -1,23 +1,23 @@ -import OpenapiFramework from '../../../'; import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); it('should use apiDoc.consumes by default and add consumes to operation context', () => { framework.initialize({ visitOperation(ctx) { - expect(ctx.consumes).to.eql([ 'application/xml' ]); + expect(ctx.consumes).to.eql(['application/xml']); expect(ctx.operationDoc).to.eql({ responses: { default: { @@ -25,14 +25,12 @@ describe(path.basename(__dirname), () => { schema: {} } }, - tags: [ 'example', 'testing' ], + tags: ['example', 'testing'] }); }, visitApi(ctx) { const apiDoc = ctx.getApiDoc(); - expect(apiDoc.consumes).to.eql([ - 'application/xml' - ]); + expect(apiDoc.consumes).to.eql(['application/xml']); } }); }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes-requestbody/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes-requestbody/paths/foo.js index 06b2ed5d..72df4d20 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes-requestbody/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes-requestbody/paths/foo.js @@ -1,27 +1,27 @@ module.exports = { - PUT, + PUT }; function PUT() { - + return; } PUT.apiDoc = { requestBody: { - content: { + content: { 'application/json': { - schema: {}, - }, - }, + schema: {} + } + } }, responses: { '200': { description: 'return foo', content: { 'application/json': { - schema: {}, - }, - }, - }, + schema: {} + } + } + } }, - tags: [ 'testing', 'example' ], + tags: ['testing', 'example'] }; diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes-requestbody/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes-requestbody/spec.ts index 04cd3b13..865f38b4 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes-requestbody/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes-requestbody/spec.ts @@ -1,50 +1,48 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); it('should add consumes to operation context from requestBody', () => { framework.initialize({ visitOperation(ctx) { - expect(ctx.consumes).to.eql([ 'application/json' ]); + expect(ctx.consumes).to.eql(['application/json']); expect(ctx.operationDoc).to.eql({ requestBody: { - content: { + content: { 'application/json': { - schema: {}, - }, - }, + schema: {} + } + } }, responses: { '200': { description: 'return foo', content: { 'application/json': { - schema: {}, - }, - }, - }, + schema: {} + } + } + } }, - tags: [ 'example', 'testing' ], + tags: ['example', 'testing'] }); }, visitApi(ctx) { const apiDoc = ctx.getApiDoc(); - expect(apiDoc.tags).to.eql([ - { name: 'example' }, - { name: 'testing' } - ]); + expect(apiDoc.tags).to.eql([{ name: 'example' }, { name: 'testing' }]); } }); }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes/paths/foo.js index 35ef9983..c1222963 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes/paths/foo.js @@ -1,17 +1,17 @@ module.exports = { - PUT, + PUT }; function PUT() { - + return; } PUT.apiDoc = { - consumes: [ 'application/json' ], + consumes: ['application/json'], responses: { default: { description: 'return foo', schema: {} } }, - tags: [ 'testing', 'example' ], + tags: ['testing', 'example'] }; diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes/spec.ts index 8e97816c..8206411d 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-consumes/spec.ts @@ -1,40 +1,37 @@ -import OpenapiFramework from '../../../'; import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); it('should override apiDoc.consumes and add consumes to operation context', () => { framework.initialize({ visitOperation(ctx) { - expect(ctx.consumes).to.eql([ 'application/json' ]); + expect(ctx.consumes).to.eql(['application/json']); expect(ctx.operationDoc).to.eql({ - consumes: [ 'application/json' ], + consumes: ['application/json'], responses: { default: { description: 'return foo', schema: {} } }, - tags: [ 'example', 'testing' ], + tags: ['example', 'testing'] }); }, visitApi(ctx) { const apiDoc = ctx.getApiDoc(); - expect(apiDoc.tags).to.eql([ - { name: 'example' }, - { name: 'testing' } - ]); + expect(apiDoc.tags).to.eql([{ name: 'example' }, { name: 'testing' }]); } }); }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection-empty-dependencies/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection-empty-dependencies/paths/foo.js index de81be1c..422bb9e4 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection-empty-dependencies/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection-empty-dependencies/paths/foo.js @@ -1,6 +1,6 @@ module.exports = function() { function GET() { - + return; } GET.apiDoc = { @@ -13,6 +13,6 @@ module.exports = function() { }; return { - GET, + GET }; }; diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection-empty-dependencies/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection-empty-dependencies/spec.ts index 1c2e7754..a9ab1d65 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection-empty-dependencies/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection-empty-dependencies/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -33,8 +34,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection/paths/foo.js index 03478971..8ab31b1e 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection/paths/foo.js @@ -1,6 +1,6 @@ module.exports = function(myService) { function GET() { - + return; } GET.apiDoc = { @@ -13,6 +13,6 @@ module.exports = function(myService) { }; return { - GET, + GET }; }; diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection/spec.ts index 31eaff7c..ccb41a65 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-after-dependency-injection/spec.ts @@ -1,19 +1,22 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), dependencies: { - myService: function() {} + myService: () => { + return; + } }, featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -36,8 +39,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters-disabled/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters-disabled/paths/foo.js index 595b078a..5242d23d 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters-disabled/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters-disabled/paths/foo.js @@ -7,11 +7,11 @@ module.exports = { type: 'string' } ], - GET, + GET }; function GET() { - + return; } GET.apiDoc = { @@ -20,7 +20,7 @@ GET.apiDoc = { name: 'name', in: 'query', type: 'string', - default: 'elvis', + default: 'elvis' } ], responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters-disabled/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters-disabled/spec.ts index e80733a1..44ed29d3 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters-disabled/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters-disabled/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -28,7 +29,7 @@ describe(path.basename(__dirname), () => { name: 'name', in: 'query', type: 'string', - default: 'elvis', + default: 'elvis' } ], responses: { @@ -36,7 +37,7 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, + } }); }, @@ -56,7 +57,7 @@ describe(path.basename(__dirname), () => { name: 'name', in: 'query', type: 'string', - default: 'elvis', + default: 'elvis' } ], responses: { @@ -64,8 +65,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); }, @@ -85,7 +86,7 @@ describe(path.basename(__dirname), () => { name: 'name', in: 'query', type: 'string', - default: 'elvis', + default: 'elvis' } ], responses: { @@ -93,8 +94,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters/paths/foo.js index f8c365e2..518ec013 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters/paths/foo.js @@ -6,11 +6,11 @@ module.exports = { type: 'string' } ], - GET, + GET }; function GET() { - + return; } GET.apiDoc = { @@ -19,7 +19,7 @@ GET.apiDoc = { name: 'name', in: 'query', type: 'string', - default: 'elvis', + default: 'elvis' } ], responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters/spec.ts index 75e7300e..c60ad257 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-default-parameters/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -39,7 +40,7 @@ describe(path.basename(__dirname), () => { name: 'name', in: 'query', type: 'string', - default: 'elvis', + default: 'elvis' } ], responses: { @@ -47,8 +48,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-duplicate-parameters/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-duplicate-parameters/paths/foo.js index d0b467e8..8b357549 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-duplicate-parameters/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-duplicate-parameters/paths/foo.js @@ -12,11 +12,11 @@ module.exports = { type: 'string' } ], - GET, + GET }; function GET() { - + return; } GET.apiDoc = { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-duplicate-parameters/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-duplicate-parameters/spec.ts index 60178cc7..810a6efd 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-duplicate-parameters/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-duplicate-parameters/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -52,8 +53,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/foo.js index 383b77e8..0e6d9783 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/foo.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/foo/{id}.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/foo/{id}.js index 04a5e448..3e0d0c82 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/foo/{id}.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/foo/{id}.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/roo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/roo.js index 6f924072..1f0f53da 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/roo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/roo.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/roo/{id}.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/roo/{id}.js index 047158c6..64b7ac14 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/roo/{id}.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/roo/{id}.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/{id}.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/{id}.js index 351636f4..c1a90bf3 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/{id}.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/paths/{id}.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/spec.ts index 91188681..cb239f48 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-dynamic-route-no-parameters/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -33,8 +34,8 @@ describe(path.basename(__dirname), () => { description: 'return something', schema: {} } - }, - }, + } + } }); expect(apiDoc.paths['/foo']).to.eql({ @@ -45,8 +46,8 @@ describe(path.basename(__dirname), () => { description: 'return all foo', schema: {} } - }, - }, + } + } }); expect(apiDoc.paths['/foo/{id}']).to.eql({ @@ -57,8 +58,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-in-operation-handler-array/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-in-operation-handler-array/paths/foo.js index e13607ea..1fe83ad4 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-in-operation-handler-array/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-in-operation-handler-array/paths/foo.js @@ -1,9 +1,14 @@ module.exports = { - GET: [function() {}, GET], + GET: [ + function() { + return; + }, + GET + ] }; function GET() { - + return; } GET.apiDoc = { responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-in-operation-handler-array/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-in-operation-handler-array/spec.ts index 1c2e7754..a9ab1d65 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-in-operation-handler-array/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-in-operation-handler-array/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -33,8 +34,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-no-features-allowed/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-no-features-allowed/paths/foo.js index 9e6b28cd..ee27c4fe 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-no-features-allowed/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-no-features-allowed/paths/foo.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-no-features-allowed/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-no-features-allowed/spec.ts index 4a3d87a9..9b42b92f 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-no-features-allowed/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-no-features-allowed/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -33,8 +34,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features-not-inherited/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features-not-inherited/paths/foo.js index 7d29c3fe..e91436b4 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features-not-inherited/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features-not-inherited/paths/foo.js @@ -1,6 +1,8 @@ module.exports = { 'x-some-framework-additional-middleware': [ - function() {} + function() { + return; + } ], parameters: [ { @@ -9,11 +11,11 @@ module.exports = { type: 'string' } ], - GET, + GET }; function GET() { - + return; } GET.apiDoc = { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features-not-inherited/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features-not-inherited/spec.ts index 8666c658..16711be2 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features-not-inherited/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features-not-inherited/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -46,10 +47,10 @@ describe(path.basename(__dirname), () => { default: { description: 'return foo', schema: {} - }, + } }, - 'x-some-framework-inherit-additional-middleware': false, - }, + 'x-some-framework-inherit-additional-middleware': false + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features/paths/foo.js index 28f5c406..278001d7 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features/paths/foo.js @@ -1,6 +1,8 @@ module.exports = { 'x-some-framework-additional-middleware': [ - function() {} + function() { + return; + } ], parameters: [ { @@ -9,11 +11,11 @@ module.exports = { type: 'string' } ], - GET, + GET }; function GET() { - + return; } GET.apiDoc = { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features/spec.ts index 2f369f18..b705e4b8 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-additional-features/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -47,8 +48,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-disabled-response-request-coercer/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-disabled-response-request-coercer/paths/foo.js index a8fdb00f..16d4b9e8 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-disabled-response-request-coercer/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-disabled-response-request-coercer/paths/foo.js @@ -6,11 +6,11 @@ module.exports = { type: 'string' } ], - GET, + GET }; function GET() { - + return; } GET.apiDoc = { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-disabled-response-request-coercer/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-disabled-response-request-coercer/spec.ts index a7d7633f..7817e3f8 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-disabled-response-request-coercer/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters-disabled-response-request-coercer/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -49,8 +50,8 @@ describe(path.basename(__dirname), () => { }, 'x-some-framework-disable-coercion-middleware': true, 'x-some-framework-disable-response-validation-middleware': true, - 'x-some-framework-disable-validation-middleware': true, - }, + 'x-some-framework-disable-validation-middleware': true + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters/paths/foo.js index 432778e8..42f0c885 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters/paths/foo.js @@ -6,11 +6,11 @@ module.exports = { type: 'string' } ], - GET, + GET }; function GET() { - + return; } GET.apiDoc = { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters/spec.ts index bfdf091c..48be5d63 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-parameters/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -46,8 +47,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-tags/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-tags/paths/foo.js index f9211d8c..b0a52834 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-tags/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-tags/paths/foo.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { responses: { @@ -12,5 +12,5 @@ GET.apiDoc = { schema: {} } }, - tags: [ 'pets', 'testing', 'example', 'examples' ], + tags: ['pets', 'testing', 'example', 'examples'] }; diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-tags/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-tags/spec.ts index 8511e698..ce1efc2a 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-tags/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-tags/spec.ts @@ -1,16 +1,16 @@ -import OpenapiFramework from '../../../'; import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -24,7 +24,7 @@ describe(path.basename(__dirname), () => { schema: {} } }, - tags: [ 'example', 'examples', 'pets', 'testing' ], + tags: ['example', 'examples', 'pets', 'testing'] }); }, visitApi(ctx) { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-parameter-ref/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-parameter-ref/paths/foo.js index 6c202d2c..cc269181 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-parameter-ref/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-parameter-ref/paths/foo.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { parameters: [ diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-parameter-ref/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-parameter-ref/spec.ts index 5293254b..78f88627 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-parameter-ref/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-parameter-ref/spec.ts @@ -1,22 +1,24 @@ -import OpenapiFramework from '../../../'; import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); it('should work', () => { expect(() => { - framework.initialize({ }); - }).to.throw('some-framework: Invalid parameter $ref or definition not found in apiDoc.parameters: Foo'); + framework.initialize({}); + }).to.throw( + 'some-framework: Invalid parameter $ref or definition not found in apiDoc.parameters: Foo' + ); }); }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-response-ref/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-response-ref/paths/foo.js index 9218dd81..2ac32ed3 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-response-ref/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-response-ref/paths/foo.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-response-ref/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-response-ref/spec.ts index f14aa649..1d23e9c1 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-response-ref/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-missing-response-ref/spec.ts @@ -1,22 +1,24 @@ -import OpenapiFramework from '../../../'; import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); it('should work', () => { expect(() => { framework.initialize({}); - }).to.throw('some-framework: Invalid response $ref or definition not found in apiDoc.responses: #/responses/FooResponse'); + }).to.throw( + 'some-framework: Invalid response $ref or definition not found in apiDoc.responses: #/responses/FooResponse' + ); }); }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-parameter-ref/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-parameter-ref/paths/foo.js index 6db06a0e..e8733835 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-parameter-ref/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-parameter-ref/paths/foo.js @@ -1,14 +1,14 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { parameters: [ { - $ref: '#/parameters/Foo', + $ref: '#/parameters/Foo' } ], diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-parameter-ref/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-parameter-ref/spec.ts index 0fc23246..9439388a 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-parameter-ref/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-parameter-ref/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -30,7 +31,7 @@ describe(path.basename(__dirname), () => { get: { parameters: [ { - $ref: '#/parameters/Foo', + $ref: '#/parameters/Foo' } ], responses: { @@ -38,8 +39,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-response-ref/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-response-ref/paths/foo.js index 9218dd81..2ac32ed3 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-response-ref/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-response-ref/paths/foo.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-response-ref/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-response-ref/spec.ts index d8b6fba6..ededd84c 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-response-ref/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc-with-response-ref/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -30,13 +31,12 @@ describe(path.basename(__dirname), () => { get: { responses: { default: { - $ref: '#/responses/FooResponse', + $ref: '#/responses/FooResponse' } - }, - }, + } + } }); } }); - }); }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc/paths/foo.js b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc/paths/foo.js index 9e6b28cd..ee27c4fe 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc/paths/foo.js +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc/paths/foo.js @@ -1,9 +1,9 @@ module.exports = { - GET, + GET }; function GET() { - + return; } GET.apiDoc = { responses: { diff --git a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc/spec.ts index 1c2e7754..a9ab1d65 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir-with-valid-method-doc/spec.ts @@ -1,16 +1,17 @@ -import OpenapiFramework from '../../../'; +/* tslint:disable:no-unused-expression */ import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); @@ -33,8 +34,8 @@ describe(path.basename(__dirname), () => { description: 'return foo', schema: {} } - }, - }, + } + } }); } }); diff --git a/packages/openapi-framework/test/sample-projects/paths-dir/spec.ts b/packages/openapi-framework/test/sample-projects/paths-dir/spec.ts index 61f4b347..adde6d9a 100644 --- a/packages/openapi-framework/test/sample-projects/paths-dir/spec.ts +++ b/packages/openapi-framework/test/sample-projects/paths-dir/spec.ts @@ -1,16 +1,16 @@ -import OpenapiFramework from '../../../'; import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: path.resolve(__dirname, 'paths'), + paths: path.resolve(__dirname, 'paths') }); }); diff --git a/packages/openapi-framework/test/sample-projects/with-duplicate-path/spec.ts b/packages/openapi-framework/test/sample-projects/with-duplicate-path/spec.ts index 54ab65fd..909db6cf 100644 --- a/packages/openapi-framework/test/sample-projects/with-duplicate-path/spec.ts +++ b/packages/openapi-framework/test/sample-projects/with-duplicate-path/spec.ts @@ -1,11 +1,11 @@ -import OpenapiFramework from '../../../'; import { expect } from 'chai'; +import OpenapiFramework from '../../../'; const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', @@ -19,13 +19,15 @@ describe(path.basename(__dirname), () => { path: '/zoo', module: require('./paths/foo') } - ], + ] }); }); it('should throw', () => { expect(() => { framework.initialize({}); - }).to.throw('some-framework: args.paths produced duplicate urls for "/zoo"'); + }).to.throw( + 'some-framework: args.paths produced duplicate urls for "/zoo"' + ); }); }); diff --git a/packages/openapi-framework/test/sample-projects/with-path-item/spec.ts b/packages/openapi-framework/test/sample-projects/with-path-item/spec.ts index dbc66434..27681dc8 100644 --- a/packages/openapi-framework/test/sample-projects/with-path-item/spec.ts +++ b/packages/openapi-framework/test/sample-projects/with-path-item/spec.ts @@ -4,15 +4,17 @@ const path = require('path'); describe(path.basename(__dirname), () => { let framework: OpenapiFramework; - beforeEach(function() { + beforeEach(() => { framework = new OpenapiFramework({ apiDoc: path.resolve(__dirname, 'apiDoc.yml'), featureType: 'middleware', name: 'some-framework', - paths: [{ - path: '/zoo', - module: require('./paths/foo') - }], + paths: [ + { + path: '/zoo', + module: require('./paths/foo') + } + ] }); }); diff --git a/packages/openapi-jsonschema-parameters/test/data-driven.ts b/packages/openapi-jsonschema-parameters/test/data-driven.ts index 17258089..8c8b422e 100644 --- a/packages/openapi-jsonschema-parameters/test/data-driven.ts +++ b/packages/openapi-jsonschema-parameters/test/data-driven.ts @@ -5,12 +5,14 @@ const baseDir = path.resolve(__dirname, 'data-driven'); import { convertParametersToJSONSchema } from '../'; describe('openapi-jsonschema-parameters', () => { - glob.sync('*.js', {cwd: baseDir}).forEach(fixture => { + glob.sync('*.js', { cwd: baseDir }).forEach(fixture => { const testName = path.basename(fixture, '.js').replace(/-/g, ' '); fixture = require(path.resolve(baseDir, fixture)); it(`should ${testName}`, () => { - expect(convertParametersToJSONSchema(fixture.parameters)).to.eql(fixture.outputSchema); + expect(convertParametersToJSONSchema(fixture.parameters)).to.eql( + fixture.outputSchema + ); }); }); }); diff --git a/packages/openapi-jsonschema-parameters/test/data-driven/allow-custom-parameters-nullable.js b/packages/openapi-jsonschema-parameters/test/data-driven/allow-custom-parameters-nullable.js index ddd2f861..6014a6f0 100644 --- a/packages/openapi-jsonschema-parameters/test/data-driven/allow-custom-parameters-nullable.js +++ b/packages/openapi-jsonschema-parameters/test/data-driven/allow-custom-parameters-nullable.js @@ -13,12 +13,15 @@ module.exports = { query: { properties: { search: { - anyOf: [{ - type: 'string', - 'x-custom': 'value' - }, { - type: 'null' - }] + anyOf: [ + { + type: 'string', + 'x-custom': 'value' + }, + { + type: 'null' + } + ] } }, required: [] diff --git a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-path-param-to-json-schema.js b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-path-param-to-json-schema.js index 1c826dc6..243a04aa 100644 --- a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-path-param-to-json-schema.js +++ b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-path-param-to-json-schema.js @@ -11,12 +11,12 @@ module.exports = { path: { properties: { foo: { - 'anyOf': [ + anyOf: [ { - 'type': 'string' + type: 'string' }, { - 'type': 'null' + type: 'null' } ] } diff --git a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-query-param-to-json-schema-openapi3.js b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-query-param-to-json-schema-openapi3.js index 6d35fd28..437b8a20 100644 --- a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-query-param-to-json-schema-openapi3.js +++ b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-query-param-to-json-schema-openapi3.js @@ -14,12 +14,12 @@ module.exports = { query: { properties: { foo: { - 'anyOf': [ + anyOf: [ { - 'type': 'string' + type: 'string' }, { - 'type': 'null' + type: 'null' } ] } diff --git a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-query-param-to-json-schema.js b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-query-param-to-json-schema.js index 5817bc41..d2625a2a 100644 --- a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-query-param-to-json-schema.js +++ b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-query-param-to-json-schema.js @@ -12,12 +12,12 @@ module.exports = { query: { properties: { foo: { - 'anyOf': [ + anyOf: [ { - 'type': 'string' + type: 'string' }, { - 'type': 'null' + type: 'null' } ] } diff --git a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-required-path-param-to-json-schema.js b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-required-path-param-to-json-schema.js index 4847db77..a7f52390 100644 --- a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-required-path-param-to-json-schema.js +++ b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-nullable-required-path-param-to-json-schema.js @@ -12,12 +12,12 @@ module.exports = { path: { properties: { foo: { - 'anyOf': [ + anyOf: [ { - 'type': 'string' + type: 'string' }, { - 'type': 'null' + type: 'null' } ] } diff --git a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-single-complex-path-parameter-to-json-schema.js b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-single-complex-path-parameter-to-json-schema.js index 797b2eb1..869da565 100644 --- a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-single-complex-path-parameter-to-json-schema.js +++ b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-single-complex-path-parameter-to-json-schema.js @@ -33,13 +33,13 @@ module.exports = { foo: { additionalItems: true, default: 5, - description: "asdfasdf", + description: 'asdfasdf', type: 'string', maximum: 0, exclusiveMaximum: true, minimum: 5, exclusiveMinimum: false, - format: "asdf", + format: 'asdf', items: [], maxLength: 5, minLength: 6, @@ -55,4 +55,4 @@ module.exports = { required: ['foo'] } } -} +}; diff --git a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-single-complex-query-param-to-json-schema.js b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-single-complex-query-param-to-json-schema.js index 7f7d466a..e20b545a 100644 --- a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-single-complex-query-param-to-json-schema.js +++ b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-single-complex-query-param-to-json-schema.js @@ -33,13 +33,13 @@ module.exports = { foo: { additionalItems: true, default: 5, - description: "asdfasdf", + description: 'asdfasdf', type: 'string', maximum: 0, exclusiveMaximum: true, minimum: 5, exclusiveMinimum: false, - format: "asdf", + format: 'asdf', items: [], maxLength: 5, minLength: 6, @@ -55,4 +55,4 @@ module.exports = { required: ['foo'] } } -} +}; diff --git a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-single-nullable-complex-query-param-to-json-schema.js b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-single-nullable-complex-query-param-to-json-schema.js index 28389787..82f4b2e6 100644 --- a/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-single-nullable-complex-query-param-to-json-schema.js +++ b/packages/openapi-jsonschema-parameters/test/data-driven/convert-a-single-nullable-complex-query-param-to-json-schema.js @@ -32,32 +32,35 @@ module.exports = { query: { properties: { foo: { - anyOf: [{ - additionalItems: true, - default: 5, - description: "asdfasdf", - type: 'string', - maximum: 0, - exclusiveMaximum: true, - minimum: 5, - exclusiveMinimum: false, - format: "asdf", - items: [], - maxLength: 5, - minLength: 6, - pattern: '^asdf$', - title: 'fffasdf', - maxItems: 5, - minItems: 7, - uniqueItems: false, - enum: ['1', '3'], - multipleOf: 57 - }, { - type: 'null' - }] + anyOf: [ + { + additionalItems: true, + default: 5, + description: 'asdfasdf', + type: 'string', + maximum: 0, + exclusiveMaximum: true, + minimum: 5, + exclusiveMinimum: false, + format: 'asdf', + items: [], + maxLength: 5, + minLength: 6, + pattern: '^asdf$', + title: 'fffasdf', + maxItems: 5, + minItems: 7, + uniqueItems: false, + enum: ['1', '3'], + multipleOf: 57 + }, + { + type: 'null' + } + ] } }, required: ['foo'] } } -} +}; diff --git a/packages/openapi-jsonschema-parameters/test/data-driven/not-convert-file-type.js b/packages/openapi-jsonschema-parameters/test/data-driven/not-convert-file-type.js index 0a051ad7..65213dc9 100644 --- a/packages/openapi-jsonschema-parameters/test/data-driven/not-convert-file-type.js +++ b/packages/openapi-jsonschema-parameters/test/data-driven/not-convert-file-type.js @@ -7,6 +7,5 @@ module.exports = { } ], - outputSchema: { - } + outputSchema: {} }; diff --git a/packages/openapi-jsonschema-parameters/test/data-driven/return-first-body-param-with-schema.js b/packages/openapi-jsonschema-parameters/test/data-driven/return-first-body-param-with-schema.js index 7afc8604..77dd1230 100644 --- a/packages/openapi-jsonschema-parameters/test/data-driven/return-first-body-param-with-schema.js +++ b/packages/openapi-jsonschema-parameters/test/data-driven/return-first-body-param-with-schema.js @@ -24,7 +24,7 @@ module.exports = { schema: { $ref: 'foo' } - }, + } ], outputSchema: { diff --git a/packages/openapi-request-coercer/test/data-driven.ts b/packages/openapi-request-coercer/test/data-driven.ts index 0100a888..c2d7779f 100644 --- a/packages/openapi-request-coercer/test/data-driven.ts +++ b/packages/openapi-request-coercer/test/data-driven.ts @@ -5,13 +5,14 @@ const baseDir = path.resolve(__dirname, 'data-driven'); import Sut from '../'; describe(require('../package.json').name, () => { - glob.sync('*.js', {cwd: baseDir}).forEach(fixture => { + glob.sync('*.js', { cwd: baseDir }).forEach(fixture => { const testName = path.basename(fixture, '.js').replace(/-/g, ' '); fixture = require(path.resolve(baseDir, fixture)); it(`should ${testName}`, () => { if (fixture.constructorError) { expect(() => { + /* tslint:disable-next-line:no-unused-expression */ new Sut(fixture.args); }).to.throw(fixture.constructorError); return; diff --git a/packages/openapi-request-coercer/test/data-driven/coerce-array-with-collectionFormat.js b/packages/openapi-request-coercer/test/data-driven/coerce-array-with-collectionFormat.js index aa0537de..4c460bc9 100644 --- a/packages/openapi-request-coercer/test/data-driven/coerce-array-with-collectionFormat.js +++ b/packages/openapi-request-coercer/test/data-driven/coerce-array-with-collectionFormat.js @@ -39,7 +39,7 @@ module.exports = { type: 'string' }, collectionFormat: 'pipes' - }, + } ] }, diff --git a/packages/openapi-request-coercer/test/data-driven/coerce-array-with-style-openapi3.js b/packages/openapi-request-coercer/test/data-driven/coerce-array-with-style-openapi3.js index 75b239fb..a1c72aff 100644 --- a/packages/openapi-request-coercer/test/data-driven/coerce-array-with-style-openapi3.js +++ b/packages/openapi-request-coercer/test/data-driven/coerce-array-with-style-openapi3.js @@ -6,11 +6,11 @@ module.exports = { name: 'headercsv', schema: { type: 'array', - items: { + items: { schema: { type: 'integer' } - }, + } }, - style: 'simple', + style: 'simple' }, { @@ -19,8 +19,8 @@ module.exports = { schema: { type: 'array', items: { - schema: { type: 'string' }, - }, + schema: { type: 'string' } + } }, style: 'form', explodes: false @@ -32,11 +32,11 @@ module.exports = { schema: { type: 'array', items: { - schema: { type: 'string' }, - }, + schema: { type: 'string' } + } }, style: 'form', - explodes: true, + explodes: true }, { @@ -45,10 +45,10 @@ module.exports = { schema: { type: 'array', items: { - schema: { type: 'string' }, - }, + schema: { type: 'string' } + } }, - style: 'pipeDelimited', + style: 'pipeDelimited' }, { @@ -57,10 +57,10 @@ module.exports = { schema: { type: 'array', items: { - schema: { type: 'string' }, - }, + schema: { type: 'string' } + } }, - style: 'spaceDelimited', + style: 'spaceDelimited' }, { @@ -69,10 +69,10 @@ module.exports = { schema: { type: 'array', items: { - schema: { type: 'string' }, - }, + schema: { type: 'string' } + } }, - style: 'simple', + style: 'simple' } ] }, @@ -81,31 +81,31 @@ module.exports = { method: 'post', path: '/foo,bar,baz/', headers: { - 'headercsv': '1,2,3' + headercsv: '1,2,3' }, params: { - pathcsv: 'foo,bar,baz', + pathcsv: 'foo,bar,baz' }, query: { querycsv: 'foo,bar', querymulti: ['foo', 'bar'], querypipe: 'pipe|delimited|array', - queryspace: 'space delimited array', - }, + queryspace: 'space delimited array' + } }, headers: { - headercsv: [1, 2, 3], + headercsv: [1, 2, 3] }, params: { - pathcsv: ['foo', 'bar', 'baz'], + pathcsv: ['foo', 'bar', 'baz'] }, query: { querycsv: ['foo', 'bar'], querymulti: ['foo', 'bar'], querypipe: ['pipe', 'delimited', 'array'], - queryspace: ['space', 'delimited', 'array'], - }, + queryspace: ['space', 'delimited', 'array'] + } }; diff --git a/packages/openapi-request-coercer/test/data-driven/coerce-boolean-params-invalid-value-openapi3.js b/packages/openapi-request-coercer/test/data-driven/coerce-boolean-params-invalid-value-openapi3.js index a3b36e08..5e4942b7 100644 --- a/packages/openapi-request-coercer/test/data-driven/coerce-boolean-params-invalid-value-openapi3.js +++ b/packages/openapi-request-coercer/test/data-driven/coerce-boolean-params-invalid-value-openapi3.js @@ -15,7 +15,7 @@ module.exports = { schema: { type: 'boolean' }, - "x-openapi-coercion-strict": true + 'x-openapi-coercion-strict': true }, { @@ -40,7 +40,7 @@ module.exports = { schema: { type: 'boolean' }, - "x-openapi-coercion-strict": true + 'x-openapi-coercion-strict': true } ] }, @@ -56,14 +56,14 @@ module.exports = { query2: 'invalid', query3: 'invalid' }, - headers: null, + headers: null }, headers: null, params: { path1: true, - path2: null, + path2: null }, query: { diff --git a/packages/openapi-request-coercer/test/data-driven/coerce-boolean-params-invalid-value.js b/packages/openapi-request-coercer/test/data-driven/coerce-boolean-params-invalid-value.js index c9f6a9da..80b7e9f6 100644 --- a/packages/openapi-request-coercer/test/data-driven/coerce-boolean-params-invalid-value.js +++ b/packages/openapi-request-coercer/test/data-driven/coerce-boolean-params-invalid-value.js @@ -11,7 +11,7 @@ module.exports = { in: 'path', name: 'path2', type: 'boolean', - "x-openapi-coercion-strict": true + 'x-openapi-coercion-strict': true }, { @@ -30,7 +30,7 @@ module.exports = { in: 'query', name: 'query3', type: 'boolean', - "x-openapi-coercion-strict": true + 'x-openapi-coercion-strict': true } ] }, @@ -46,14 +46,14 @@ module.exports = { query2: 'invalid', query3: 'invalid' }, - headers: null, + headers: null }, headers: null, params: { path1: true, - path2: null, + path2: null }, query: { diff --git a/packages/openapi-request-coercer/test/data-driven/coerce-boolean-params-openapi3.js b/packages/openapi-request-coercer/test/data-driven/coerce-boolean-params-openapi3.js index cb536b71..28964790 100644 --- a/packages/openapi-request-coercer/test/data-driven/coerce-boolean-params-openapi3.js +++ b/packages/openapi-request-coercer/test/data-driven/coerce-boolean-params-openapi3.js @@ -5,32 +5,32 @@ module.exports = { in: 'path', name: 'path1', schema: { - type: 'boolean', - }, + type: 'boolean' + } }, { in: 'path', name: 'path2', schema: { - type: 'boolean', - }, + type: 'boolean' + } }, { in: 'query', name: 'query1', schema: { - type: 'boolean', - }, + type: 'boolean' + } }, { in: 'query', name: 'query2', schema: { - type: 'boolean', - }, + type: 'boolean' + } } ] }, diff --git a/packages/openapi-request-coercer/test/data-driven/coerce-object-params-in-request-openapi3.js b/packages/openapi-request-coercer/test/data-driven/coerce-object-params-in-request-openapi3.js index 3957699b..74c984ee 100644 --- a/packages/openapi-request-coercer/test/data-driven/coerce-object-params-in-request-openapi3.js +++ b/packages/openapi-request-coercer/test/data-driven/coerce-object-params-in-request-openapi3.js @@ -8,10 +8,10 @@ module.exports = { type: 'array', items: { schema: { - type: 'object', + type: 'object' // optional format property not passed meaning default coercer will kick in - }, - }, + } + } }, name: 'include', required: false @@ -19,7 +19,7 @@ module.exports = { { in: 'query', schema: { - type: 'object', + type: 'object' // optional format property not passed meaning the default coercer will kick in }, name: 'query', @@ -44,9 +44,9 @@ module.exports = { { association: 'lines', include: ['status'] }, { association: 'people', include: ['hairColor'] } ], - query: { - where: { - $status: 2 + query: { + where: { + $status: 2 } } } diff --git a/packages/openapi-request-coercer/test/data-driven/coerce-object-params-in-request.js b/packages/openapi-request-coercer/test/data-driven/coerce-object-params-in-request.js index 27939c3c..c7c8f9dc 100644 --- a/packages/openapi-request-coercer/test/data-driven/coerce-object-params-in-request.js +++ b/packages/openapi-request-coercer/test/data-driven/coerce-object-params-in-request.js @@ -33,7 +33,10 @@ module.exports = { }, query: { - include: [{ association: 'lines', include: ['status'] }, { association: 'people', include: ['hairColor'] }], + include: [ + { association: 'lines', include: ['status'] }, + { association: 'people', include: ['hairColor'] } + ], query: { where: { $status: 2 } } } }; diff --git a/packages/openapi-request-coercer/test/data-driven/coerce-params-in-request-openapi3.js b/packages/openapi-request-coercer/test/data-driven/coerce-params-in-request-openapi3.js index 0c4c61a0..2e8be67f 100644 --- a/packages/openapi-request-coercer/test/data-driven/coerce-params-in-request-openapi3.js +++ b/packages/openapi-request-coercer/test/data-driven/coerce-params-in-request-openapi3.js @@ -5,40 +5,40 @@ module.exports = { in: 'header', name: 'X-Foo', schema: { - type: 'boolean', - }, + type: 'boolean' + } }, { in: 'path', name: 'path1', schema: { - type: 'integer', - }, + type: 'integer' + } }, { in: 'path', name: 'path2', schema: { - type: 'number', - }, + type: 'number' + } }, { in: 'query', name: 'foo', schema: { - type: 'boolean', - }, + type: 'boolean' + } }, { in: 'query', name: 'boo', schema: { - type: 'string', - }, + type: 'string' + } } ] }, diff --git a/packages/openapi-request-coercer/test/data-driven/handle-strict-extension-openapi3.js b/packages/openapi-request-coercer/test/data-driven/handle-strict-extension-openapi3.js index e4480b1e..147ce73e 100644 --- a/packages/openapi-request-coercer/test/data-driven/handle-strict-extension-openapi3.js +++ b/packages/openapi-request-coercer/test/data-driven/handle-strict-extension-openapi3.js @@ -6,27 +6,27 @@ module.exports = { in: 'path', name: 'path0', schema: { - type: 'boolean', + type: 'boolean' }, - 'x-foo-coercion-strict': true + 'x-foo-coercion-strict': true }, { in: 'path', name: 'path1', schema: { - type: 'boolean', + type: 'boolean' }, - 'x-foo-coercion-strict': true + 'x-foo-coercion-strict': true }, { in: 'path', name: 'path2', schema: { - type: 'boolean', + type: 'boolean' }, - 'x-foo-coercion-strict': true + 'x-foo-coercion-strict': true } ] }, @@ -38,9 +38,8 @@ module.exports = { path1: 'true', path2: 'false' }, - query: { - }, - headers: null, + query: {}, + headers: null }, headers: null, @@ -48,9 +47,8 @@ module.exports = { params: { path0: true, path1: true, - path2: false, + path2: false }, - query: { - } + query: {} }; diff --git a/packages/openapi-request-coercer/test/data-driven/handle-strict-extension.js b/packages/openapi-request-coercer/test/data-driven/handle-strict-extension.js index 45b1811c..0661eda7 100644 --- a/packages/openapi-request-coercer/test/data-driven/handle-strict-extension.js +++ b/packages/openapi-request-coercer/test/data-driven/handle-strict-extension.js @@ -6,21 +6,21 @@ module.exports = { in: 'path', name: 'path0', type: 'boolean', - 'x-foo-coercion-strict': true + 'x-foo-coercion-strict': true }, { in: 'path', name: 'path1', type: 'boolean', - 'x-foo-coercion-strict': true + 'x-foo-coercion-strict': true }, { in: 'path', name: 'path2', type: 'boolean', - 'x-foo-coercion-strict': true + 'x-foo-coercion-strict': true } ] }, @@ -32,9 +32,8 @@ module.exports = { path1: 'true', path2: 'false' }, - query: { - }, - headers: null, + query: {}, + headers: null }, headers: null, @@ -42,9 +41,8 @@ module.exports = { params: { path0: true, path1: true, - path2: false, + path2: false }, - query: { - } + query: {} }; diff --git a/packages/openapi-request-coercer/test/data-driven/ignore-object-params-in-request-when-enableObjectCoercion-is-not-set-openapi3.js b/packages/openapi-request-coercer/test/data-driven/ignore-object-params-in-request-when-enableObjectCoercion-is-not-set-openapi3.js index c005a482..9cfb8b2a 100644 --- a/packages/openapi-request-coercer/test/data-driven/ignore-object-params-in-request-when-enableObjectCoercion-is-not-set-openapi3.js +++ b/packages/openapi-request-coercer/test/data-driven/ignore-object-params-in-request-when-enableObjectCoercion-is-not-set-openapi3.js @@ -5,24 +5,24 @@ module.exports = { in: 'query', schema: { type: 'array', - items: { - schema: { - type: 'object', + items: { + schema: { + type: 'object' // optional format property not passed meaning the default coercer will kick in - } - }, + } + } }, name: 'include', - required: false, + required: false }, { in: 'query', schema: { - type: 'object', + type: 'object' // optional format property not passed meaning the default coercer will kick in }, name: 'query', - required: false, + required: false } ] }, diff --git a/packages/openapi-request-coercer/test/data-driven/ignore-unkown-types-openapi3.js b/packages/openapi-request-coercer/test/data-driven/ignore-unkown-types-openapi3.js index d996cd77..febaf08a 100644 --- a/packages/openapi-request-coercer/test/data-driven/ignore-unkown-types-openapi3.js +++ b/packages/openapi-request-coercer/test/data-driven/ignore-unkown-types-openapi3.js @@ -5,16 +5,16 @@ module.exports = { in: 'path', name: 'path1', schema: { - type: 'asdfasdf', - }, + type: 'asdfasdf' + } }, { in: 'path', name: 'path2', schema: { - type: 'dddd', - }, + type: 'dddd' + } } ] }, diff --git a/packages/openapi-request-coercer/test/data-driven/not-require-any-parameters.js b/packages/openapi-request-coercer/test/data-driven/not-require-any-parameters.js index d39c51ef..737e8b86 100644 --- a/packages/openapi-request-coercer/test/data-driven/not-require-any-parameters.js +++ b/packages/openapi-request-coercer/test/data-driven/not-require-any-parameters.js @@ -1,7 +1,6 @@ module.exports = { args: { - parameters: [ - ] + parameters: [] }, request: { diff --git a/packages/openapi-request-coercer/test/data-driven/should-pass-through-arrays-openapi3.js b/packages/openapi-request-coercer/test/data-driven/should-pass-through-arrays-openapi3.js index d870a0a5..a65c3272 100644 --- a/packages/openapi-request-coercer/test/data-driven/should-pass-through-arrays-openapi3.js +++ b/packages/openapi-request-coercer/test/data-driven/should-pass-through-arrays-openapi3.js @@ -8,10 +8,10 @@ module.exports = { type: 'array', items: { schema: { - type: 'integer', - }, - }, - }, + type: 'integer' + } + } + } }, { @@ -21,10 +21,10 @@ module.exports = { type: 'array', items: { schema: { - type: 'number', - }, - }, - }, + type: 'number' + } + } + } } ] }, @@ -32,8 +32,8 @@ module.exports = { request: { path: '/', query: { - 'foo': ['5', '6'], - 'boo': '34.2345' + foo: ['5', '6'], + boo: '34.2345' }, headers: null }, diff --git a/packages/openapi-request-coercer/test/data-driven/should-pass-through-arrays.js b/packages/openapi-request-coercer/test/data-driven/should-pass-through-arrays.js index cb35813d..5de6a94a 100644 --- a/packages/openapi-request-coercer/test/data-driven/should-pass-through-arrays.js +++ b/packages/openapi-request-coercer/test/data-driven/should-pass-through-arrays.js @@ -24,8 +24,8 @@ module.exports = { request: { path: '/', query: { - 'foo': ['5', '6'], - 'boo': '34.2345' + foo: ['5', '6'], + boo: '34.2345' }, headers: null }, diff --git a/packages/openapi-request-coercer/test/data-driven/throw-error-when-array-parameter-has-items-property-of-type-array-openapi3.js b/packages/openapi-request-coercer/test/data-driven/throw-error-when-array-parameter-has-items-property-of-type-array-openapi3.js index 8637d6cf..07cdd637 100644 --- a/packages/openapi-request-coercer/test/data-driven/throw-error-when-array-parameter-has-items-property-of-type-array-openapi3.js +++ b/packages/openapi-request-coercer/test/data-driven/throw-error-when-array-parameter-has-items-property-of-type-array-openapi3.js @@ -11,10 +11,10 @@ module.exports = { type: 'array', items: { schema: { - type: 'array', - }, - }, - }, + type: 'array' + } + } + } } ] }, diff --git a/packages/openapi-request-coercer/test/data-driven/throw-error-when-array-parameter-has-no-items-property-openapi3.js b/packages/openapi-request-coercer/test/data-driven/throw-error-when-array-parameter-has-no-items-property-openapi3.js index 9d80c785..606131dd 100644 --- a/packages/openapi-request-coercer/test/data-driven/throw-error-when-array-parameter-has-no-items-property-openapi3.js +++ b/packages/openapi-request-coercer/test/data-driven/throw-error-when-array-parameter-has-no-items-property-openapi3.js @@ -8,8 +8,8 @@ module.exports = { name: 'foo', in: 'query', schema: { - type: 'array', - }, + type: 'array' + } } ] }, diff --git a/packages/openapi-request-validator/test/data-driven.ts b/packages/openapi-request-validator/test/data-driven.ts index ed87e3e0..703ee2a4 100644 --- a/packages/openapi-request-validator/test/data-driven.ts +++ b/packages/openapi-request-validator/test/data-driven.ts @@ -5,13 +5,14 @@ const baseDir = path.resolve(__dirname, 'data-driven'); import Sut from '../'; describe(require('../package.json').name, () => { - glob.sync('*.js', {cwd: baseDir}).forEach(fixture => { + glob.sync('*.js', { cwd: baseDir }).forEach(fixture => { const testName = path.basename(fixture, '.js').replace(/-/g, ' '); fixture = require(path.resolve(baseDir, fixture)); it(`should ${testName}`, () => { if (fixture.constructorError) { expect(() => { + /* tslint:disable-next-line:no-unused-expression */ new Sut(fixture.validateArgs); }).to.throw(fixture.constructorError); return; diff --git a/packages/openapi-request-validator/test/data-driven/accept-a-required-header-param.js b/packages/openapi-request-validator/test/data-driven/accept-a-required-header-param.js index f7be7494..5a6946a5 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-a-required-header-param.js +++ b/packages/openapi-request-validator/test/data-driven/accept-a-required-header-param.js @@ -2,9 +2,9 @@ module.exports = { validateArgs: { parameters: [ { - in: "header", - name: "X-foO", - type: "string", + in: 'header', + name: 'X-foO', + type: 'string', required: true } ], @@ -12,7 +12,7 @@ module.exports = { }, request: { headers: { - "x-foo": "asdf" + 'x-foo': 'asdf' } } }; diff --git a/packages/openapi-request-validator/test/data-driven/accept-a-required-path-param.js b/packages/openapi-request-validator/test/data-driven/accept-a-required-path-param.js index e20fcf55..8bd982ff 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-a-required-path-param.js +++ b/packages/openapi-request-validator/test/data-driven/accept-a-required-path-param.js @@ -2,19 +2,19 @@ module.exports = { validateArgs: { parameters: [ { - in: "path", - name: "path1", - type: "string", + in: 'path', + name: 'path1', + type: 'string', required: true } ], schemas: null }, request: { - path: "/foo/asdf", + path: '/foo/asdf', params: { - path1: "foo", - path2: "asdf" + path1: 'foo', + path2: 'asdf' } } }; diff --git a/packages/openapi-request-validator/test/data-driven/accept-a-required-query-param.js b/packages/openapi-request-validator/test/data-driven/accept-a-required-query-param.js index 619eb253..0f3a1fed 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-a-required-query-param.js +++ b/packages/openapi-request-validator/test/data-driven/accept-a-required-query-param.js @@ -2,18 +2,18 @@ module.exports = { validateArgs: { parameters: [ { - in: "query", - name: "foo", - type: "string", + in: 'query', + name: 'foo', + type: 'string', required: true } ], schemas: null }, request: { - path: "?foo=asdf", + path: '?foo=asdf', query: { - foo: "asdf" + foo: 'asdf' } } }; diff --git a/packages/openapi-request-validator/test/data-driven/accept-an-optional-header-param.js b/packages/openapi-request-validator/test/data-driven/accept-an-optional-header-param.js index 4d179ab9..ba8ee0bd 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-an-optional-header-param.js +++ b/packages/openapi-request-validator/test/data-driven/accept-an-optional-header-param.js @@ -2,9 +2,9 @@ module.exports = { validateArgs: { parameters: [ { - in: "header", - name: "X-yoda", - type: "string" + in: 'header', + name: 'X-yoda', + type: 'string' } ], schemas: null diff --git a/packages/openapi-request-validator/test/data-driven/accept-an-optional-path-param.js b/packages/openapi-request-validator/test/data-driven/accept-an-optional-path-param.js index 70786380..7f0756cf 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-an-optional-path-param.js +++ b/packages/openapi-request-validator/test/data-driven/accept-an-optional-path-param.js @@ -2,17 +2,17 @@ module.exports = { validateArgs: { parameters: [ { - in: "path", - name: "path1", - type: "string" + in: 'path', + name: 'path1', + type: 'string' } ], schemas: null }, request: { - path: "/s", + path: '/s', params: { - path1: "s" + path1: 's' } } }; diff --git a/packages/openapi-request-validator/test/data-driven/accept-an-optional-query-param.js b/packages/openapi-request-validator/test/data-driven/accept-an-optional-query-param.js index 34c62150..1bdaf94a 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-an-optional-query-param.js +++ b/packages/openapi-request-validator/test/data-driven/accept-an-optional-query-param.js @@ -2,9 +2,9 @@ module.exports = { validateArgs: { parameters: [ { - in: "query", - name: "foo", - type: "string" + in: 'query', + name: 'foo', + type: 'string' } ], schemas: null diff --git a/packages/openapi-request-validator/test/data-driven/accept-custom-formats-openapi3.js b/packages/openapi-request-validator/test/data-driven/accept-custom-formats-openapi3.js index 9ef6a572..50893221 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-custom-formats-openapi3.js +++ b/packages/openapi-request-validator/test/data-driven/accept-custom-formats-openapi3.js @@ -2,25 +2,25 @@ module.exports = { validateArgs: { parameters: [ { - in: "query", - name: "foo", + in: 'query', + name: 'foo', schema: { - type: "string", - format: "foo" + type: 'string', + format: 'foo' } } ], schemas: null, customFormats: { foo: function(input) { - return input === 'foo' + return input === 'foo'; } } }, request: { - path: "?foo=foo", + path: '?foo=foo', query: { - foo: "foo" + foo: 'foo' } } }; diff --git a/packages/openapi-request-validator/test/data-driven/accept-custom-formats.js b/packages/openapi-request-validator/test/data-driven/accept-custom-formats.js index 04746230..da39d80d 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-custom-formats.js +++ b/packages/openapi-request-validator/test/data-driven/accept-custom-formats.js @@ -2,19 +2,19 @@ module.exports = { validateArgs: { parameters: [ { - in: "query", - name: "foo", - type: "string", - format: "foo" + in: 'query', + name: 'foo', + type: 'string', + format: 'foo' } ], schemas: null, customFormats: {} }, request: { - path: "?foo=foo", + path: '?foo=foo', query: { - foo: "foo" + foo: 'foo' } } }; diff --git a/packages/openapi-request-validator/test/data-driven/accept-definitions-with-id.js b/packages/openapi-request-validator/test/data-driven/accept-definitions-with-id.js index bf70a7cb..e7a80ec9 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-definitions-with-id.js +++ b/packages/openapi-request-validator/test/data-driven/accept-definitions-with-id.js @@ -3,8 +3,8 @@ module.exports = { parameters: [], schemas: [ { - id: "#/definitions/SomeString", - type: "string" + id: '#/definitions/SomeString', + type: 'string' } ] }, diff --git a/packages/openapi-request-validator/test/data-driven/accept-external-ref-in-body.js b/packages/openapi-request-validator/test/data-driven/accept-external-ref-in-body.js index dba76c03..c169cfc7 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-external-ref-in-body.js +++ b/packages/openapi-request-validator/test/data-driven/accept-external-ref-in-body.js @@ -2,48 +2,41 @@ module.exports = { validateArgs: { parameters: [ { - in: "body", - name: "foo", + in: 'body', + name: 'foo', required: true, schema: { properties: { test1: { - $ref: "http://example.com/schema1" + $ref: 'http://example.com/schema1' }, test2: { - $ref: "http://example.com/schema2#/definitions/Test" + $ref: 'http://example.com/schema2#/definitions/Test' } }, - required: [ - "test1", - "test2" - ] + required: ['test1', 'test2'] } } ], schemas: null, externalSchemas: { - "http://example.com/schema1": { + 'http://example.com/schema1': { properties: { foo: { - type: "string" + type: 'string' } }, - required: [ - "foo" - ] + required: ['foo'] }, - "http://example.com/schema2": { + 'http://example.com/schema2': { definitions: { Test: { properties: { boo: { - type: "string" + type: 'string' } }, - required: [ - "boo" - ] + required: ['boo'] } } } @@ -52,10 +45,10 @@ module.exports = { request: { body: { test1: { - foo: "asdf" + foo: 'asdf' }, test2: { - boo: "ccccc" + boo: 'ccccc' } } } diff --git a/packages/openapi-request-validator/test/data-driven/accept-external-ref-through-local-ref-in-body.js b/packages/openapi-request-validator/test/data-driven/accept-external-ref-through-local-ref-in-body.js index 2f1e3c0e..4a6be8ba 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-external-ref-through-local-ref-in-body.js +++ b/packages/openapi-request-validator/test/data-driven/accept-external-ref-through-local-ref-in-body.js @@ -1,69 +1,62 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "properties": { - "test1": { - "$ref": "#/definitions/Test1" + in: 'body', + name: 'foo', + required: true, + schema: { + properties: { + test1: { + $ref: '#/definitions/Test1' }, - "test2": { - "$ref": "#/definitions/Test2" + test2: { + $ref: '#/definitions/Test2' } }, - "required": [ - "test1", - "test2" - ] + required: ['test1', 'test2'] } } ], - "schemas": { - "Test1": { - "$ref": "http://example.com/schema1" + schemas: { + Test1: { + $ref: 'http://example.com/schema1' }, - "Test2": { - "$ref": "http://example.com/schema2#/definitions/Test" + Test2: { + $ref: 'http://example.com/schema2#/definitions/Test' } }, - "externalSchemas": { - "http://example.com/schema1": { - "properties": { - "foo": { - "type": "string" + externalSchemas: { + 'http://example.com/schema1': { + properties: { + foo: { + type: 'string' } }, - "required": [ - "foo" - ] + required: ['foo'] }, - "http://example.com/schema2": { - "definitions": { - "Test": { - "properties": { - "boo": { - "type": "string" + 'http://example.com/schema2': { + definitions: { + Test: { + properties: { + boo: { + type: 'string' } }, - "required": [ - "boo" - ] + required: ['boo'] } } } } }, - "request": { - "body": { - "test1": { - "foo": "asdf" + request: { + body: { + test1: { + foo: 'asdf' }, - "test2": { - "boo": "ccccc" + test2: { + boo: 'ccccc' } } } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/accept-file-type-parameters.js b/packages/openapi-request-validator/test/data-driven/accept-file-type-parameters.js index e602270a..b8c453f8 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-file-type-parameters.js +++ b/packages/openapi-request-validator/test/data-driven/accept-file-type-parameters.js @@ -12,7 +12,7 @@ module.exports = { }, request: { headers: { - "x-foo": "asdf" + 'x-foo': 'asdf' } } }; diff --git a/packages/openapi-request-validator/test/data-driven/accept-missing-body-when-body-is-not-required-and-body-schema-has-no-required-properties.js b/packages/openapi-request-validator/test/data-driven/accept-missing-body-when-body-is-not-required-and-body-schema-has-no-required-properties.js index 02a8c397..68424dbe 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-missing-body-when-body-is-not-required-and-body-schema-has-no-required-properties.js +++ b/packages/openapi-request-validator/test/data-driven/accept-missing-body-when-body-is-not-required-and-body-schema-has-no-required-properties.js @@ -1,39 +1,39 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "schema": { - "properties": { - "test1": { - "$ref": "#/definitions/Test1" + in: 'body', + name: 'foo', + schema: { + properties: { + test1: { + $ref: '#/definitions/Test1' }, - "test2": { - "$ref": "#/definitions/Test2" + test2: { + $ref: '#/definitions/Test2' } } } } ], - "schemas": [ + schemas: [ { - "id": "#/definitions/Test1", - "properties": { - "foo": { - "type": "string" + id: '#/definitions/Test1', + properties: { + foo: { + type: 'string' } } }, { - "id": "#/definitions/Test2", - "properties": { - "boo": { - "type": "string" + id: '#/definitions/Test2', + properties: { + boo: { + type: 'string' } } } ] }, - "request": {} -}; \ No newline at end of file + request: {} +}; diff --git a/packages/openapi-request-validator/test/data-driven/accept-multiple-header-params.js b/packages/openapi-request-validator/test/data-driven/accept-multiple-header-params.js index a842ab4f..23cd5dc8 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-multiple-header-params.js +++ b/packages/openapi-request-validator/test/data-driven/accept-multiple-header-params.js @@ -1,25 +1,25 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "header", - "name": "X-foO", - "type": "string", - "required": true + in: 'header', + name: 'X-foO', + type: 'string', + required: true }, { - "in": "header", - "name": "x-yoda", - "type": "string", - "required": true + in: 'header', + name: 'x-yoda', + type: 'string', + required: true } ], - "schemas": null + schemas: null }, - "request": { - "headers": { - "x-foo": "asdf", - "X-Yoda": "Luke" + request: { + headers: { + 'x-foo': 'asdf', + 'X-Yoda': 'Luke' } } }; diff --git a/packages/openapi-request-validator/test/data-driven/accept-multiple-local-refs-in-body-as-array.js b/packages/openapi-request-validator/test/data-driven/accept-multiple-local-refs-in-body-as-array.js index c8243468..17232048 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-multiple-local-refs-in-body-as-array.js +++ b/packages/openapi-request-validator/test/data-driven/accept-multiple-local-refs-in-body-as-array.js @@ -1,59 +1,52 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "properties": { - "test1": { - "$ref": "#/definitions/Test1" + in: 'body', + name: 'foo', + required: true, + schema: { + properties: { + test1: { + $ref: '#/definitions/Test1' }, - "test2": { - "$ref": "#/definitions/Test2" + test2: { + $ref: '#/definitions/Test2' } }, - "required": [ - "test1", - "test2" - ] + required: ['test1', 'test2'] } } ], - "schemas": [ + schemas: [ { - "id": "#/definitions/Test1", - "properties": { - "foo": { - "type": "string" + id: '#/definitions/Test1', + properties: { + foo: { + type: 'string' } }, - "required": [ - "foo" - ] + required: ['foo'] }, { - "id": "#/definitions/Test2", - "properties": { - "boo": { - "type": "string" + id: '#/definitions/Test2', + properties: { + boo: { + type: 'string' } }, - "required": [ - "boo" - ] + required: ['boo'] } ] }, - "request": { - "body": { - "test1": { - "foo": "asdf" + request: { + body: { + test1: { + foo: 'asdf' }, - "test2": { - "boo": "ccccc" + test2: { + boo: 'ccccc' } } } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/accept-multiple-local-refs-in-body-as-object.js b/packages/openapi-request-validator/test/data-driven/accept-multiple-local-refs-in-body-as-object.js index 3944a923..c456729f 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-multiple-local-refs-in-body-as-object.js +++ b/packages/openapi-request-validator/test/data-driven/accept-multiple-local-refs-in-body-as-object.js @@ -1,57 +1,50 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "properties": { - "test1": { - "$ref": "#/definitions/Test1" + in: 'body', + name: 'foo', + required: true, + schema: { + properties: { + test1: { + $ref: '#/definitions/Test1' }, - "test2": { - "$ref": "#/definitions/Test2" + test2: { + $ref: '#/definitions/Test2' } }, - "required": [ - "test1", - "test2" - ] + required: ['test1', 'test2'] } } ], - "schemas": { - "Test1": { - "properties": { - "foo": { - "type": "string" + schemas: { + Test1: { + properties: { + foo: { + type: 'string' } }, - "required": [ - "foo" - ] + required: ['foo'] }, - "Test2": { - "properties": { - "boo": { - "type": "string" + Test2: { + properties: { + boo: { + type: 'string' } }, - "required": [ - "boo" - ] + required: ['boo'] } } }, - "request": { - "body": { - "test1": { - "foo": "asdf" + request: { + body: { + test1: { + foo: 'asdf' }, - "test2": { - "boo": "ccccc" + test2: { + boo: 'ccccc' } } } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/accept-recursive-ref-in-body-as-object.js b/packages/openapi-request-validator/test/data-driven/accept-recursive-ref-in-body-as-object.js index 43366201..6c22a9d3 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-recursive-ref-in-body-as-object.js +++ b/packages/openapi-request-validator/test/data-driven/accept-recursive-ref-in-body-as-object.js @@ -1,46 +1,42 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "properties": { - "test1": { - "$ref": "#/definitions/Test1" + in: 'body', + name: 'foo', + required: true, + schema: { + properties: { + test1: { + $ref: '#/definitions/Test1' } }, - "required": [ - "test1" - ] + required: ['test1'] } } ], - "schemas": { - "Test1": { - "properties": { - "foo": { - "type": "string" + schemas: { + Test1: { + properties: { + foo: { + type: 'string' }, - "recursive": { - "$ref": "#/definitions/Test1" + recursive: { + $ref: '#/definitions/Test1' } }, - "required": [ - "foo" - ] + required: ['foo'] } } }, - "request": { - "body": { - "test1": { - "foo": "asdf", - "recursive": { - "foo": "boo" + request: { + body: { + test1: { + foo: 'asdf', + recursive: { + foo: 'boo' } } } } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/accept-requestBody.js b/packages/openapi-request-validator/test/data-driven/accept-requestBody.js index b7aa0bef..dad5f100 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-requestBody.js +++ b/packages/openapi-request-validator/test/data-driven/accept-requestBody.js @@ -2,7 +2,7 @@ module.exports = { validateArgs: { parameters: [], requestBody: { - description: "a test body", + description: 'a test body', content: { 'application/json': { schema: { @@ -20,7 +20,7 @@ module.exports = { }, request: { body: { - "foo": "asdf" + foo: 'asdf' }, headers: { 'content-type': 'application/json' diff --git a/packages/openapi-request-validator/test/data-driven/accept-schema-ref-in-body.js b/packages/openapi-request-validator/test/data-driven/accept-schema-ref-in-body.js index 170af76a..d94d5142 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-schema-ref-in-body.js +++ b/packages/openapi-request-validator/test/data-driven/accept-schema-ref-in-body.js @@ -1,31 +1,29 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "$ref": "#/definitions/Test1" + in: 'body', + name: 'foo', + required: true, + schema: { + $ref: '#/definitions/Test1' } } ], - "schemas": { - "Test1": { - "properties": { - "foo": { - "type": "string" + schemas: { + Test1: { + properties: { + foo: { + type: 'string' } }, - "required": [ - "foo" - ] + required: ['foo'] } } }, - "request": { - "body": { - "foo": "asdf" + request: { + body: { + foo: 'asdf' } } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/accept-schema-when-no-body-params.js b/packages/openapi-request-validator/test/data-driven/accept-schema-when-no-body-params.js index 837e7199..d84dc58f 100644 --- a/packages/openapi-request-validator/test/data-driven/accept-schema-when-no-body-params.js +++ b/packages/openapi-request-validator/test/data-driven/accept-schema-when-no-body-params.js @@ -1,37 +1,33 @@ module.exports = { - "validateArgs": { - "parameters": [], - "schemas": { - "Test1": { - "properties": { - "foo": { - "type": "string" + validateArgs: { + parameters: [], + schemas: { + Test1: { + properties: { + foo: { + type: 'string' } }, - "required": [ - "foo" - ] + required: ['foo'] }, - "Test2": { - "properties": { - "boo": { - "type": "string" + Test2: { + properties: { + boo: { + type: 'string' } }, - "required": [ - "boo" - ] + required: ['boo'] } } }, - "request": { - "body": { - "test1": { - "foo": "asdf" + request: { + body: { + test1: { + foo: 'asdf' }, - "test2": { - "boo": "ccccc" + test2: { + boo: 'ccccc' } } } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/fail-a-missing-body-when-a-body-param-exists.js b/packages/openapi-request-validator/test/data-driven/fail-a-missing-body-when-a-body-param-exists.js index 8b8c1025..187b5275 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-a-missing-body-when-a-body-param-exists.js +++ b/packages/openapi-request-validator/test/data-driven/fail-a-missing-body-when-a-body-param-exists.js @@ -1,26 +1,26 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "$ref": "#/definitions/TestBody" + in: 'body', + name: 'foo', + required: true, + schema: { + $ref: '#/definitions/TestBody' } } ] }, - "request": { - }, - "expectedError": { - "status": 400, - "errors": [ + request: {}, + expectedError: { + status: 400, + errors: [ { - "location": "body", - "message": "request.body was not present in the request. Is a body-parser being used?", - "schema": { - "$ref": "#/definitions/TestBody" + location: 'body', + message: + 'request.body was not present in the request. Is a body-parser being used?', + schema: { + $ref: '#/definitions/TestBody' } } ] diff --git a/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-body-property.js b/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-body-property.js index d15ea464..88093ce1 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-body-property.js +++ b/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-body-property.js @@ -1,41 +1,39 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "$ref": "#/definitions/TestBody" + in: 'body', + name: 'foo', + required: true, + schema: { + $ref: '#/definitions/TestBody' } } ], - "schemas": [ + schemas: [ { - "id": "#/definitions/TestBody", - "properties": { - "foo": { - "type": "string" + id: '#/definitions/TestBody', + properties: { + foo: { + type: 'string' } }, - "required": [ - "foo" - ] + required: ['foo'] } ] }, - "request": { - "body": {} + request: { + body: {} }, - "expectedError": { - "status": 400, - "errors": [ + expectedError: { + status: 400, + errors: [ { - "path": "foo", - "errorCode": "required.openapi.validation", - "message": "should have required property 'foo'", - "location": "body" + path: 'foo', + errorCode: 'required.openapi.validation', + message: "should have required property 'foo'", + location: 'body' } ] } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-formData-property.js b/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-formData-property.js index 4559d785..5884449b 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-formData-property.js +++ b/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-formData-property.js @@ -1,26 +1,26 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "formData", - "name": "foo", - "type": "string", - "required": true + in: 'formData', + name: 'foo', + type: 'string', + required: true } ] }, - "request": { - "body": {} + request: { + body: {} }, - "expectedError": { - "status": 400, - "errors": [ + expectedError: { + status: 400, + errors: [ { - "path": "foo", - "errorCode": "required.openapi.validation", - "message": "should have required property 'foo'", - "location": "formData" + path: 'foo', + errorCode: 'required.openapi.validation', + message: "should have required property 'foo'", + location: 'formData' } ] } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-header-param.js b/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-header-param.js index 8c6b1374..c4bc4eeb 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-header-param.js +++ b/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-header-param.js @@ -1,25 +1,25 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "header", - "name": "foo", - "type": "string", - "required": true + in: 'header', + name: 'foo', + type: 'string', + required: true } ], - "schemas": null + schemas: null }, - "request": {}, - "expectedError": { - "status": 400, - "errors": [ + request: {}, + expectedError: { + status: 400, + errors: [ { - "path": "foo", - "errorCode": "required.openapi.validation", - "message": "should have required property 'foo'", - "location": "headers" + path: 'foo', + errorCode: 'required.openapi.validation', + message: "should have required property 'foo'", + location: 'headers' } ] } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-query-param.js b/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-query-param.js index 0514d523..6080e046 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-query-param.js +++ b/packages/openapi-request-validator/test/data-driven/fail-a-missing-required-query-param.js @@ -1,25 +1,25 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "query", - "name": "foo", - "type": "string", - "required": true + in: 'query', + name: 'foo', + type: 'string', + required: true } ], - "schemas": null + schemas: null }, - "request": {}, - "expectedError": { - "status": 400, - "errors": [ + request: {}, + expectedError: { + status: 400, + errors: [ { - "path": "foo", - "errorCode": "required.openapi.validation", - "message": "should have required property 'foo'", - "location": "query" + path: 'foo', + errorCode: 'required.openapi.validation', + message: "should have required property 'foo'", + location: 'query' } ] } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/fail-an-invalid-path-param.js b/packages/openapi-request-validator/test/data-driven/fail-an-invalid-path-param.js index d1013ce5..0ab86a15 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-an-invalid-path-param.js +++ b/packages/openapi-request-validator/test/data-driven/fail-an-invalid-path-param.js @@ -1,30 +1,30 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "path", - "name": "path1", - "type": "string", - "pattern": "^a$", - "required": true + in: 'path', + name: 'path1', + type: 'string', + pattern: '^a$', + required: true } ], - "schemas": null + schemas: null }, - "request": { - "path": "/f", - "params": { - "path1": "f" + request: { + path: '/f', + params: { + path1: 'f' } }, - "expectedError": { - "status": 400, - "errors": [ + expectedError: { + status: 400, + errors: [ { - "path": "path1", - "errorCode": "pattern.openapi.validation", - "message": "should match pattern \"^a$\"", - "location": "path" + path: 'path1', + errorCode: 'pattern.openapi.validation', + message: 'should match pattern "^a$"', + location: 'path' } ] } diff --git a/packages/openapi-request-validator/test/data-driven/fail-an-unknown-ref-in-body.js b/packages/openapi-request-validator/test/data-driven/fail-an-unknown-ref-in-body.js index b39d9c87..689fae20 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-an-unknown-ref-in-body.js +++ b/packages/openapi-request-validator/test/data-driven/fail-an-unknown-ref-in-body.js @@ -1,29 +1,29 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "$ref": "#/definitions/TestBody" + in: 'body', + name: 'foo', + required: true, + schema: { + $ref: '#/definitions/TestBody' } } ] }, - "request": { - "body": {} + request: { + body: {} }, - "expectedError": { - "status": 400, - "errors": [ + expectedError: { + status: 400, + errors: [ { - "message": "can't resolve reference #/definitions/TestBody", - "schema": { - "$ref": "#/definitions/TestBody" + message: "can't resolve reference #/definitions/TestBody", + schema: { + $ref: '#/definitions/TestBody' }, - "location": "body" + location: 'body' } ] } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/fail-body-expecting-array.js b/packages/openapi-request-validator/test/data-driven/fail-body-expecting-array.js index cb046e80..aafa4af2 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-body-expecting-array.js +++ b/packages/openapi-request-validator/test/data-driven/fail-body-expecting-array.js @@ -1,27 +1,27 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "type": "array" + in: 'body', + name: 'foo', + required: true, + schema: { + type: 'array' } } ] }, - "request": { - "body": {} + request: { + body: {} }, - "expectedError": { - "status": 400, - "errors": [ + expectedError: { + status: 400, + errors: [ { - "errorCode": "type.openapi.validation", - "message": "should be array", - "location": "body" + errorCode: 'type.openapi.validation', + message: 'should be array', + location: 'body' } ] } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/fail-customFormats-for-openapi3-query-param.js b/packages/openapi-request-validator/test/data-driven/fail-customFormats-for-openapi3-query-param.js index 780fee72..a5bf7efb 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-customFormats-for-openapi3-query-param.js +++ b/packages/openapi-request-validator/test/data-driven/fail-customFormats-for-openapi3-query-param.js @@ -1,37 +1,37 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "query", - "name": "foo", - "schema": { - "type": "string", - "format": "foo", + in: 'query', + name: 'foo', + schema: { + type: 'string', + format: 'foo' }, - "required": true, + required: true } ], - "schemas": null, - "customFormats": { + schemas: null, + customFormats: { foo: function(input) { - return input === 'foo' + return input === 'foo'; } } }, - "request": { - "path": "?foo=boo", - "query": { - "foo": "boo" + request: { + path: '?foo=boo', + query: { + foo: 'boo' } }, - "expectedError": { - "status": 400, - "errors": [ + expectedError: { + status: 400, + errors: [ { - "path": "foo", - "errorCode": "format.openapi.validation", - "message": "should match format \"foo\"", - "location": "query" + path: 'foo', + errorCode: 'format.openapi.validation', + message: 'should match format "foo"', + location: 'query' } ] } diff --git a/packages/openapi-request-validator/test/data-driven/fail-customFormats.js b/packages/openapi-request-validator/test/data-driven/fail-customFormats.js index 7c0ede8e..161d1ff1 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-customFormats.js +++ b/packages/openapi-request-validator/test/data-driven/fail-customFormats.js @@ -1,35 +1,35 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "query", - "name": "foo", - "type": "string", - "required": true, - "format": "foo" + in: 'query', + name: 'foo', + type: 'string', + required: true, + format: 'foo' } ], - "schemas": null, - "customFormats": { + schemas: null, + customFormats: { foo: function(input) { - return input === 'foo' + return input === 'foo'; } } }, - "request": { - "path": "?foo=boo", - "query": { - "foo": "boo" + request: { + path: '?foo=boo', + query: { + foo: 'boo' } }, - "expectedError": { - "status": 400, - "errors": [ + expectedError: { + status: 400, + errors: [ { - "path": "foo", - "errorCode": "format.openapi.validation", - "message": "should match format \"foo\"", - "location": "query" + path: 'foo', + errorCode: 'format.openapi.validation', + message: 'should match format "foo"', + location: 'query' } ] } diff --git a/packages/openapi-request-validator/test/data-driven/fail-external-ref-in-body.js b/packages/openapi-request-validator/test/data-driven/fail-external-ref-in-body.js index 0e74b843..f6270a54 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-external-ref-in-body.js +++ b/packages/openapi-request-validator/test/data-driven/fail-external-ref-in-body.js @@ -1,72 +1,65 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "properties": { - "test1": { - "$ref": "http://example.com/schema1" + in: 'body', + name: 'foo', + required: true, + schema: { + properties: { + test1: { + $ref: 'http://example.com/schema1' }, - "test2": { - "$ref": "http://example.com/schema2#/definitions/Test" + test2: { + $ref: 'http://example.com/schema2#/definitions/Test' } }, - "required": [ - "test1", - "test2" - ] + required: ['test1', 'test2'] } } ], - "schemas": null, - "externalSchemas": { - "http://example.com/schema1": { - "properties": { - "foo": { - "type": "string" + schemas: null, + externalSchemas: { + 'http://example.com/schema1': { + properties: { + foo: { + type: 'string' } }, - "required": [ - "foo" - ] + required: ['foo'] }, - "http://example.com/schema2": { - "definitions": { - "Test": { - "properties": { - "boo": { - "type": "string" + 'http://example.com/schema2': { + definitions: { + Test: { + properties: { + boo: { + type: 'string' } }, - "required": [ - "boo" - ] + required: ['boo'] } } } } }, - "request": { - "body": {} + request: { + body: {} }, - "expectedError": { - "status": 400, - "errors": [ + expectedError: { + status: 400, + errors: [ { - "path": "test1", - "errorCode": "required.openapi.validation", - "message": "should have required property 'test1'", - "location": "body" + path: 'test1', + errorCode: 'required.openapi.validation', + message: "should have required property 'test1'", + location: 'body' }, { - "path": "test2", - "errorCode": "required.openapi.validation", - "message": "should have required property 'test2'", - "location": "body" + path: 'test2', + errorCode: 'required.openapi.validation', + message: "should have required property 'test2'", + location: 'body' } ] } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/fail-external-ref-through-local-ref-in-body.js b/packages/openapi-request-validator/test/data-driven/fail-external-ref-through-local-ref-in-body.js index a0cd9f9a..4edd23fd 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-external-ref-through-local-ref-in-body.js +++ b/packages/openapi-request-validator/test/data-driven/fail-external-ref-through-local-ref-in-body.js @@ -1,79 +1,72 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "properties": { - "test1": { - "$ref": "#/definitions/Test1" + in: 'body', + name: 'foo', + required: true, + schema: { + properties: { + test1: { + $ref: '#/definitions/Test1' }, - "test2": { - "$ref": "#/definitions/Test2" + test2: { + $ref: '#/definitions/Test2' } }, - "required": [ - "test1", - "test2" - ] + required: ['test1', 'test2'] } } ], - "schemas": { - "Test1": { - "$ref": "http://example.com/schema1" + schemas: { + Test1: { + $ref: 'http://example.com/schema1' }, - "Test2": { - "$ref": "http://example.com/schema2#/definitions/Test" + Test2: { + $ref: 'http://example.com/schema2#/definitions/Test' } }, - "externalSchemas": { - "http://example.com/schema1": { - "properties": { - "foo": { - "type": "string" + externalSchemas: { + 'http://example.com/schema1': { + properties: { + foo: { + type: 'string' } }, - "required": [ - "foo" - ] + required: ['foo'] }, - "http://example.com/schema2": { - "definitions": { - "Test": { - "properties": { - "boo": { - "type": "string" + 'http://example.com/schema2': { + definitions: { + Test: { + properties: { + boo: { + type: 'string' } }, - "required": [ - "boo" - ] + required: ['boo'] } } } } }, - "request": { - "body": {} + request: { + body: {} }, - "expectedError": { - "status": 400, - "errors": [ + expectedError: { + status: 400, + errors: [ { - "path": "test1", - "errorCode": "required.openapi.validation", - "message": "should have required property 'test1'", - "location": "body" + path: 'test1', + errorCode: 'required.openapi.validation', + message: "should have required property 'test1'", + location: 'body' }, { - "path": "test2", - "errorCode": "required.openapi.validation", - "message": "should have required property 'test2'", - "location": "body" + path: 'test2', + errorCode: 'required.openapi.validation', + message: "should have required property 'test2'", + location: 'body' } ] } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/fail-missing-path-params.js b/packages/openapi-request-validator/test/data-driven/fail-missing-path-params.js index d994b589..596ebccc 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-missing-path-params.js +++ b/packages/openapi-request-validator/test/data-driven/fail-missing-path-params.js @@ -1,26 +1,26 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "path", - "name": "path1", - "type": "string", - "required": true + in: 'path', + name: 'path1', + type: 'string', + required: true } ], - "schemas": null + schemas: null }, - "request": { - "path": "/f" + request: { + path: '/f' }, - "expectedError": { - "status": 400, - "errors": [ + expectedError: { + status: 400, + errors: [ { - "path": "path1", - "errorCode": "required.openapi.validation", - "message": "should have required property 'path1'", - "location": "path" + path: 'path1', + errorCode: 'required.openapi.validation', + message: "should have required property 'path1'", + location: 'path' } ] } diff --git a/packages/openapi-request-validator/test/data-driven/fail-multiple-invalid-path-params.js b/packages/openapi-request-validator/test/data-driven/fail-multiple-invalid-path-params.js index f457cc77..dd086225 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-multiple-invalid-path-params.js +++ b/packages/openapi-request-validator/test/data-driven/fail-multiple-invalid-path-params.js @@ -1,45 +1,45 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "path", - "name": "path1", - "type": "string", - "pattern": "^a$", - "required": true + in: 'path', + name: 'path1', + type: 'string', + pattern: '^a$', + required: true }, { - "in": "path", - "name": "path2", - "type": "string", - "pattern": "^f$", - "required": true + in: 'path', + name: 'path2', + type: 'string', + pattern: '^f$', + required: true } ], - "schemas": null + schemas: null }, - "request": { - "path": "/f/a", - "params": { - "path1": "f", - "path2": "a" + request: { + path: '/f/a', + params: { + path1: 'f', + path2: 'a' } }, - "expectedError": { - "status": 400, - "errors": [ + expectedError: { + status: 400, + errors: [ { - "path": "path1", - "errorCode": "pattern.openapi.validation", - "message": "should match pattern \"^a$\"", - "location": "path" + path: 'path1', + errorCode: 'pattern.openapi.validation', + message: 'should match pattern "^a$"', + location: 'path' }, { - "path": "path2", - "errorCode": "pattern.openapi.validation", - "message": "should match pattern \"^f$\"", - "location": "path" + path: 'path2', + errorCode: 'pattern.openapi.validation', + message: 'should match pattern "^f$"', + location: 'path' } ] } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/fail-multiple-local-refs-in-body.js b/packages/openapi-request-validator/test/data-driven/fail-multiple-local-refs-in-body.js index 0b40a63c..84beda9c 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-multiple-local-refs-in-body.js +++ b/packages/openapi-request-validator/test/data-driven/fail-multiple-local-refs-in-body.js @@ -1,69 +1,62 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "properties": { - "test1": { - "$ref": "#/definitions/Test1" + in: 'body', + name: 'foo', + required: true, + schema: { + properties: { + test1: { + $ref: '#/definitions/Test1' }, - "test2": { - "$ref": "#/definitions/Test2" + test2: { + $ref: '#/definitions/Test2' } }, - "required": [ - "test1", - "test2" - ] + required: ['test1', 'test2'] } } ], - "schemas": [ + schemas: [ { - "id": "#/definitions/Test1", - "properties": { - "foo": { - "type": "string" + id: '#/definitions/Test1', + properties: { + foo: { + type: 'string' } }, - "required": [ - "test1" - ] + required: ['test1'] }, { - "id": "#/definitions/Test2", - "properties": { - "boo": { - "type": "string" + id: '#/definitions/Test2', + properties: { + boo: { + type: 'string' } }, - "required": [ - "test2" - ] + required: ['test2'] } ] }, - "request": { - "body": {} + request: { + body: {} }, - "expectedError": { - "status": 400, - "errors": [ + expectedError: { + status: 400, + errors: [ { - "path": "test1", - "errorCode": "required.openapi.validation", - "message": "should have required property 'test1'", - "location": "body" + path: 'test1', + errorCode: 'required.openapi.validation', + message: "should have required property 'test1'", + location: 'body' }, { - "path": "test2", - "errorCode": "required.openapi.validation", - "message": "should have required property 'test2'", - "location": "body" + path: 'test2', + errorCode: 'required.openapi.validation', + message: "should have required property 'test2'", + location: 'body' } ] } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/fail-multiple-missing-local-refs-in-body.js b/packages/openapi-request-validator/test/data-driven/fail-multiple-missing-local-refs-in-body.js index 0b40a63c..84beda9c 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-multiple-missing-local-refs-in-body.js +++ b/packages/openapi-request-validator/test/data-driven/fail-multiple-missing-local-refs-in-body.js @@ -1,69 +1,62 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "properties": { - "test1": { - "$ref": "#/definitions/Test1" + in: 'body', + name: 'foo', + required: true, + schema: { + properties: { + test1: { + $ref: '#/definitions/Test1' }, - "test2": { - "$ref": "#/definitions/Test2" + test2: { + $ref: '#/definitions/Test2' } }, - "required": [ - "test1", - "test2" - ] + required: ['test1', 'test2'] } } ], - "schemas": [ + schemas: [ { - "id": "#/definitions/Test1", - "properties": { - "foo": { - "type": "string" + id: '#/definitions/Test1', + properties: { + foo: { + type: 'string' } }, - "required": [ - "test1" - ] + required: ['test1'] }, { - "id": "#/definitions/Test2", - "properties": { - "boo": { - "type": "string" + id: '#/definitions/Test2', + properties: { + boo: { + type: 'string' } }, - "required": [ - "test2" - ] + required: ['test2'] } ] }, - "request": { - "body": {} + request: { + body: {} }, - "expectedError": { - "status": 400, - "errors": [ + expectedError: { + status: 400, + errors: [ { - "path": "test1", - "errorCode": "required.openapi.validation", - "message": "should have required property 'test1'", - "location": "body" + path: 'test1', + errorCode: 'required.openapi.validation', + message: "should have required property 'test1'", + location: 'body' }, { - "path": "test2", - "errorCode": "required.openapi.validation", - "message": "should have required property 'test2'", - "location": "body" + path: 'test2', + errorCode: 'required.openapi.validation', + message: "should have required property 'test2'", + location: 'body' } ] } -}; \ No newline at end of file +}; diff --git a/packages/openapi-request-validator/test/data-driven/fail-recursive-ref-in-body-as-object.js b/packages/openapi-request-validator/test/data-driven/fail-recursive-ref-in-body-as-object.js index 707947a7..4d6d3cc0 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-recursive-ref-in-body-as-object.js +++ b/packages/openapi-request-validator/test/data-driven/fail-recursive-ref-in-body-as-object.js @@ -1,44 +1,40 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "properties": { - "test1": { - "$ref": "#/definitions/Test1" + in: 'body', + name: 'foo', + required: true, + schema: { + properties: { + test1: { + $ref: '#/definitions/Test1' } }, - "required": [ - "test1" - ] + required: ['test1'] } } ], - "schemas": { - "Test1": { - "properties": { - "foo": { - "type": "string" + schemas: { + Test1: { + properties: { + foo: { + type: 'string' }, - "recursive": { - "$ref": "#/definitions/Test1" + recursive: { + $ref: '#/definitions/Test1' } }, - "required": [ - "foo" - ] + required: ['foo'] } } }, - "request": { - "body": { - "test1": { - "foo": "asdf", - "recursive": { - "foo": 5 + request: { + body: { + test1: { + foo: 'asdf', + recursive: { + foo: 5 } } } diff --git a/packages/openapi-request-validator/test/data-driven/fail-schema-ref-in-body.js b/packages/openapi-request-validator/test/data-driven/fail-schema-ref-in-body.js index 0d51dbf8..fb9af102 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-schema-ref-in-body.js +++ b/packages/openapi-request-validator/test/data-driven/fail-schema-ref-in-body.js @@ -1,43 +1,40 @@ module.exports = { - "validateArgs": { - "parameters": [ + validateArgs: { + parameters: [ { - "in": "body", - "name": "foo", - "required": true, - "schema": { - "$ref": "#/definitions/Test1" + in: 'body', + name: 'foo', + required: true, + schema: { + $ref: '#/definitions/Test1' } } ], - "schemas": { - "Test1": { - "properties": { - "foo": { - "type": "string" + schemas: { + Test1: { + properties: { + foo: { + type: 'string' } }, - "required": [ - "foo" - ] + required: ['foo'] } } }, - "request": { - "body": {} + request: { + body: {} }, expectedError: { - 'status': 400, - 'errors': [ + status: 400, + errors: [ { - 'path': 'foo', - 'errorCode': 'required.openapi.validation', - 'message': 'should have required property \'foo\'', - 'location': 'body' + path: 'foo', + errorCode: 'required.openapi.validation', + message: "should have required property 'foo'", + location: 'body' } ] } - }; diff --git a/packages/openapi-request-validator/test/data-driven/fail-unsupported-media-type-for-request-body.js b/packages/openapi-request-validator/test/data-driven/fail-unsupported-media-type-for-request-body.js index cc473190..05e3e071 100644 --- a/packages/openapi-request-validator/test/data-driven/fail-unsupported-media-type-for-request-body.js +++ b/packages/openapi-request-validator/test/data-driven/fail-unsupported-media-type-for-request-body.js @@ -1,33 +1,31 @@ module.exports = { - "validateArgs": { - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "foo": { - "type": "string" + validateArgs: { + parameters: [], + requestBody: { + content: { + 'application/json': { + schema: { + properties: { + foo: { + type: 'string' } }, - "required": [ - "foo" - ] + required: ['foo'] } } } - }, + } }, - "request": { - "headers": { - "content-type": "text/plain" + request: { + headers: { + 'content-type': 'text/plain' } }, - "expectedError": { - "status": 415, - "errors": [ + expectedError: { + status: 415, + errors: [ { - "message": "Unsupported Content-Type text/plain", + message: 'Unsupported Content-Type text/plain' } ] } diff --git a/packages/openapi-request-validator/test/data-driven/throw-error-when-args-is-not-given.js b/packages/openapi-request-validator/test/data-driven/throw-error-when-args-is-not-given.js index fa48ba57..92d980c1 100644 --- a/packages/openapi-request-validator/test/data-driven/throw-error-when-args-is-not-given.js +++ b/packages/openapi-request-validator/test/data-driven/throw-error-when-args-is-not-given.js @@ -1,5 +1,5 @@ module.exports = { - "validateArgs": null, - "request": {}, - constructorError: /missing args argument/, + validateArgs: null, + request: {}, + constructorError: /missing args argument/ }; diff --git a/packages/openapi-request-validator/test/data-driven/throw-error-when-customFormats-are-not-functions.js b/packages/openapi-request-validator/test/data-driven/throw-error-when-customFormats-are-not-functions.js index 68764c5e..d9a1adda 100644 --- a/packages/openapi-request-validator/test/data-driven/throw-error-when-customFormats-are-not-functions.js +++ b/packages/openapi-request-validator/test/data-driven/throw-error-when-customFormats-are-not-functions.js @@ -1,11 +1,11 @@ module.exports = { - "validateArgs": { + validateArgs: { loggingKey: 'express-openapi-validation', - "parameters": [], + parameters: [], customFormats: { foo: 'asdf' } }, - "request": {}, - constructorError: /args.customFormats properties must be functions/, + request: {}, + constructorError: /args.customFormats properties must be functions/ }; diff --git a/packages/openapi-request-validator/test/data-driven/throw-error-when-parameters-is-not-an-array.js b/packages/openapi-request-validator/test/data-driven/throw-error-when-parameters-is-not-an-array.js index 68dda629..d7fbbb93 100644 --- a/packages/openapi-request-validator/test/data-driven/throw-error-when-parameters-is-not-an-array.js +++ b/packages/openapi-request-validator/test/data-driven/throw-error-when-parameters-is-not-an-array.js @@ -1,8 +1,8 @@ module.exports = { - "validateArgs": { + validateArgs: { loggingKey: 'express-openapi-validation', - "parameters": null + parameters: null }, - "request": {}, - constructorError: /express-openapi-validation: args.parameters must be an Array/, + request: {}, + constructorError: /express-openapi-validation: args.parameters must be an Array/ }; diff --git a/packages/openapi-request-validator/test/data-driven/use-errorTransformer-to-format-errors.js b/packages/openapi-request-validator/test/data-driven/use-errorTransformer-to-format-errors.js index 80ae39ae..293f1bd5 100644 --- a/packages/openapi-request-validator/test/data-driven/use-errorTransformer-to-format-errors.js +++ b/packages/openapi-request-validator/test/data-driven/use-errorTransformer-to-format-errors.js @@ -2,9 +2,9 @@ module.exports = { validateArgs: { parameters: [ { - in: "query", - name: "foo", - type: "string", + in: 'query', + name: 'foo', + type: 'string', required: true } ], @@ -13,11 +13,9 @@ module.exports = { return arguments.length; } }, - "request": {}, - "expectedError": { - "status": 400, - "errors": [ - 2 - ] + request: {}, + expectedError: { + status: 400, + errors: [2] } }; diff --git a/packages/openapi-request-validator/test/data-driven/use-given-media-type-schema-for-requestBody.js b/packages/openapi-request-validator/test/data-driven/use-given-media-type-schema-for-requestBody.js index 6d867e0f..845f415f 100644 --- a/packages/openapi-request-validator/test/data-driven/use-given-media-type-schema-for-requestBody.js +++ b/packages/openapi-request-validator/test/data-driven/use-given-media-type-schema-for-requestBody.js @@ -1,46 +1,41 @@ module.exports = { - "validateArgs": { - "parameters": [] + validateArgs: { + parameters: [] }, requestBody: { - "content": { - "application/foo1+json": { - "schema": { - "properties": { - "name": { - "type": "string" + content: { + 'application/foo1+json': { + schema: { + properties: { + name: { + type: 'string' } }, - "required": [ - "name" - ] + required: ['name'] } }, - "application/foo2+json": { - "schema": { - "properties": { - "first_name": { - "type": "string" + 'application/foo2+json': { + schema: { + properties: { + first_name: { + type: 'string' }, - "last_name": { - "type": "string" + last_name: { + type: 'string' } }, - "required": [ - "first_name", - "last_name" - ] + required: ['first_name', 'last_name'] } } } }, - "request": { - "headers": { - "content-type": "application/foo2+json" + request: { + headers: { + 'content-type': 'application/foo2+json' }, - "body": { - "first_name": "foo", - "last_name": "bar" + body: { + first_name: 'foo', + last_name: 'bar' } } }; diff --git a/packages/openapi-request-validator/test/data-driven/warn-for-definition-with-no-id.js b/packages/openapi-request-validator/test/data-driven/warn-for-definition-with-no-id.js index 43879ef0..f06deefe 100644 --- a/packages/openapi-request-validator/test/data-driven/warn-for-definition-with-no-id.js +++ b/packages/openapi-request-validator/test/data-driven/warn-for-definition-with-no-id.js @@ -1,11 +1,11 @@ module.exports = { - "validateArgs": { - "parameters": [], - "schemas": [ + validateArgs: { + parameters: [], + schemas: [ { - "type": "string" + type: 'string' } ] }, - "request": {} -}; \ No newline at end of file + request: {} +}; diff --git a/packages/openapi-request-validator/test/tests.ts b/packages/openapi-request-validator/test/tests.ts index 10fffa9a..6f588f59 100644 --- a/packages/openapi-request-validator/test/tests.ts +++ b/packages/openapi-request-validator/test/tests.ts @@ -4,7 +4,8 @@ import Sut from '../'; describe(require('../package.json').name, () => { it('should not modify the input parameters', () => { const initialArguments = createArguments(); - //@ts-ignore + /* tslint:disable:no-unused-expression */ + // @ts-ignore new Sut(initialArguments); expect(initialArguments).to.eql(createArguments()); }); diff --git a/packages/openapi-response-validator/test/data-driven.ts b/packages/openapi-response-validator/test/data-driven.ts index e23eb112..58bc5125 100644 --- a/packages/openapi-response-validator/test/data-driven.ts +++ b/packages/openapi-response-validator/test/data-driven.ts @@ -5,20 +5,24 @@ const baseDir = path.resolve(__dirname, 'data-driven'); import Sut from '../'; describe(require('../package.json').name, () => { - glob.sync('*.js', {cwd: baseDir}).forEach(fixture => { + glob.sync('*.js', { cwd: baseDir }).forEach(fixture => { const testName = path.basename(fixture, '.js').replace(/-/g, ' '); fixture = require(path.resolve(baseDir, fixture)); it(`should ${testName}`, () => { if (fixture.constructorError) { expect(() => { + /* tslint:disable-next-line:no-unused-expression */ new Sut(fixture.constructorArgs); }).to.throw(fixture.constructorError); return; } const instance = new Sut(fixture.constructorArgs); - const error = instance.validateResponse(fixture.inputStatusCode, fixture.inputResponseBody); + const error = instance.validateResponse( + fixture.inputStatusCode, + fixture.inputResponseBody + ); expect(error).to.eql(fixture.expectedValidationError); }); }); diff --git a/packages/openapi-response-validator/test/data-driven/accept-customFormats.js b/packages/openapi-response-validator/test/data-driven/accept-customFormats.js index b7285ca0..aec0d4a8 100644 --- a/packages/openapi-response-validator/test/data-driven/accept-customFormats.js +++ b/packages/openapi-response-validator/test/data-driven/accept-customFormats.js @@ -24,7 +24,7 @@ module.exports = { }, inputStatusCode: 200, - inputResponseBody: {foo: 'foo'}, + inputResponseBody: { foo: 'foo' }, expectedValidationError: void 0 }; diff --git a/packages/openapi-response-validator/test/data-driven/accept-definition-references.js b/packages/openapi-response-validator/test/data-driven/accept-definition-references.js index 060a138d..16e2b659 100644 --- a/packages/openapi-response-validator/test/data-driven/accept-definition-references.js +++ b/packages/openapi-response-validator/test/data-driven/accept-definition-references.js @@ -21,7 +21,7 @@ module.exports = { }, inputStatusCode: 200, - inputResponseBody: {foo: 'asdf'}, + inputResponseBody: { foo: 'asdf' }, expectedValidationError: void 0 }; diff --git a/packages/openapi-response-validator/test/data-driven/accept-external-references-through-local-ref.js b/packages/openapi-response-validator/test/data-driven/accept-external-references-through-local-ref.js index 718a8fe2..7567794c 100644 --- a/packages/openapi-response-validator/test/data-driven/accept-external-references-through-local-ref.js +++ b/packages/openapi-response-validator/test/data-driven/accept-external-references-through-local-ref.js @@ -1,34 +1,33 @@ module.exports = { - constructorArgs: { - responses: { - 200: { - schema: { - type: 'object', - properties: { - foo: { - $ref: '#/definitions/foo' - } - } - } - } - }, - - definitions: { + constructorArgs: { + responses: { + 200: { + schema: { + type: 'object', + properties: { foo: { - $ref: 'http://example.com/schema' - } - }, - - externalSchemas: { - 'http://example.com/schema': { - type: 'string' + $ref: '#/definitions/foo' } + } } + } }, - inputStatusCode: 200, - inputResponseBody: {foo: 'asdf'}, + definitions: { + foo: { + $ref: 'http://example.com/schema' + } + }, - expectedValidationError: void 0 -}; + externalSchemas: { + 'http://example.com/schema': { + type: 'string' + } + } + }, + inputStatusCode: 200, + inputResponseBody: { foo: 'asdf' }, + + expectedValidationError: void 0 +}; diff --git a/packages/openapi-response-validator/test/data-driven/accept-external-references-with-path-through-local-ref.js b/packages/openapi-response-validator/test/data-driven/accept-external-references-with-path-through-local-ref.js index 2bc91a11..489e66d6 100644 --- a/packages/openapi-response-validator/test/data-driven/accept-external-references-with-path-through-local-ref.js +++ b/packages/openapi-response-validator/test/data-driven/accept-external-references-with-path-through-local-ref.js @@ -1,38 +1,37 @@ module.exports = { - constructorArgs: { - responses: { - 200: { - schema: { - type: 'object', - properties: { - foo: { - $ref: '#/definitions/foo' - } - } - } - } - }, - - definitions: { + constructorArgs: { + responses: { + 200: { + schema: { + type: 'object', + properties: { foo: { - $ref: 'http://example.com/schema#/definitions/foo' - } - }, - - externalSchemas: { - 'http://example.com/schema': { - definitions: { - foo: { - type: 'string' - } - } + $ref: '#/definitions/foo' } + } } + } }, - inputStatusCode: 200, - inputResponseBody: {foo: 'asdf'}, + definitions: { + foo: { + $ref: 'http://example.com/schema#/definitions/foo' + } + }, - expectedValidationError: void 0 -}; + externalSchemas: { + 'http://example.com/schema': { + definitions: { + foo: { + type: 'string' + } + } + } + } + }, + inputStatusCode: 200, + inputResponseBody: { foo: 'asdf' }, + + expectedValidationError: void 0 +}; diff --git a/packages/openapi-response-validator/test/data-driven/accept-external-references-with-path.js b/packages/openapi-response-validator/test/data-driven/accept-external-references-with-path.js index 130aed7e..1e937323 100644 --- a/packages/openapi-response-validator/test/data-driven/accept-external-references-with-path.js +++ b/packages/openapi-response-validator/test/data-driven/accept-external-references-with-path.js @@ -1,34 +1,33 @@ module.exports = { - constructorArgs: { - responses: { - 200: { - schema: { - type: 'object', - properties: { - foo: { - $ref: 'http://example.com/schema#/definitions/foo' - } - } - } + constructorArgs: { + responses: { + 200: { + schema: { + type: 'object', + properties: { + foo: { + $ref: 'http://example.com/schema#/definitions/foo' } - }, + } + } + } + }, - definitions: null, + definitions: null, - externalSchemas: { - 'http://example.com/schema': { - definitions: { - foo: { - type: 'string' - } - } - } + externalSchemas: { + 'http://example.com/schema': { + definitions: { + foo: { + type: 'string' + } } - }, + } + } + }, - inputStatusCode: 200, - inputResponseBody: {foo: 'asdf'}, + inputStatusCode: 200, + inputResponseBody: { foo: 'asdf' }, - expectedValidationError: void 0 + expectedValidationError: void 0 }; - diff --git a/packages/openapi-response-validator/test/data-driven/accept-external-references.js b/packages/openapi-response-validator/test/data-driven/accept-external-references.js index f8d52922..c4a554bd 100644 --- a/packages/openapi-response-validator/test/data-driven/accept-external-references.js +++ b/packages/openapi-response-validator/test/data-driven/accept-external-references.js @@ -1,30 +1,29 @@ module.exports = { - constructorArgs: { - responses: { - 200: { - schema: { - type: 'object', - properties: { - foo: { - $ref: 'http://example.com/schema' - } - } - } - } - }, - - definitions: null, - - externalSchemas: { - 'http://example.com/schema': { - type: 'string' + constructorArgs: { + responses: { + 200: { + schema: { + type: 'object', + properties: { + foo: { + $ref: 'http://example.com/schema' } + } } + } }, - inputStatusCode: 200, - inputResponseBody: {foo: 'asdf'}, + definitions: null, - expectedValidationError: void 0 -}; + externalSchemas: { + 'http://example.com/schema': { + type: 'string' + } + } + }, + + inputStatusCode: 200, + inputResponseBody: { foo: 'asdf' }, + expectedValidationError: void 0 +}; diff --git a/packages/openapi-response-validator/test/data-driven/accept-nullable-properties.js b/packages/openapi-response-validator/test/data-driven/accept-nullable-properties.js index c376a59d..d9b56521 100644 --- a/packages/openapi-response-validator/test/data-driven/accept-nullable-properties.js +++ b/packages/openapi-response-validator/test/data-driven/accept-nullable-properties.js @@ -1,31 +1,29 @@ module.exports = { constructorArgs: { responses: { - "200": { - description: "Ok", - schema: { - "type": "object", - "properties": { - "msisdn": { - "type": "string" - }, - "countryId": { - "type": "string", - "nullable": true - } - }, - "required": [ - "msisdn" - ] - } + '200': { + description: 'Ok', + schema: { + type: 'object', + properties: { + msisdn: { + type: 'string' + }, + countryId: { + type: 'string', + nullable: true + } + }, + required: ['msisdn'] + } } - }, + }, definitions: null }, inputStatusCode: 200, - inputResponseBody: {"msisdn":"790000000000","countryId":null}, + inputResponseBody: { msisdn: '790000000000', countryId: null }, expectedValidationError: void 0 }; diff --git a/packages/openapi-response-validator/test/data-driven/accept-openapi3-responses.js b/packages/openapi-response-validator/test/data-driven/accept-openapi3-responses.js index 4fd5df8f..a320b94d 100644 --- a/packages/openapi-response-validator/test/data-driven/accept-openapi3-responses.js +++ b/packages/openapi-response-validator/test/data-driven/accept-openapi3-responses.js @@ -2,9 +2,9 @@ module.exports = { constructorArgs: { responses: { 200: { - description: "Ok", + description: 'Ok', content: { - "application/json": { + 'application/json': { schema: { type: 'object', properties: { @@ -22,7 +22,7 @@ module.exports = { inputStatusCode: 200, - inputResponseBody: {foo: 'asdf'}, + inputResponseBody: { foo: 'asdf' }, expectedValidationError: void 0 }; diff --git a/packages/openapi-response-validator/test/data-driven/accept-openapi3-with-ref-responses.js b/packages/openapi-response-validator/test/data-driven/accept-openapi3-with-ref-responses.js index f4956193..769e99bb 100644 --- a/packages/openapi-response-validator/test/data-driven/accept-openapi3-with-ref-responses.js +++ b/packages/openapi-response-validator/test/data-driven/accept-openapi3-with-ref-responses.js @@ -2,11 +2,11 @@ module.exports = { constructorArgs: { responses: { 200: { - description: "Ok", + description: 'Ok', content: { - "application/json": { + 'application/json': { schema: { - '$ref': '#/components/schemas/Foo' + $ref: '#/components/schemas/Foo' } } } @@ -24,12 +24,12 @@ module.exports = { } } } - }, + } }, inputStatusCode: 200, - inputResponseBody: {id: 'asdf'}, + inputResponseBody: { id: 'asdf' }, expectedValidationError: void 0 }; diff --git a/packages/openapi-response-validator/test/data-driven/accept-valid-responses.js b/packages/openapi-response-validator/test/data-driven/accept-valid-responses.js index ce432e1e..fadf8053 100644 --- a/packages/openapi-response-validator/test/data-driven/accept-valid-responses.js +++ b/packages/openapi-response-validator/test/data-driven/accept-valid-responses.js @@ -17,7 +17,7 @@ module.exports = { }, inputStatusCode: 200, - inputResponseBody: {foo: 'asdf'}, + inputResponseBody: { foo: 'asdf' }, expectedValidationError: void 0 }; diff --git a/packages/openapi-response-validator/test/data-driven/fail-any-response-with-undefined-schema.js b/packages/openapi-response-validator/test/data-driven/fail-any-response-with-undefined-schema.js index 67bfe8ac..82c2a066 100644 --- a/packages/openapi-response-validator/test/data-driven/fail-any-response-with-undefined-schema.js +++ b/packages/openapi-response-validator/test/data-driven/fail-any-response-with-undefined-schema.js @@ -12,15 +12,14 @@ module.exports = { } }, - 400: { - } + 400: {} }, definitions: null }, inputStatusCode: 400, - inputResponseBody: {foo: 2345}, + inputResponseBody: { foo: 2345 }, expectedValidationError: { message: 'The response was not valid.', diff --git a/packages/openapi-response-validator/test/data-driven/fail-customFormats.js b/packages/openapi-response-validator/test/data-driven/fail-customFormats.js index 13df7281..14d1efe7 100644 --- a/packages/openapi-response-validator/test/data-driven/fail-customFormats.js +++ b/packages/openapi-response-validator/test/data-driven/fail-customFormats.js @@ -24,7 +24,7 @@ module.exports = { }, inputStatusCode: 200, - inputResponseBody: {foo: 2345}, + inputResponseBody: { foo: 2345 }, expectedValidationError: { message: 'The response was not valid.', diff --git a/packages/openapi-response-validator/test/data-driven/fail-invalid-response.js b/packages/openapi-response-validator/test/data-driven/fail-invalid-response.js index dc6def79..709553f3 100644 --- a/packages/openapi-response-validator/test/data-driven/fail-invalid-response.js +++ b/packages/openapi-response-validator/test/data-driven/fail-invalid-response.js @@ -17,7 +17,7 @@ module.exports = { }, inputStatusCode: 200, - inputResponseBody: {foo: 2345}, + inputResponseBody: { foo: 2345 }, expectedValidationError: { message: 'The response was not valid.', diff --git a/packages/openapi-response-validator/test/data-driven/fail-response-against-undefined-schema.js b/packages/openapi-response-validator/test/data-driven/fail-response-against-undefined-schema.js index 2073f564..d92f9922 100644 --- a/packages/openapi-response-validator/test/data-driven/fail-response-against-undefined-schema.js +++ b/packages/openapi-response-validator/test/data-driven/fail-response-against-undefined-schema.js @@ -6,7 +6,7 @@ module.exports = { }, inputStatusCode: 200, - inputResponseBody: {foo: 'asdf'}, + inputResponseBody: { foo: 'asdf' }, expectedValidationError: { message: 'The response was not valid.', diff --git a/packages/openapi-response-validator/test/data-driven/fail-with-definition-references.js b/packages/openapi-response-validator/test/data-driven/fail-with-definition-references.js index aad76337..52945fd5 100644 --- a/packages/openapi-response-validator/test/data-driven/fail-with-definition-references.js +++ b/packages/openapi-response-validator/test/data-driven/fail-with-definition-references.js @@ -21,7 +21,7 @@ module.exports = { }, inputStatusCode: 200, - inputResponseBody: {foo: 345}, + inputResponseBody: { foo: 345 }, expectedValidationError: { message: 'The response was not valid.', diff --git a/packages/openapi-response-validator/test/data-driven/fail-with-external-references-through-local-ref.js b/packages/openapi-response-validator/test/data-driven/fail-with-external-references-through-local-ref.js index f00ac429..c83e5e33 100644 --- a/packages/openapi-response-validator/test/data-driven/fail-with-external-references-through-local-ref.js +++ b/packages/openapi-response-validator/test/data-driven/fail-with-external-references-through-local-ref.js @@ -1,43 +1,42 @@ module.exports = { - constructorArgs: { - responses: { - 200: { - schema: { - type: 'object', - properties: { - foo: { - $ref: '#/definitions/foo' - } - } - } - } - }, - - definitions: { + constructorArgs: { + responses: { + 200: { + schema: { + type: 'object', + properties: { foo: { - $ref: 'http://example.com/schema' - } - }, - - externalSchemas: { - 'http://example.com/schema': { - type: 'string' + $ref: '#/definitions/foo' } + } } + } }, - inputStatusCode: 200, - inputResponseBody: {foo: 2345}, + definitions: { + foo: { + $ref: 'http://example.com/schema' + } + }, - expectedValidationError: { - message: 'The response was not valid.', - errors: [ - { - path: 'foo', - errorCode: 'type.openapi.responseValidation', - message: 'foo should be string' - } - ] + externalSchemas: { + 'http://example.com/schema': { + type: 'string' + } } -}; + }, + inputStatusCode: 200, + inputResponseBody: { foo: 2345 }, + + expectedValidationError: { + message: 'The response was not valid.', + errors: [ + { + path: 'foo', + errorCode: 'type.openapi.responseValidation', + message: 'foo should be string' + } + ] + } +}; diff --git a/packages/openapi-response-validator/test/data-driven/fail-with-external-references-with-path-through-local-ref.js b/packages/openapi-response-validator/test/data-driven/fail-with-external-references-with-path-through-local-ref.js index 07010376..cc874194 100644 --- a/packages/openapi-response-validator/test/data-driven/fail-with-external-references-with-path-through-local-ref.js +++ b/packages/openapi-response-validator/test/data-driven/fail-with-external-references-with-path-through-local-ref.js @@ -1,47 +1,46 @@ module.exports = { - constructorArgs: { - responses: { - 200: { - schema: { - type: 'object', - properties: { - foo: { - $ref: '#/definitions/foo' - } - } - } - } - }, - - definitions: { + constructorArgs: { + responses: { + 200: { + schema: { + type: 'object', + properties: { foo: { - $ref: 'http://example.com/schema#/definitions/foo' - } - }, - - externalSchemas: { - 'http://example.com/schema': { - definitions: { - foo: { - type: 'string' - } - } + $ref: '#/definitions/foo' } + } } + } }, - inputStatusCode: 200, - inputResponseBody: {foo: 2345}, + definitions: { + foo: { + $ref: 'http://example.com/schema#/definitions/foo' + } + }, - expectedValidationError: { - message: 'The response was not valid.', - errors: [ - { - path: 'foo', - errorCode: 'type.openapi.responseValidation', - message: 'foo should be string' - } - ] + externalSchemas: { + 'http://example.com/schema': { + definitions: { + foo: { + type: 'string' + } + } + } } -}; + }, + + inputStatusCode: 200, + inputResponseBody: { foo: 2345 }, + expectedValidationError: { + message: 'The response was not valid.', + errors: [ + { + path: 'foo', + errorCode: 'type.openapi.responseValidation', + message: 'foo should be string' + } + ] + } +}; diff --git a/packages/openapi-response-validator/test/data-driven/fail-with-external-references-with-path.js b/packages/openapi-response-validator/test/data-driven/fail-with-external-references-with-path.js index bf4d2d03..b3bba9f9 100644 --- a/packages/openapi-response-validator/test/data-driven/fail-with-external-references-with-path.js +++ b/packages/openapi-response-validator/test/data-driven/fail-with-external-references-with-path.js @@ -1,43 +1,42 @@ module.exports = { - constructorArgs: { - responses: { - 200: { - schema: { - type: 'object', - properties: { - foo: { - $ref: 'http://example.com/schema#/definitions/foo' - } - } - } - } - }, - - definitions: null, - - externalSchemas: { - 'http://example.com/schema': { - definitions: { - foo: { - type: 'string' - } - } + constructorArgs: { + responses: { + 200: { + schema: { + type: 'object', + properties: { + foo: { + $ref: 'http://example.com/schema#/definitions/foo' } + } } + } }, - inputStatusCode: 200, - inputResponseBody: {foo: 2345}, + definitions: null, - expectedValidationError: { - message: 'The response was not valid.', - errors: [ - { - path: 'foo', - errorCode: 'type.openapi.responseValidation', - message: 'foo should be string' - } - ] + externalSchemas: { + 'http://example.com/schema': { + definitions: { + foo: { + type: 'string' + } + } + } } -}; + }, + inputStatusCode: 200, + inputResponseBody: { foo: 2345 }, + + expectedValidationError: { + message: 'The response was not valid.', + errors: [ + { + path: 'foo', + errorCode: 'type.openapi.responseValidation', + message: 'foo should be string' + } + ] + } +}; diff --git a/packages/openapi-response-validator/test/data-driven/fail-with-external-references.js b/packages/openapi-response-validator/test/data-driven/fail-with-external-references.js index 933db978..5d512222 100644 --- a/packages/openapi-response-validator/test/data-driven/fail-with-external-references.js +++ b/packages/openapi-response-validator/test/data-driven/fail-with-external-references.js @@ -1,39 +1,38 @@ module.exports = { - constructorArgs: { - responses: { - 200: { - schema: { - type: 'object', - properties: { - foo: { - $ref: 'http://example.com/schema' - } - } - } - } - }, - - definitions: null, - - externalSchemas: { - 'http://example.com/schema': { - type: 'string' + constructorArgs: { + responses: { + 200: { + schema: { + type: 'object', + properties: { + foo: { + $ref: 'http://example.com/schema' } + } } + } }, - inputStatusCode: 200, - inputResponseBody: {foo: 2345}, + definitions: null, - expectedValidationError: { - message: 'The response was not valid.', - errors: [ - { - path: 'foo', - errorCode: 'type.openapi.responseValidation', - message: 'foo should be string' - } - ] + externalSchemas: { + 'http://example.com/schema': { + type: 'string' + } } -}; + }, + + inputStatusCode: 200, + inputResponseBody: { foo: 2345 }, + expectedValidationError: { + message: 'The response was not valid.', + errors: [ + { + path: 'foo', + errorCode: 'type.openapi.responseValidation', + message: 'foo should be string' + } + ] + } +}; diff --git a/packages/openapi-response-validator/test/data-driven/fail-with-unkown-status-code.js b/packages/openapi-response-validator/test/data-driven/fail-with-unkown-status-code.js index 01c12129..edbc2324 100644 --- a/packages/openapi-response-validator/test/data-driven/fail-with-unkown-status-code.js +++ b/packages/openapi-response-validator/test/data-driven/fail-with-unkown-status-code.js @@ -21,7 +21,7 @@ module.exports = { }, inputStatusCode: 400, - inputResponseBody: {foo: 'asdf'}, + inputResponseBody: { foo: 'asdf' }, expectedValidationError: { message: 'An unknown status code was used and no default was provided.' diff --git a/packages/openapi-response-validator/test/data-driven/use-errorTransformer-to-format-errors.js b/packages/openapi-response-validator/test/data-driven/use-errorTransformer-to-format-errors.js index c5f7a848..f960d6e2 100644 --- a/packages/openapi-response-validator/test/data-driven/use-errorTransformer-to-format-errors.js +++ b/packages/openapi-response-validator/test/data-driven/use-errorTransformer-to-format-errors.js @@ -21,7 +21,7 @@ module.exports = { }, inputStatusCode: 200, - inputResponseBody: {foo: 2345}, + inputResponseBody: { foo: 2345 }, expectedValidationError: { message: 'The response was not valid.', diff --git a/packages/openapi-schema-validator/test/data-driven.ts b/packages/openapi-schema-validator/test/data-driven.ts index c8e244f7..209eccdb 100644 --- a/packages/openapi-schema-validator/test/data-driven.ts +++ b/packages/openapi-schema-validator/test/data-driven.ts @@ -5,7 +5,7 @@ const baseDir = path.resolve(__dirname, 'data-driven'); import Sut from '../'; describe(require('../package.json').name, () => { - glob.sync('*.js', {cwd: baseDir}).forEach(fixture => { + glob.sync('*.js', { cwd: baseDir }).forEach(fixture => { const testName = path.basename(fixture, '.js').replace(/-/g, ' '); fixture = require(path.resolve(baseDir, fixture)); it(`should ${testName}`, () => { diff --git a/packages/openapi-schema-validator/test/data-driven/accept-extensions-to-v2-schema.js b/packages/openapi-schema-validator/test/data-driven/accept-extensions-to-v2-schema.js index 0196bda5..598711db 100644 --- a/packages/openapi-schema-validator/test/data-driven/accept-extensions-to-v2-schema.js +++ b/packages/openapi-schema-validator/test/data-driven/accept-extensions-to-v2-schema.js @@ -6,10 +6,10 @@ module.exports = { schema: { properties: { oneOf: { - type: "array", + type: 'array', minItems: 1, items: { - $ref: "#/definitions/schema" + $ref: '#/definitions/schema' } } } @@ -28,10 +28,7 @@ module.exports = { User: { properties: { name: { - oneOf: [ - { type: 'string' }, - { type: 'null' } - ] + oneOf: [{ type: 'string' }, { type: 'null' }] } } } diff --git a/packages/openapi-schema-validator/test/data-driven/accept-valid-v2-documents.js b/packages/openapi-schema-validator/test/data-driven/accept-valid-v2-documents.js index bbdb2d20..687336cd 100644 --- a/packages/openapi-schema-validator/test/data-driven/accept-valid-v2-documents.js +++ b/packages/openapi-schema-validator/test/data-driven/accept-valid-v2-documents.js @@ -24,9 +24,7 @@ module.exports = { operationId: 'FormDraftFileUpload', tags: ['Drafts'], - consumes: [ - 'multipart/form-data' - ], + consumes: ['multipart/form-data'], parameters: [ { name: 'process_intel', @@ -58,10 +56,10 @@ module.exports = { ], responses: { 200: { - 'description': 'OK' + description: 'OK' }, 400: { - 'description': 'BAD' + description: 'BAD' } } } diff --git a/packages/openapi-schema-validator/test/data-driven/accept-valid-v3-documents.js b/packages/openapi-schema-validator/test/data-driven/accept-valid-v3-documents.js index e2fd5aa6..028ae1cd 100644 --- a/packages/openapi-schema-validator/test/data-driven/accept-valid-v3-documents.js +++ b/packages/openapi-schema-validator/test/data-driven/accept-valid-v3-documents.js @@ -4,86 +4,82 @@ module.exports = { }, apiDoc: { - "openapi": "3.0.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore", - "license": { - "name": "MIT" + openapi: '3.0.0', + info: { + version: '1.0.0', + title: 'Swagger Petstore', + license: { + name: 'MIT' } }, - "servers": [ + servers: [ { - "url": "http://petstore.swagger.io/v1" + url: 'http://petstore.swagger.io/v1' } ], - "paths": { - "/pets": { - "get": { - "summary": "List all pets", - "operationId": "listPets", - "tags": [ - "pets" - ], - "parameters": [ + paths: { + '/pets': { + get: { + summary: 'List all pets', + operationId: 'listPets', + tags: ['pets'], + parameters: [ { - "name": "limit", - "in": "query", - "description": "How many items to return at one time (max 100)", - "required": false, - "schema": { - "type": "integer", - "format": "int32" + name: 'limit', + in: 'query', + description: 'How many items to return at one time (max 100)', + required: false, + schema: { + type: 'integer', + format: 'int32' } } ], - "responses": { - "200": { - "description": "An paged array of pets", - "headers": { - "x-next": { - "description": "A link to the next page of responses", - "schema": { - "type": "string" + responses: { + '200': { + description: 'An paged array of pets', + headers: { + 'x-next': { + description: 'A link to the next page of responses', + schema: { + type: 'string' } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pets" + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/Pets' } } } }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" + default: { + description: 'unexpected error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/Error' } } } } } }, - "post": { - "summary": "Create a pet", - "operationId": "createPets", - "tags": [ - "pets" - ], - "responses": { - "201": { - "description": "Null response" + post: { + summary: 'Create a pet', + operationId: 'createPets', + tags: ['pets'], + responses: { + '201': { + description: 'Null response' }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" + default: { + description: 'unexpected error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/Error' } } } @@ -91,41 +87,39 @@ module.exports = { } } }, - "/pets/{petId}": { - "get": { - "summary": "Info for a specific pet", - "operationId": "showPetById", - "tags": [ - "pets" - ], - "parameters": [ + '/pets/{petId}': { + get: { + summary: 'Info for a specific pet', + operationId: 'showPetById', + tags: ['pets'], + parameters: [ { - "name": "petId", - "in": "path", - "required": true, - "description": "The id of the pet to retrieve", - "schema": { - "type": "string" + name: 'petId', + in: 'path', + required: true, + description: 'The id of the pet to retrieve', + schema: { + type: 'string' } } ], - "responses": { - "200": { - "description": "Expected response to a valid request", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pets" + responses: { + '200': { + description: 'Expected response to a valid request', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/Pets' } } } }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" + default: { + description: 'unexpected error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/Error' } } } @@ -134,50 +128,43 @@ module.exports = { } } }, - "components": { - "schemas": { - "Pet": { - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" + components: { + schemas: { + Pet: { + required: ['id', 'name'], + properties: { + id: { + type: 'integer', + format: 'int64' }, - "name": { - "type": "string" + name: { + type: 'string' }, - "tag": { - "type": "string" + tag: { + type: 'string' } } }, - "Pets": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" + Pets: { + type: 'array', + items: { + $ref: '#/components/schemas/Pet' } }, - "Error": { - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" + Error: { + required: ['code', 'message'], + properties: { + code: { + type: 'integer', + format: 'int32' }, - "message": { - "type": "string" + message: { + type: 'string' } } } } } - }, errors: [] diff --git a/packages/openapi-schema-validator/test/data-driven/fail-invalid-v2-documents.js b/packages/openapi-schema-validator/test/data-driven/fail-invalid-v2-documents.js index 35f2341c..6da2ec59 100644 --- a/packages/openapi-schema-validator/test/data-driven/fail-invalid-v2-documents.js +++ b/packages/openapi-schema-validator/test/data-driven/fail-invalid-v2-documents.js @@ -15,9 +15,9 @@ module.exports = { { dataPath: '', keyword: 'required', - message: 'should have required property \'swagger\'', + message: "should have required property 'swagger'", params: { - missingProperty: 'swagger', + missingProperty: 'swagger' }, schemaPath: '#/required' } diff --git a/packages/openapi-schema-validator/test/data-driven/fail-invalid-v3-documents.js b/packages/openapi-schema-validator/test/data-driven/fail-invalid-v3-documents.js index 28915eaa..1fcf7294 100644 --- a/packages/openapi-schema-validator/test/data-driven/fail-invalid-v3-documents.js +++ b/packages/openapi-schema-validator/test/data-driven/fail-invalid-v3-documents.js @@ -4,86 +4,82 @@ module.exports = { }, apiDoc: { - "swagger": "3.0.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore", - "license": { - "name": "MIT" + swagger: '3.0.0', + info: { + version: '1.0.0', + title: 'Swagger Petstore', + license: { + name: 'MIT' } }, - "servers": [ + servers: [ { - "url": "http://petstore.swagger.io/v1" + url: 'http://petstore.swagger.io/v1' } ], - "paths": { - "/pets": { - "get": { - "summary": "List all pets", - "operationId": "listPets", - "tags": [ - "pets" - ], - "parameters": [ + paths: { + '/pets': { + get: { + summary: 'List all pets', + operationId: 'listPets', + tags: ['pets'], + parameters: [ { - "name": "limit", - "in": "query", - "description": "How many items to return at one time (max 100)", - "required": false, - "schema": { - "type": "integer", - "format": "int32" + name: 'limit', + in: 'query', + description: 'How many items to return at one time (max 100)', + required: false, + schema: { + type: 'integer', + format: 'int32' } } ], - "responses": { - "200": { - "description": "An paged array of pets", - "headers": { - "x-next": { - "description": "A link to the next page of responses", - "schema": { - "type": "string" + responses: { + '200': { + description: 'An paged array of pets', + headers: { + 'x-next': { + description: 'A link to the next page of responses', + schema: { + type: 'string' } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pets" + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/Pets' } } } }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" + default: { + description: 'unexpected error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/Error' } } } } } }, - "post": { - "summary": "Create a pet", - "operationId": "createPets", - "tags": [ - "pets" - ], - "responses": { - "201": { - "description": "Null response" + post: { + summary: 'Create a pet', + operationId: 'createPets', + tags: ['pets'], + responses: { + '201': { + description: 'Null response' }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" + default: { + description: 'unexpected error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/Error' } } } @@ -91,41 +87,39 @@ module.exports = { } } }, - "/pets/{petId}": { - "get": { - "summary": "Info for a specific pet", - "operationId": "showPetById", - "tags": [ - "pets" - ], - "parameters": [ + '/pets/{petId}': { + get: { + summary: 'Info for a specific pet', + operationId: 'showPetById', + tags: ['pets'], + parameters: [ { - "name": "petId", - "in": "path", - "required": true, - "description": "The id of the pet to retrieve", - "schema": { - "type": "string" + name: 'petId', + in: 'path', + required: true, + description: 'The id of the pet to retrieve', + schema: { + type: 'string' } } ], - "responses": { - "200": { - "description": "Expected response to a valid request", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pets" + responses: { + '200': { + description: 'Expected response to a valid request', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/Pets' } } } }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" + default: { + description: 'unexpected error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/Error' } } } @@ -134,67 +128,63 @@ module.exports = { } } }, - "components": { - "schemas": { - "Pet": { - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" + components: { + schemas: { + Pet: { + required: ['id', 'name'], + properties: { + id: { + type: 'integer', + format: 'int64' }, - "name": { - "type": "string" + name: { + type: 'string' }, - "tag": { - "type": "string" + tag: { + type: 'string' } } }, - "Pets": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" + Pets: { + type: 'array', + items: { + $ref: '#/components/schemas/Pet' } }, - "Error": { - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" + Error: { + required: ['code', 'message'], + properties: { + code: { + type: 'integer', + format: 'int32' }, - "message": { - "type": "string" + message: { + type: 'string' } } } } } - }, - errors: [{ - "dataPath": "", - "keyword": "additionalProperties", - "message": "should NOT have additional properties", - "params": { - "additionalProperty": "swagger" - }, - "schemaPath": "#/additionalProperties" - }, { - "dataPath": "", - "keyword": "required", - "message": "should have required property 'openapi'", - "params": { - "missingProperty": "openapi" + errors: [ + { + dataPath: '', + keyword: 'additionalProperties', + message: 'should NOT have additional properties', + params: { + additionalProperty: 'swagger' + }, + schemaPath: '#/additionalProperties' }, - "schemaPath": "#/required" - }] + { + dataPath: '', + keyword: 'required', + message: "should have required property 'openapi'", + params: { + missingProperty: 'openapi' + }, + schemaPath: '#/required' + } + ] }; diff --git a/packages/openapi-security-handler/test/data-driven.ts b/packages/openapi-security-handler/test/data-driven.ts index 2c854886..f5d686ad 100644 --- a/packages/openapi-security-handler/test/data-driven.ts +++ b/packages/openapi-security-handler/test/data-driven.ts @@ -5,13 +5,14 @@ const baseDir = path.resolve(__dirname, 'data-driven'); import Sut from '../'; describe(require('../package.json').name, () => { - glob.sync('*.js', {cwd: baseDir}).forEach(fixture => { + glob.sync('*.js', { cwd: baseDir }).forEach(fixture => { const testName = path.basename(fixture, '.js').replace(/-/g, ' '); fixture = require(path.resolve(baseDir, fixture)); it('should ' + testName, async () => { if (fixture.constructorError) { expect(() => { + /* tslint:disable-next-line:no-unused-expression */ new Sut(fixture.constructorArgs); }).to.throw(fixture.constructorError); return; @@ -26,7 +27,7 @@ describe(require('../package.json').name, () => { let err; try { await instance.handle(request); - } catch(e) { + } catch (e) { err = e; } if ('expectedError' in fixture) { diff --git a/packages/openapi-security-handler/test/data-driven/handle-bad-request-with-challenge.js b/packages/openapi-security-handler/test/data-driven/handle-bad-request-with-challenge.js index 6f667647..8dab3af7 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-bad-request-with-challenge.js +++ b/packages/openapi-security-handler/test/data-driven/handle-bad-request-with-challenge.js @@ -16,7 +16,7 @@ module.exports = { throw { status: 400, challenge: 'Bearer error="invalid_request"', - message: 'foo', + message: 'foo' }; } }, @@ -25,13 +25,13 @@ module.exports = { { keyScheme: ['write'] } - ], + ] }, expectedError: { status: 400, challenge: 'Bearer error="invalid_request"', - message: 'foo', + message: 'foo' }, expectedResult: false }; diff --git a/packages/openapi-security-handler/test/data-driven/handle-bad-request-without-message.js b/packages/openapi-security-handler/test/data-driven/handle-bad-request-without-message.js index a9c28105..0f52de0f 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-bad-request-without-message.js +++ b/packages/openapi-security-handler/test/data-driven/handle-bad-request-without-message.js @@ -14,7 +14,7 @@ module.exports = { securityHandlers: { keyScheme: function(req, scopes, securityDefinition) { throw { - status: 400, + status: 400 }; } }, @@ -23,7 +23,7 @@ module.exports = { { keyScheme: ['write'] } - ], + ] }, expectedError: { diff --git a/packages/openapi-security-handler/test/data-driven/handle-custom-response.js b/packages/openapi-security-handler/test/data-driven/handle-custom-response.js index 5bb70115..4d1e0501 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-custom-response.js +++ b/packages/openapi-security-handler/test/data-driven/handle-custom-response.js @@ -27,7 +27,7 @@ module.exports = { { keyScheme: ['write'] } - ], + ] }, expectedError: { diff --git a/packages/openapi-security-handler/test/data-driven/handle-empty-custom-response.js b/packages/openapi-security-handler/test/data-driven/handle-empty-custom-response.js index e0a7cc17..97d6f9f1 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-empty-custom-response.js +++ b/packages/openapi-security-handler/test/data-driven/handle-empty-custom-response.js @@ -24,12 +24,12 @@ module.exports = { { keyScheme: ['write'] } - ], + ] }, expectedError: { - errorCode: "authentication.openapi.security", - message: "No security handlers returned an acceptable response: keyScheme", + errorCode: 'authentication.openapi.security', + message: 'No security handlers returned an acceptable response: keyScheme', status: 401 }, diff --git a/packages/openapi-security-handler/test/data-driven/handle-forbidden-with-challenge.js b/packages/openapi-security-handler/test/data-driven/handle-forbidden-with-challenge.js index ca999add..14d0db7c 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-forbidden-with-challenge.js +++ b/packages/openapi-security-handler/test/data-driven/handle-forbidden-with-challenge.js @@ -25,7 +25,7 @@ module.exports = { { keyScheme: ['write'] } - ], + ] }, expectedError: { diff --git a/packages/openapi-security-handler/test/data-driven/handle-forbidden-with-no-message.js b/packages/openapi-security-handler/test/data-driven/handle-forbidden-with-no-message.js index 364dd825..e18095dd 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-forbidden-with-no-message.js +++ b/packages/openapi-security-handler/test/data-driven/handle-forbidden-with-no-message.js @@ -26,7 +26,7 @@ module.exports = { { keyScheme: ['write'] } - ], + ] }, expectedError: { diff --git a/packages/openapi-security-handler/test/data-driven/handle-json-message.js b/packages/openapi-security-handler/test/data-driven/handle-json-message.js index 10537209..cbd56863 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-json-message.js +++ b/packages/openapi-security-handler/test/data-driven/handle-json-message.js @@ -1,6 +1,6 @@ var expectedError = { status: 401, - message: {a:1} + message: { a: 1 } }; module.exports = { @@ -29,7 +29,7 @@ module.exports = { { keyScheme: ['write'] } - ], + ] }, expectedError: expectedError, diff --git a/packages/openapi-security-handler/test/data-driven/handle-missing-handlers.js b/packages/openapi-security-handler/test/data-driven/handle-missing-handlers.js index 56036c8c..8caf7fe3 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-missing-handlers.js +++ b/packages/openapi-security-handler/test/data-driven/handle-missing-handlers.js @@ -21,8 +21,7 @@ module.exports = { } }, - securityHandlers: { - }, + securityHandlers: {}, operationSecurity: [ { diff --git a/packages/openapi-security-handler/test/data-driven/handle-multiple-security-shemes.js b/packages/openapi-security-handler/test/data-driven/handle-multiple-security-shemes.js index c71dfba4..c7189816 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-multiple-security-shemes.js +++ b/packages/openapi-security-handler/test/data-driven/handle-multiple-security-shemes.js @@ -21,7 +21,6 @@ module.exports = { passwordScheme1: { type: 'basic' } - }, securityHandlers: { @@ -33,7 +32,7 @@ module.exports = { }, keyScheme1: function(req, scopes, securityDefinition) { - req.user = {name: 'fred'}; + req.user = { name: 'fred' }; return Promise.resolve(true); }, passwordScheme1: function(req, scopes, securityDefinition) { @@ -50,10 +49,10 @@ module.exports = { keyScheme1: ['write'], passwordScheme1: ['write'] } - ], + ] }, expectedError: void 0, expectedResult: true, - expectedUser: {name: 'fred'} + expectedUser: { name: 'fred' } }; diff --git a/packages/openapi-security-handler/test/data-driven/handle-no-authorized-requests.js b/packages/openapi-security-handler/test/data-driven/handle-no-authorized-requests.js index fd8dd8cf..5bfbdada 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-no-authorized-requests.js +++ b/packages/openapi-security-handler/test/data-driven/handle-no-authorized-requests.js @@ -42,12 +42,13 @@ module.exports = { keyScheme2: ['write'], keyScheme1: ['write'] } - ], + ] }, expectedError: { status: 401, - message: 'No security handlers returned an acceptable response: keyScheme AND keyScheme1 OR keyScheme2 AND keyScheme1', + message: + 'No security handlers returned an acceptable response: keyScheme AND keyScheme1 OR keyScheme2 AND keyScheme1', errorCode: 'authentication.openapi.security' }, expectedResult: false diff --git a/packages/openapi-security-handler/test/data-driven/handle-one-security-scheme-that-fails.js b/packages/openapi-security-handler/test/data-driven/handle-one-security-scheme-that-fails.js index 37592f68..9df8280a 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-one-security-scheme-that-fails.js +++ b/packages/openapi-security-handler/test/data-driven/handle-one-security-scheme-that-fails.js @@ -19,7 +19,7 @@ module.exports = { return false; }, passwordScheme: function(req, scopes, securityDefinition) { - req.user = {name: 'fred'}; + req.user = { name: 'fred' }; return true; } }, @@ -31,10 +31,10 @@ module.exports = { { passwordScheme: ['write'] } - ], + ] }, expectedError: void 0, expectedResult: true, - expectedUser: {name: 'fred'} + expectedUser: { name: 'fred' } }; diff --git a/packages/openapi-security-handler/test/data-driven/handle-one-security-scheme-that-passes.js b/packages/openapi-security-handler/test/data-driven/handle-one-security-scheme-that-passes.js index 9cf119e7..8eb6b3e4 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-one-security-scheme-that-passes.js +++ b/packages/openapi-security-handler/test/data-driven/handle-one-security-scheme-that-passes.js @@ -16,11 +16,11 @@ module.exports = { securityHandlers: { keyScheme: function(req, scopes, securityDefinition) { - req.user = {name: 'fred'}; + req.user = { name: 'fred' }; return Promise.resolve(true); }, passwordScheme: function(req, scopes, securityDefinition) { - req.user = {name: 'fred'}; + req.user = { name: 'fred' }; return Promise.resolve(true); } }, @@ -32,10 +32,10 @@ module.exports = { { passwordScheme: ['write'] } - ], + ] }, expectedError: void 0, expectedResult: true, - expectedUser: {name: 'fred'} + expectedUser: { name: 'fred' } }; diff --git a/packages/openapi-security-handler/test/data-driven/handle-unauthorized-no-challenge.js b/packages/openapi-security-handler/test/data-driven/handle-unauthorized-no-challenge.js index 3413fd67..dcdd916a 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-unauthorized-no-challenge.js +++ b/packages/openapi-security-handler/test/data-driven/handle-unauthorized-no-challenge.js @@ -26,7 +26,7 @@ module.exports = { { keyScheme: ['write'] } - ], + ] }, expectedError: { diff --git a/packages/openapi-security-handler/test/data-driven/handle-unauthorized-with-challenge.js b/packages/openapi-security-handler/test/data-driven/handle-unauthorized-with-challenge.js index dd0b292a..091130f3 100644 --- a/packages/openapi-security-handler/test/data-driven/handle-unauthorized-with-challenge.js +++ b/packages/openapi-security-handler/test/data-driven/handle-unauthorized-with-challenge.js @@ -27,7 +27,7 @@ module.exports = { { keyScheme: ['write'] } - ], + ] }, expectedError: { diff --git a/packages/openapi-security-handler/test/data-driven/throw-missing-args.js b/packages/openapi-security-handler/test/data-driven/throw-missing-args.js index 2dd11b54..0d789f2a 100644 --- a/packages/openapi-security-handler/test/data-driven/throw-missing-args.js +++ b/packages/openapi-security-handler/test/data-driven/throw-missing-args.js @@ -3,5 +3,5 @@ module.exports = { path: '/', headers: null, - constructorArgs: null, + constructorArgs: null }; diff --git a/packages/openapi-security-handler/test/data-driven/throw-operationSecurity-falsey.js b/packages/openapi-security-handler/test/data-driven/throw-operationSecurity-falsey.js index 2f62b465..0b1cd544 100644 --- a/packages/openapi-security-handler/test/data-driven/throw-operationSecurity-falsey.js +++ b/packages/openapi-security-handler/test/data-driven/throw-operationSecurity-falsey.js @@ -31,15 +31,14 @@ module.exports = { }, keyScheme1: function(req, scopes, securityDefinition) { - req.user = {name: 'fred'}; + req.user = { name: 'fred' }; return Promise.resolve(true); }, passwordScheme1: function(req, scopes, securityDefinition) { return Promise.resolve(true); } - }, - operationSecurity: null, - }, + operationSecurity: null + } }; diff --git a/packages/openapi-security-handler/test/data-driven/throw-operationSecurity-not-an-array.js b/packages/openapi-security-handler/test/data-driven/throw-operationSecurity-not-an-array.js index fb6cb4d0..4ce03509 100644 --- a/packages/openapi-security-handler/test/data-driven/throw-operationSecurity-not-an-array.js +++ b/packages/openapi-security-handler/test/data-driven/throw-operationSecurity-not-an-array.js @@ -31,16 +31,15 @@ module.exports = { }, keyScheme1: function(req, scopes, securityDefinition) { - req.user = {name: 'fred'}; + req.user = { name: 'fred' }; return Promise.resolve(true); }, passwordScheme1: function(req, scopes, securityDefinition) { cb(null, true); return Promise.resolve(true); } - }, - operationSecurity: true, - }, + operationSecurity: true + } }; diff --git a/packages/openapi-security-handler/test/data-driven/throw-securityDefinitions-falsey.js b/packages/openapi-security-handler/test/data-driven/throw-securityDefinitions-falsey.js index 47032059..c55fb4ac 100644 --- a/packages/openapi-security-handler/test/data-driven/throw-securityDefinitions-falsey.js +++ b/packages/openapi-security-handler/test/data-driven/throw-securityDefinitions-falsey.js @@ -15,13 +15,12 @@ module.exports = { }, keyScheme1: function(req, scopes, securityDefinition) { - req.user = {name: 'fred'}; + req.user = { name: 'fred' }; return Promise.resolve(true); }, passwordScheme1: function(req, scopes, securityDefinition) { return Promise.resolve(true); } - }, operationSecurity: [ @@ -33,6 +32,6 @@ module.exports = { keyScheme1: ['write'], passwordScheme1: ['write'] } - ], - }, + ] + } }; diff --git a/packages/openapi-security-handler/test/data-driven/throw-securityDefinitions-not-an-object.js b/packages/openapi-security-handler/test/data-driven/throw-securityDefinitions-not-an-object.js index 02c8de85..0b8ee156 100644 --- a/packages/openapi-security-handler/test/data-driven/throw-securityDefinitions-not-an-object.js +++ b/packages/openapi-security-handler/test/data-driven/throw-securityDefinitions-not-an-object.js @@ -15,13 +15,12 @@ module.exports = { }, keyScheme1: function(req, scopes, securityDefinition) { - req.user = {name: 'fred'}; + req.user = { name: 'fred' }; return Promise.resolve(true); }, passwordScheme1: function(req, scopes, securityDefinition) { return Promise.resolve(true); } - }, operationSecurity: [ @@ -33,6 +32,6 @@ module.exports = { keyScheme1: ['write'], passwordScheme1: ['write'] } - ], - }, + ] + } }; diff --git a/packages/openapi-security-handler/test/data-driven/throw-securityHandlers-not-an-object.js b/packages/openapi-security-handler/test/data-driven/throw-securityHandlers-not-an-object.js index c5ace9b1..91aff34f 100644 --- a/packages/openapi-security-handler/test/data-driven/throw-securityHandlers-not-an-object.js +++ b/packages/openapi-security-handler/test/data-driven/throw-securityHandlers-not-an-object.js @@ -33,6 +33,6 @@ module.exports = { keyScheme1: ['write'], passwordScheme1: ['write'] } - ], + ] } }; diff --git a/packages/openapi-security-handler/test/data-driven/throw-unkonwn-security-scheme-in-operation.js b/packages/openapi-security-handler/test/data-driven/throw-unkonwn-security-scheme-in-operation.js index 7740e6dc..5a7d2f14 100644 --- a/packages/openapi-security-handler/test/data-driven/throw-unkonwn-security-scheme-in-operation.js +++ b/packages/openapi-security-handler/test/data-driven/throw-unkonwn-security-scheme-in-operation.js @@ -1,6 +1,5 @@ module.exports = { - constructorError: - /openapi-security: Unknown security scheme "foo" used in operation/, + constructorError: /openapi-security: Unknown security scheme "foo" used in operation/, path: '/', headers: null, @@ -45,6 +44,6 @@ module.exports = { keyScheme2: ['write'], keyScheme1: ['write'] } - ], + ] } }; diff --git a/tslint.json b/tslint.json index ffabe528..08f5f5a8 100644 --- a/tslint.json +++ b/tslint.json @@ -1,21 +1,31 @@ { - "defaultSeverity": "error", - "extends": [ - "tslint:recommended", - "tslint-config-prettier", - "tslint-plugin-prettier" - ], - "jsRules": { - "no-console": false, - "object-literal-sort-keys": false, - "prettier": true - }, - "rules": { - "interface-name": false, - "no-console": false, - "no-var-requires": false, - "object-literal-sort-keys": false, - "prettier": true - }, - "rulesDirectory": [] -} \ No newline at end of file + "defaultSeverity": "error", + "extends": [ + "tslint:recommended", + "tslint-config-prettier", + "tslint-plugin-prettier" + ], + "jsRules": { + "no-console": false, + "object-literal-sort-keys": false, + "prettier": true + }, + "linterOptions": { + "exclude": [ + "**/node_modules/**/*", + "**/coverage/**/*", + "**/.nyc_output/**/*", + "**/dist/**/*", + "**/docs/**/*", + "packages/fetch-openapi/test/**/output.js" + ] + }, + "rules": { + "interface-name": false, + "no-console": false, + "no-var-requires": false, + "object-literal-sort-keys": false, + "prettier": true + }, + "rulesDirectory": [] +}