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

Commit

Permalink
fix: support empty auth options
Browse files Browse the repository at this point in the history
  • Loading branch information
joolfe committed May 18, 2021
1 parent 4d9b400 commit 704ef36
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,12 @@ function parseOptsAuth (optAuth) {
security.push({ [secName]: [] })
}
}
return {
components: { securitySchemes },
security
}
return Object.keys(securitySchemes).length === 0
? {}
: {
components: { securitySchemes },
security
}
}

/* From the path array compose the real path for OpenApi specs */
Expand Down Expand Up @@ -291,6 +293,7 @@ function scrapeURL (url) {
function parseServers (domains, serversOpts) {
let servers
if (serversOpts != null) {
// This map is just to filter not supported fields while no validations are implemented
servers = serversOpts.map(({ url, description }) => ({ url, description }))
} else {
servers = Array.from(domains).map(domain => ({ url: domain }))
Expand Down
8 changes: 8 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ describe('Library specs', function () {
equal(result, EXPECTED_BASIC)
})

it('should not fail if auth is empty object', async function () {
const result = await postmanToOpenApi(COLLECTION_BASIC, OUTPUT_PATH,
{
auth: {}
})
equal(result, EXPECTED_BASIC)
})

it('should use depth configuration for parse paths', async function () {
const result = await postmanToOpenApi(COLLECTION_DEPTH_PATH_PARAMS, OUTPUT_PATH, { pathDepth: 1 })
equal(result, EXPECTED_DEPTH_PATH_PARAMS)
Expand Down

0 comments on commit 704ef36

Please sign in to comment.