Skip to content

Commit

Permalink
Merge pull request #18 from IncredibleHannes/master
Browse files Browse the repository at this point in the history
Custom values can now override fields in the request header
  • Loading branch information
noahdietz authored Jan 8, 2019
2 parents c142217 + dbddd62 commit 4304809
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lib/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,20 +348,6 @@ function processHeaders(responseCode, op, path, top, options) {
var headers = {};
var levels = [path.path, op.method, responseCode]

// check custom request values for any desired headers; cascading merge
if (options.customValues) {
var curr = options.customValues

var ndx = 0
do {
if (curr['header'] !== undefined) {
headers = merge2(curr['header'], headers)
}

curr = curr[levels[ndx]]
} while (ndx++ < levels.length && curr !== undefined)
}

// handle consumes
if (options.consumes) { // a specific content-type was targeted
if (op.definitionFullyResolved.consumes) {
Expand Down Expand Up @@ -405,6 +391,20 @@ function processHeaders(responseCode, op, path, top, options) {
headers['Accept'] = top.produces[0];
}

// check custom request values for any desired headers; cascading merge
if (options.customValues) {
var curr = options.customValues

var ndx = 0
do {
if (curr['header'] !== undefined) {
headers = merge2(curr['header'], headers)
}

curr = curr[levels[ndx]]
} while (ndx++ < levels.length && curr !== undefined)
}

return headers
}

Expand Down

0 comments on commit 4304809

Please sign in to comment.