Skip to content

Commit

Permalink
take advantage of Swagger-Client opId improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
shockey committed May 13, 2017
1 parent e80b2f5 commit 6e40d04
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/core/plugins/spec/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,23 @@ export const logRequest = (req) => {
// Actually fire the request via fn.execute
// (For debugging) and ease of testing
export const executeRequest = (req) => ({fn, specActions, specSelectors}) => {
let { pathName, method } = req
let { pathName, method, operation } = req

let op = operation.toJS()

// if url is relative, parseUrl makes it absolute by inferring from `window.location`
req.contextUrl = parseUrl(specSelectors.url()).toString()

let parsedRequest = Object.assign({}, req)
if ( pathName && method ) {
parsedRequest.operationId = method.toLowerCase() + "-" + pathName

if(op && op.operationId) {
req.operationId = op.operationId
} else if(op && pathName && method) {
req.operationId = fn.opId(op, pathName, method)
}

let parsedRequest = Object.assign({}, req)
parsedRequest = fn.buildRequest(parsedRequest)

specActions.setRequest(req.pathName, req.method, parsedRequest)

return fn.execute(req)
Expand Down
3 changes: 2 additions & 1 deletion src/core/plugins/swagger-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module.exports = function({ configs }) {
buildRequest: Swagger.buildRequest,
execute: Swagger.execute,
resolve: Swagger.resolve,
serializeRes: Swagger.serializeRes
serializeRes: Swagger.serializeRes,
opId: Swagger.helpers.opId
}
}
}

0 comments on commit 6e40d04

Please # to comment.