@@ -10,21 +10,25 @@ Or in other words, transform [this specification](https://schema.getpostman.com/
1010[ ![ codecov] ( https://codecov.io/gh/joolfe/postman-to-openapi/branch/master/graph/badge.svg )] ( https://codecov.io/gh/joolfe/postman-to-openapi )
1111[ ![ npm version] (https://img.shields.io/npm/v/postman-to-openapi
1212)] ( https://www.npmjs.com/package/postman-to-openapi )
13- [ ![ dcos ] ( https://img.shields.io/badge/docs-here-yellow )] ( https://joolfe.github.io/postman-to-openapi/ )
13+ [ ![ docs ] ( https://img.shields.io/badge/docs-here-yellow )] ( https://joolfe.github.io/postman-to-openapi/ )
1414
1515## Installation
1616
1717Using ` npm ` :
1818
19- ` npm i postman-to-openapi `
19+ ``` bash
20+ npm i postman-to-openapi
21+ ```
2022
2123Using ` yarn ` :
2224
23- ` yarn add postman-to-openapi `
25+ ``` bash
26+ yarn add postman-to-openapi
27+ ```
2428
2529## Quick Usage
2630
27- ```
31+ ``` js
2832// Require Package
2933const postmanToOpenApi = require (' postman-to-openapi' )
3034
@@ -33,30 +37,24 @@ const postmanCollection = './path/to/postman/collection.json'
3337// Output OpenAPI Path
3438const outputFile = ' ./api/collection.yml'
3539
36- // Convert Postman collection to OpenAPI using Async/Await
37- const collectionToOpenAPI = async () => {
38- try {
39- const result = await postmanToOpenApi(postmanCollection, outputFile, { defaultTag: 'General' })
40- // Without save the result in a file
41- const result2 = await postmanToOpenApi(postmanCollection, null, { defaultTag: 'General' })
40+ // Async/await
41+ try {
42+ const result = await postmanToOpenApi (postmanCollection, outputFile, { defaultTag: ' General' })
43+ // Without save the result in a file
44+ const result2 = await postmanToOpenApi (postmanCollection, null , { defaultTag: ' General' })
45+ console .log (` OpenAPI specs: ${ result} ` )
46+ } catch (err) {
47+ console .log (err)
48+ }
49+
50+ // Promise callback style
51+ postmanToOpenApi (postmanCollection, outputFile, { defaultTag: ' General' })
52+ .then (result => {
4253 console .log (` OpenAPI specs: ${ result} ` )
43- } catch (err) {
54+ })
55+ .catch (err => {
4456 console .log (err)
45- }
46- }
47- collectionToOpenAPI();
48-
49- // Convert Postman collection to OpenAPI using Promise Callback
50- const collectionToOpenAPI = async () => {
51- postmanToOpenApi(postmanCollection, outputFile, { defaultTag: 'General' })
52- .then(result => {
53- console.log(`OpenAPI specs: ${result}`)
54- })
55- .catch(err => {
56- console.log(err)
57- })
58- }
59- collectionToOpenAPI();
57+ })
6058```
6159
6260## Documentation
0 commit comments