@@ -12,6 +12,53 @@ Or in other words, transform [this specification](https://schema.getpostman.com/
1212)] ( https://www.npmjs.com/package/postman-to-openapi )
1313[ ![ dcos] ( https://img.shields.io/badge/docs-here-yellow )] ( https://joolfe.github.io/postman-to-openapi/ )
1414
15+ ## Installation
16+
17+ Using ` npm ` :
18+
19+ ` npm i postman-to-openapi `
20+
21+ Using ` yarn ` :
22+
23+ ` yarn add postman-to-openapi `
24+
25+ ## Quick Usage
26+
27+ ```
28+ // Require Package
29+ const postmanToOpenApi = require('postman-to-openapi')
30+
31+ // Postman Collection Path
32+ const postmanCollection = './path/to/postman/collection.json'
33+ // Output OpenAPI Path
34+ const outputFile = './api/collection.yml'
35+
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' })
42+ console.log(`OpenAPI specs: ${result}`)
43+ } catch (err) {
44+ 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();
60+ ```
61+
1562## Documentation
1663
1764All features, usage instructions and help can be found in the [ Documentation page] ( https://joolfe.github.io/postman-to-openapi/ )
0 commit comments