take advantage of Swagger-Client opId improvements

This commit is contained in:
Kyle Shockey
2017-05-12 23:12:11 -07:00
parent e80b2f5b3f
commit 6e40d04741
2 changed files with 13 additions and 5 deletions

View File

@@ -186,16 +186,23 @@ export const logRequest = (req) => {
// Actually fire the request via fn.execute // Actually fire the request via fn.execute
// (For debugging) and ease of testing // (For debugging) and ease of testing
export const executeRequest = (req) => ({fn, specActions, specSelectors}) => { 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` // if url is relative, parseUrl makes it absolute by inferring from `window.location`
req.contextUrl = parseUrl(specSelectors.url()).toString() req.contextUrl = parseUrl(specSelectors.url()).toString()
let parsedRequest = Object.assign({}, req)
if ( pathName && method ) { if(op && op.operationId) {
parsedRequest.operationId = method.toLowerCase() + "-" + pathName 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) parsedRequest = fn.buildRequest(parsedRequest)
specActions.setRequest(req.pathName, req.method, parsedRequest) specActions.setRequest(req.pathName, req.method, parsedRequest)
return fn.execute(req) return fn.execute(req)

View File

@@ -7,7 +7,8 @@ module.exports = function({ configs }) {
buildRequest: Swagger.buildRequest, buildRequest: Swagger.buildRequest,
execute: Swagger.execute, execute: Swagger.execute,
resolve: Swagger.resolve, resolve: Swagger.resolve,
serializeRes: Swagger.serializeRes serializeRes: Swagger.serializeRes,
opId: Swagger.helpers.opId
} }
} }
} }