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

Commit

Permalink
docs: add quick usage in readme Close #95
Browse files Browse the repository at this point in the history
  • Loading branch information
joolfe committed Mar 30, 2021
1 parent 51ec113 commit 194b1a4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
50 changes: 24 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,25 @@ Or in other words, transform [this specification](https://schema.getpostman.com/
[![codecov](https://codecov.io/gh/joolfe/postman-to-openapi/branch/master/graph/badge.svg)](https://codecov.io/gh/joolfe/postman-to-openapi)
[![npm version](https://img.shields.io/npm/v/postman-to-openapi
)](https://www.npmjs.com/package/postman-to-openapi)
[![dcos](https://img.shields.io/badge/docs-here-yellow)](https://joolfe.github.io/postman-to-openapi/)
[![docs](https://img.shields.io/badge/docs-here-yellow)](https://joolfe.github.io/postman-to-openapi/)

## Installation

Using `npm`:

`npm i postman-to-openapi`
```bash
npm i postman-to-openapi
```

Using `yarn`:

`yarn add postman-to-openapi`
```bash
yarn add postman-to-openapi
```

## Quick Usage

```
```js
// Require Package
const postmanToOpenApi = require('postman-to-openapi')

Expand All @@ -33,30 +37,24 @@ const postmanCollection = './path/to/postman/collection.json'
// Output OpenAPI Path
const outputFile = './api/collection.yml'

// Convert Postman collection to OpenAPI using Async/Await
const collectionToOpenAPI = async () => {
try {
const result = await postmanToOpenApi(postmanCollection, outputFile, { defaultTag: 'General' })
// Without save the result in a file
const result2 = await postmanToOpenApi(postmanCollection, null, { defaultTag: 'General' })
// Async/await
try {
const result = await postmanToOpenApi(postmanCollection, outputFile, { defaultTag: 'General' })
// Without save the result in a file
const result2 = await postmanToOpenApi(postmanCollection, null, { defaultTag: 'General' })
console.log(`OpenAPI specs: ${result}`)
} catch (err) {
console.log(err)
}

// Promise callback style
postmanToOpenApi(postmanCollection, outputFile, { defaultTag: 'General' })
.then(result => {
console.log(`OpenAPI specs: ${result}`)
} catch (err) {
})
.catch(err => {
console.log(err)
}
}
collectionToOpenAPI();
// Convert Postman collection to OpenAPI using Promise Callback
const collectionToOpenAPI = async () => {
postmanToOpenApi(postmanCollection, outputFile, { defaultTag: 'General' })
.then(result => {
console.log(`OpenAPI specs: ${result}`)
})
.catch(err => {
console.log(err)
})
}
collectionToOpenAPI();
})
```

## Documentation
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postman-to-openapi",
"version": "1.7.0",
"version": "1.7.1",
"description": "Convert postman collection to OpenAPI spec",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit 194b1a4

Please sign in to comment.