Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 194b1a4

Browse files
committed
docs: add quick usage in readme Close #95
1 parent 51ec113 commit 194b1a4

3 files changed

Lines changed: 27 additions & 29 deletions

File tree

README.md

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1717
Using `npm`:
1818

19-
`npm i postman-to-openapi`
19+
```bash
20+
npm i postman-to-openapi
21+
```
2022

2123
Using `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
2933
const postmanToOpenApi = require('postman-to-openapi')
3034

@@ -33,30 +37,24 @@ const postmanCollection = './path/to/postman/collection.json'
3337
// Output OpenAPI Path
3438
const 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

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postman-to-openapi",
3-
"version": "1.7.0",
3+
"version": "1.7.1",
44
"description": "Convert postman collection to OpenAPI spec",
55
"main": "lib/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)