Skip to content

Commit

Permalink
fix(auth): remove authentication from /openapi/v2 call (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpauwels authored and silasbw committed Dec 24, 2018
1 parent 0aa7f80 commit ef1467a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
4 changes: 4 additions & 0 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ class Request {
headers: options.headers
}, this.requestOptions)

if (options.noAuth) {
delete requestOptions.auth
}

if (options.stream) return request(requestOptions)

return new Promise((resolve, reject) => {
Expand Down
19 changes: 7 additions & 12 deletions lib/swagger-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@ const Request = require('./request')

class Root extends Component {
_getSpec (pathname) {
return this.http.http({ method: 'GET', pathname })
return this.http.http({ method: 'GET', pathname, noAuth: true })
.then(res => {
return res.body
})
.catch(err => {
if (err.statusCode === 404) return null
throw new Error(`Failed to get ${pathname}`)
})
}

/**
Expand All @@ -49,16 +45,15 @@ class Root extends Component {
*/
loadSpec () {
return this._getSpec('/openapi/v2')
.then(res => {
if (res) return res
.catch(err => {
return this._getSpec('/swagger.json')
})
.then(res => {
if (res) {
this._addSpec(res)
return this
}
throw new Error('Failed to get /openapi/v2 and /swagger.json')
this._addSpec(res)
return this
})
.catch(err => {
throw new Error(`Failed to get /openapi/v2 and /swagger.json: ${err.message}`)
})
}

Expand Down

0 comments on commit ef1467a

Please sign in to comment.