This repository has been archived by the owner on Dec 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
385 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,6 @@ node_modules/* | |
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.cache | ||
|
||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env node | ||
const yargs = require('yargs/yargs'); | ||
const { hideBin } = require('yargs/helpers'); | ||
const postmanToOpenApi = require('../lib/index'); | ||
const fs = require('fs'); | ||
|
||
const args = yargs(hideBin(process.argv)) | ||
.usage('$0 output', 'Convert the input file, usually json, ' + | ||
'with Postman collections to OpenAPI by applying the given options file, also json, ' + | ||
'and save as the output file, usually yml.', (yargs) => { | ||
yargs | ||
.positional('output', { | ||
desc: 'Save the output OpenAPI with this name', | ||
type: 'string', | ||
}) | ||
.options('i', { | ||
alias: 'input', | ||
demandOption: true, | ||
desc: 'Path to the Postman collection json file', | ||
type: 'string', | ||
}) | ||
.options('o', { | ||
alias: 'options', | ||
desc: 'Path to the Options json file', | ||
type: 'string', | ||
}) | ||
}).argv; | ||
|
||
const json_str = args.options && fs.readFileSync(args.options, 'utf8'); | ||
const options = json_str && JSON.parse(json_str); | ||
console.log(`Converting ${args.input} to ${args.output}, with options:\n${json_str || 'NONE'}`); | ||
|
||
postmanToOpenApi(args.input, args.output, options) | ||
.then(_ => { | ||
console.log(`Done !`); | ||
}) | ||
.catch(err => { | ||
console.log(err); | ||
}); |
Oops, something went wrong.