Skip to content

Commit

Permalink
Custom values can now override fields in the request header
Browse files Browse the repository at this point in the history
  • Loading branch information
IncredibleHannes committed Jan 8, 2019
1 parent c142217 commit dbddd62
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 dbddd62

Please sign in to comment.