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

Commit

Permalink
Merge pull request #73 from joolfe/develop
Browse files Browse the repository at this point in the history
Collection version 2
  • Loading branch information
joolfe authored Oct 1, 2020
2 parents 6138a9d + 38be7cb commit 0acb75a
Show file tree
Hide file tree
Showing 36 changed files with 1,566 additions and 177 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,24 @@ jobs:
- run: npm install
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Generate changelog
id: changelog
uses: metcalfc/[email protected]
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
- name: Get package version
id: package-version
uses: martinbeentjes/npm-get-version-action@master
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.package-version.outputs.current-version }}
release_name: Release ${{ steps.package-version.outputs.current-version }}
body: |
${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## [1.5.0](https://github.com/joolfe/postman-to-openapi/compare/1.4.1...1.5.0) (2020-10-01)


### Features

* support postman collection v2 ([1d9da47](https://github.com/joolfe/postman-to-openapi/commit/1d9da470d428b3053761464b7965b294c833e70b)), closes [#20](https://github.com/joolfe/postman-to-openapi/issues/20)


### Continuous Integration

* added autorelease steps ([c3b297c](https://github.com/joolfe/postman-to-openapi/commit/c3b297cb4a85cf0028bdcc98c13c8ad2459e20f0)), closes [#71](https://github.com/joolfe/postman-to-openapi/issues/71)


### Build System

* update version to 1.5.0 ([c3267a8](https://github.com/joolfe/postman-to-openapi/commit/c3267a847327c371cc347f615de1e5bfd5ac55d2))

### [1.4.1](https://github.com/joolfe/postman-to-openapi/compare/1.4.0...1.4.1) (2020-09-12)


Expand Down
18 changes: 17 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ async function postmanToOpenApi (input, output, { info = {}, defaultTag = 'defau
element = tagged.shift()
}
const {
request: { url: { path, query, protocol, host }, method, body, description: rawDesc, header },
request: { url, method, body, description: rawDesc, header },
name: summary, tag = defaultTag, event: events
} = element
const { path, query, protocol, host } = scrapeURL(url)
domains.add(calculateDomains(protocol, host))
const joinedPath = calculatePath(path, pathDepth)
if (!paths[joinedPath]) paths[joinedPath] = {}
Expand Down Expand Up @@ -250,6 +251,21 @@ function calculateDomains (protocol, hosts) {
return protocol + '://' + hosts.join('.')
}

/** Support for collection V2 */
function scrapeURL (url) {
if (typeof url === 'string' || url instanceof String) {
const objUrl = new URL(url)
return {
raw: url,
path: decodeURIComponent(objUrl.pathname).slice(1).split('/'),
query: [],
protocol: objUrl.protocol.slice(0, -1),
host: decodeURIComponent(objUrl.hostname).split('.')
}
}
return url
}

/* Parse domains from operations or options */
function parseServers (domains, serversOpts) {
let servers
Expand Down
2 changes: 1 addition & 1 deletion 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.4.1",
"version": "1.5.0",
"description": "Convert postman collection to OpenAPI spec",
"main": "lib/index.js",
"scripts": {
Expand Down
Loading

0 comments on commit 0acb75a

Please sign in to comment.