Skip to content

Commit a9c0a24

Browse files
committed
Downgrade deps to node carbon
1 parent d105727 commit a9c0a24

23 files changed

+443
-270
lines changed

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lts/carbon

bin/swagger-jsdoc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function createSpecification(swaggerDefinition, apis, fileName) {
4444
swaggerSpec = JSON.stringify(swaggerJSDoc(options), null, 2);
4545
}
4646

47-
fs.writeFile(fileName, swaggerSpec, (err) => {
47+
fs.writeFile(fileName, swaggerSpec, err => {
4848
if (err) {
4949
throw err;
5050
}

example/v2/routes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is an example, it's not functionally used by the module.
33

44
// Sets up the routes.
5-
module.exports.setup = function (app) {
5+
module.exports.setup = function(app) {
66
/**
77
* @swagger
88
* /:

example/v2/routes2.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* istanbul ignore next */
22
// This file is an example, it's not functionally used by the module.
33

4-
module.exports.setup = function (app) {
4+
module.exports.setup = function(app) {
55
/**
66
* @swagger
77
* /hello:

lib/helpers/convertGlobPaths.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const glob = require('glob');
99
*/
1010
function convertGlobPaths(globs) {
1111
return globs
12-
.map((globString) => glob.sync(globString))
12+
.map(globString => glob.sync(globString))
1313
.reduce((previous, current) => previous.concat(current), []);
1414
}
1515

lib/helpers/createSpecification.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ function createSpecification(definition) {
2222

2323
if (specification.openapi) {
2424
specification.openapi = specification.openapi;
25-
v3.forEach((property) => {
25+
v3.forEach(property => {
2626
specification[property] = specification[property] || {};
2727
});
2828
} else if (specification.swagger) {
2929
specification.swagger = specification.swagger;
30-
v2.forEach((property) => {
30+
v2.forEach(property => {
3131
specification[property] = specification[property] || {};
3232
});
3333
} else {
3434
specification.swagger = '2.0';
35-
v2.forEach((property) => {
35+
v2.forEach(property => {
3636
specification[property] = specification[property] || {};
3737
});
3838
}

lib/helpers/finalizeSpecificationObject.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function cleanUselessProperties(inputSpec) {
1717
'securityDefinitions',
1818
];
1919

20-
toClean.forEach((unnecessaryProp) => {
20+
toClean.forEach(unnecessaryProp => {
2121
if (hasEmptyProperty(improvedSpec[unnecessaryProp])) {
2222
delete improvedSpec[unnecessaryProp];
2323
}

lib/helpers/hasEmptyProperty.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
*/
66
function hasEmptyProperty(obj) {
77
return Object.keys(obj)
8-
.map((key) => obj[key])
8+
.map(key => obj[key])
99
.every(
10-
(keyObject) =>
10+
keyObject =>
1111
typeof keyObject === 'object' &&
12-
Object.keys(keyObject).every((key) => !(key in keyObject))
12+
Object.keys(keyObject).every(key => !(key in keyObject))
1313
);
1414
}
1515

lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const finalizeSpecificationObject = require('./helpers/finalizeSpecificationObje
1414
* @returns {object} Output specification
1515
* @requires swagger-parser
1616
*/
17-
module.exports = (options) => {
17+
module.exports = options => {
1818
if ((!options.swaggerDefinition || !options.definition) && !options.apis) {
1919
throw new Error('Provided options are incorrect.');
2020
}

package.json

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
{
22
"name": "swagger-jsdoc",
3-
"version": "3.6.0",
4-
"description": "Generates swagger doc based on JSDoc",
5-
"main": "index.js",
6-
"scripts": {
7-
"test:lint": "eslint .",
8-
"test:js": "mocha --timeout 10000 --exit",
9-
"start": "node example/v2/app.js",
10-
"test": "run-p test:* -cn"
11-
},
12-
"bin": {
13-
"swagger-jsdoc": "./bin/swagger-jsdoc.js"
3+
"version": "3.7.0",
4+
"engines": {
5+
"node": ">=8.0.0"
146
},
7+
"license": "MIT",
8+
"description": "Generates swagger doc based on JSDoc",
9+
"homepage": "https://github.com/Surnet/swagger-jsdoc",
1510
"repository": {
1611
"type": "git",
1712
"url": "https://github.com/Surnet/swagger-jsdoc.git"
@@ -24,17 +19,25 @@
2419
"swagger"
2520
],
2621
"author": "https://github.com/Surnet/swagger-jsdoc/graphs/contributors",
27-
"license": "MIT",
2822
"bugs": {
2923
"url": "https://github.com/Surnet/swagger-jsdoc/issues"
3024
},
31-
"homepage": "https://github.com/Surnet/swagger-jsdoc",
25+
"main": "index.js",
26+
"scripts": {
27+
"test:lint": "eslint .",
28+
"test:js": "mocha --timeout 10000 --exit",
29+
"start": "node example/v2/app.js",
30+
"test": "run-p test:* -cn"
31+
},
32+
"bin": {
33+
"swagger-jsdoc": "./bin/swagger-jsdoc.js"
34+
},
3235
"dependencies": {
3336
"commander": "4.0.1",
3437
"doctrine": "3.0.0",
3538
"glob": "7.1.6",
3639
"js-yaml": "3.13.1",
37-
"swagger-parser": "9.0.1"
40+
"swagger-parser": "8.0.4"
3841
},
3942
"devDependencies": {
4043
"body-parser": "1.19.0",
@@ -47,11 +50,11 @@
4750
"eslint-plugin-import": "2.20.1",
4851
"eslint-plugin-prettier": "3.1.2",
4952
"express": "4.17.1",
50-
"husky": "4.2.3",
51-
"lint-staged": "10.0.8",
53+
"husky": "3.1.0",
54+
"lint-staged": "9.5.0",
5255
"mocha": "7.1.1",
5356
"npm-run-all": "4.1.5",
54-
"prettier": "2.0.1",
57+
"prettier": "1.19.1",
5558
"supertest": "4.0.2"
5659
},
5760
"husky": {

test/cli/cli.js

+19-19
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { expect } = chai;
88
const fs = require('fs');
99

1010
describe('command line interface', () => {
11-
it('help menu works', (done) => {
11+
it('help menu works', done => {
1212
const helpCommand = `${process.env.PWD}/bin/swagger-jsdoc.js -h`;
1313
exec(helpCommand, (error, stdout, stderr) => {
1414
if (error) {
@@ -19,7 +19,7 @@ describe('command line interface', () => {
1919
});
2020
});
2121

22-
it('help menu is default fallback when no arguments', (done) => {
22+
it('help menu is default fallback when no arguments', done => {
2323
const helpCommand = `${process.env.PWD}/bin/swagger-jsdoc.js`;
2424
exec(helpCommand, (error, stdout, stderr) => {
2525
if (error) {
@@ -30,7 +30,7 @@ describe('command line interface', () => {
3030
});
3131
});
3232

33-
it('should require a definition file', (done) => {
33+
it('should require a definition file', done => {
3434
const wrongDefinition = `${process.env.PWD}/bin/swagger-jsdoc.js wrongDefinition`;
3535
exec(wrongDefinition, (error, stdout, stderr) => {
3636
if (error) {
@@ -41,7 +41,7 @@ describe('command line interface', () => {
4141
});
4242
});
4343

44-
it('should require an info object in the definition', (done) => {
44+
it('should require an info object in the definition', done => {
4545
const wrongDefinition = `${process.env.PWD}/bin/swagger-jsdoc.js -d test/fixtures/v2/empty_definition.js`;
4646
exec(wrongDefinition, (error, stdout, stderr) => {
4747
if (error) {
@@ -54,7 +54,7 @@ describe('command line interface', () => {
5454
});
5555
});
5656

57-
it('should require title and version in the info object', (done) => {
57+
it('should require title and version in the info object', done => {
5858
const wrongDefinition = `${process.env.PWD}/bin/swagger-jsdoc.js -d test/fixtures/v2/wrong_definition.js`;
5959
exec(wrongDefinition, (error, stdout, stderr) => {
6060
if (error) {
@@ -67,7 +67,7 @@ describe('command line interface', () => {
6767
});
6868
});
6969

70-
it('should require arguments with jsDoc data about an API', (done) => {
70+
it('should require arguments with jsDoc data about an API', done => {
7171
const missingApis = `${process.env.PWD}/bin/swagger-jsdoc.js -d example/v2/swaggerDef.js`;
7272
exec(missingApis, (error, stdout, stderr) => {
7373
if (error) {
@@ -80,7 +80,7 @@ describe('command line interface', () => {
8080
});
8181
});
8282

83-
it('should create swagger.json by default when the API input is good', (done) => {
83+
it('should create swagger.json by default when the API input is good', done => {
8484
const goodInput = `${process.env.PWD}/bin/swagger-jsdoc.js -d example/v2/swaggerDef.js example/v2/routes.js`;
8585
exec(goodInput, (error, stdout, stderr) => {
8686
if (error) {
@@ -97,7 +97,7 @@ describe('command line interface', () => {
9797
});
9898
});
9999

100-
it('should create swagger.json by default when the API input is from definition file', (done) => {
100+
it('should create swagger.json by default when the API input is from definition file', done => {
101101
const goodInput = `${process.env.PWD}/bin/swagger-jsdoc.js -d test/fixtures/v2/api_definition.js`;
102102
exec(goodInput, (error, stdout, stderr) => {
103103
if (error) {
@@ -114,7 +114,7 @@ describe('command line interface', () => {
114114
});
115115
});
116116

117-
it('should accept custom configuration for output specification', (done) => {
117+
it('should accept custom configuration for output specification', done => {
118118
const goodInput = `${process.env.PWD}/bin/swagger-jsdoc.js -d example/v2/swaggerDef.js -o customSpec.json example/v2/routes.js`;
119119
exec(goodInput, (error, stdout, stderr) => {
120120
if (error) {
@@ -128,7 +128,7 @@ describe('command line interface', () => {
128128
});
129129
});
130130

131-
it('should create a YAML swagger spec when a custom output configuration with a .yaml extension is used', (done) => {
131+
it('should create a YAML swagger spec when a custom output configuration with a .yaml extension is used', done => {
132132
const goodInput = `${process.env.PWD}/bin/swagger-jsdoc.js -d example/v2/swaggerDef.js -o customSpec.yaml example/v2/routes.js`;
133133
exec(goodInput, (error, stdout, stderr) => {
134134
if (error) {
@@ -142,7 +142,7 @@ describe('command line interface', () => {
142142
});
143143
});
144144

145-
it('should create a YAML swagger spec when a custom output configuration with a .yml extension is used', (done) => {
145+
it('should create a YAML swagger spec when a custom output configuration with a .yml extension is used', done => {
146146
const goodInput = `${process.env.PWD}/bin/swagger-jsdoc.js -d example/v2/swaggerDef.js -o customSpec.yml example/v2/routes.js`;
147147
exec(goodInput, (error, stdout, stderr) => {
148148
if (error) {
@@ -156,7 +156,7 @@ describe('command line interface', () => {
156156
});
157157
});
158158

159-
it('should allow a JavaScript definition file', (done) => {
159+
it('should allow a JavaScript definition file', done => {
160160
const goodInput = `${process.env.PWD}/bin/swagger-jsdoc.js -d test/fixtures/v2/api_definition.js`;
161161
exec(goodInput, (error, stdout, stderr) => {
162162
if (error) {
@@ -167,7 +167,7 @@ describe('command line interface', () => {
167167
});
168168
});
169169

170-
it('should allow a JSON definition file', (done) => {
170+
it('should allow a JSON definition file', done => {
171171
const goodInput = `${process.env.PWD}/bin/swagger-jsdoc.js -d test/fixtures/api_definition.json`;
172172
exec(goodInput, (error, stdout, stderr) => {
173173
if (error) {
@@ -178,7 +178,7 @@ describe('command line interface', () => {
178178
});
179179
});
180180

181-
it('should allow a YAML definition file', (done) => {
181+
it('should allow a YAML definition file', done => {
182182
const goodInput = `${process.env.PWD}/bin/swagger-jsdoc.js -d test/fixtures/api_definition.yaml`;
183183
exec(goodInput, (error, stdout, stderr) => {
184184
if (error) {
@@ -189,15 +189,15 @@ describe('command line interface', () => {
189189
});
190190
});
191191

192-
it('should reject definition file with invalid YAML syntax', (done) => {
192+
it('should reject definition file with invalid YAML syntax', done => {
193193
const goodInput = `${process.env.PWD}/bin/swagger-jsdoc.js -d test/fixtures/wrong_syntax.yaml`;
194194
exec(goodInput, (error, stdout) => {
195195
expect(stdout).to.contain('tag suffix cannot contain exclamation marks');
196196
done();
197197
});
198198
});
199199

200-
it('should reject definition file with non-JSON compatible YAML syntax', (done) => {
200+
it('should reject definition file with non-JSON compatible YAML syntax', done => {
201201
const goodInput = `${process.env.PWD}/bin/swagger-jsdoc.js -d test/fixtures/non_json_compatible.yaml`;
202202
exec(goodInput, (error, stdout) => {
203203
expect(stdout).to.contain(
@@ -207,23 +207,23 @@ describe('command line interface', () => {
207207
});
208208
});
209209

210-
it('should reject definition file with invalid JSON syntax', (done) => {
210+
it('should reject definition file with invalid JSON syntax', done => {
211211
const input = `${process.env.PWD}/bin/swagger-jsdoc.js -d test/fixtures/wrong_syntax.json`;
212212
exec(input, (error, stdout) => {
213213
expect(stdout).to.contain('Unexpected token t in JSON');
214214
done();
215215
});
216216
});
217217

218-
it('should reject bad YAML identation with feedback: upper line', (done) => {
218+
it('should reject bad YAML identation with feedback: upper line', done => {
219219
const input = `${process.env.PWD}/bin/swagger-jsdoc.js -d example/v2/swaggerDef.js test/fixtures/wrong-yaml-identation1.js`;
220220
exec(input, (error, stdout, stderr) => {
221221
expect(stderr).to.contain('Pay attention at this place');
222222
done();
223223
});
224224
});
225225

226-
it('should reject bad YAML identation with feedback: same line', (done) => {
226+
it('should reject bad YAML identation with feedback: same line', done => {
227227
const input = `${process.env.PWD}/bin/swagger-jsdoc.js -d example/v2/swaggerDef.js test/fixtures/wrong-yaml-identation2.js`;
228228
exec(input, (error, stdout, stderr) => {
229229
expect(stderr).to.contain('Pay attention at this place');

test/example/v2/app.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,38 @@ function swaggerSpecIsCompliant(res) {
1515

1616
// Testing an example app parsing documentation with swagger-jsdoc.
1717
describe('example app', () => {
18-
it('homepage returns a success code', (done) => {
18+
it('homepage returns a success code', done => {
1919
request(app)
2020
.get('/')
2121
.expect(200)
22-
.end((err) => {
22+
.end(err => {
2323
if (err) return done(err);
2424

2525
return done();
2626
});
2727
});
2828

29-
it('login authentication returns a success code', (done) => {
29+
it('login authentication returns a success code', done => {
3030
request(app)
3131
.post('/login')
3232
.send({
3333
username: 'user@domain.com',
3434
password: 'Password',
3535
})
3636
.expect(200)
37-
.end((err) => {
37+
.end(err => {
3838
if (err) return done(err);
3939

4040
return done();
4141
});
4242
});
4343

44-
it('produced swagger spec is as expected', (done) => {
44+
it('produced swagger spec is as expected', done => {
4545
request(app)
4646
.get('/api-docs.json')
4747
.expect(200)
4848
.expect(swaggerSpecIsCompliant)
49-
.end((err) => {
49+
.end(err => {
5050
if (err) return done(err);
5151

5252
return done();

test/example/v3/api-with-examples/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Imaginary API helper
2-
module.exports = function (app) {
2+
module.exports = function(app) {
33
/**
44
* @swagger
55
*

test/example/v3/callback/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Imaginary API helper
2-
module.exports = function (app) {
2+
module.exports = function(app) {
33
/**
44
* @swagger
55
*

test/example/v3/links/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@
4242
* userRepositories:
4343
* $ref: '#/components/links/UserRepositories'
4444
*/
45-
module.exports = function (app) {
45+
module.exports = function(app) {
4646
app.get('/users/:username', () => {});
4747
};

0 commit comments

Comments
 (0)