Browse Source

take advantage of Swagger-Client opId improvements

bubble
Kyle Shockey 7 years ago
parent
commit
6e40d04741
2 changed files with 13 additions and 5 deletions
  1. +11
    -4
      src/core/plugins/spec/actions.js
  2. +2
    -1
      src/core/plugins/swagger-js/index.js

+ 11
- 4
src/core/plugins/spec/actions.js View File

@@ -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)


+ 2
- 1
src/core/plugins/swagger-js/index.js View File

@@ -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
}
}
}

Loading…
Cancel
Save