Skip to content

Commit

Permalink
fix yaml formatting (#245)
Browse files Browse the repository at this point in the history
* fix yaml formatting

* fix yaml formatting

* improvements
  • Loading branch information
kalinchernev authored Feb 15, 2021
1 parent 87e51e9 commit 3bb003a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 44 deletions.
28 changes: 15 additions & 13 deletions bin/swagger-jsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ if (!process.argv.slice(2).length) {
process.exit();
}

const { definition, output } = program;
const { definition } = program;
const output = program.output || 'swagger.json';

if (!definition) {
console.log('Definition file is required.');
Expand Down Expand Up @@ -68,17 +69,18 @@ if (!program.args.length) {
process.exit();
}

fs.writeFileSync(
output || 'swagger.json',
JSON.stringify(
swaggerJsdoc({
swaggerDefinition,
apis: program.args,
format: path.extname(output || ''),
}),
null,
2
)
);
const format = path.extname(output);

const result = swaggerJsdoc({
swaggerDefinition,
apis: program.args,
format,
});

if (format === '.json') {
fs.writeFileSync(output, JSON.stringify(result, null, 2));
} else {
fs.writeFileSync(output, result);
}

console.log('Swagger specification is ready.');
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "swagger-jsdoc",
"description": "Generates swagger doc based on JSDoc",
"version": "6.0.2",
"version": "6.0.3",
"engines": {
"node": ">=12.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('CLI module', () => {

it('should accept custom configuration for output specification', async () => {
const result = await sh(
`${bin} -d examples/app/swaggerDefinition.js -o customSpec.json examples/app/routes.js`
`${bin} -d examples/app/swaggerDefinition.js examples/app/routes.js -o customSpec.json`
);
expect(result.stdout).toBe('Swagger specification is ready.\n');
const specification = fs.statSync('customSpec.json');
Expand Down
31 changes: 2 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -985,11 +985,6 @@ balanced-match@^1.0.0:
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=

base64-js@^1.3.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==

base@^0.11.1:
version "0.11.2"
resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f"
Expand All @@ -1015,15 +1010,6 @@ big.js@^5.2.2:
resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"
integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==

bl@>=4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/bl/-/bl-4.0.3.tgz#12d6287adc29080e22a705e5764b2a9522cdc489"
integrity sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg==
dependencies:
buffer "^5.5.0"
inherits "^2.0.4"
readable-stream "^3.4.0"

[email protected]:
version "1.19.0"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a"
Expand Down Expand Up @@ -1088,14 +1074,6 @@ buffer-from@^1.0.0:
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==

buffer@^5.5.0:
version "5.7.1"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0"
integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.1.13"

[email protected]:
version "3.1.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6"
Expand Down Expand Up @@ -2490,11 +2468,6 @@ [email protected]:
dependencies:
safer-buffer ">= 2.1.2 < 3"

ieee754@^1.1.13:
version "1.2.1"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==

ignore@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
Expand Down Expand Up @@ -2539,7 +2512,7 @@ inflight@^1.0.4:
once "^1.3.0"
wrappy "1"

inherits@2, [email protected], inherits@^2.0.3, inherits@^2.0.4:
inherits@2, [email protected], inherits@^2.0.3:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
Expand Down Expand Up @@ -4245,7 +4218,7 @@ read-pkg@^5.2.0:
parse-json "^5.0.0"
type-fest "^0.6.0"

readable-stream@^3.4.0, readable-stream@^3.6.0:
readable-stream@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198"
integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==
Expand Down

0 comments on commit 3bb003a

Please sign in to comment.