From dbddd62e4817254b5c4590f768df50e4ba4eaaa0 Mon Sep 17 00:00:00 2001 From: Johannes Hartmann Date: Tue, 8 Jan 2019 15:49:59 +0100 Subject: [PATCH] Custom values can now override fields in the request header --- lib/process.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/process.js b/lib/process.js index a43c83a..08559d9 100644 --- a/lib/process.js +++ b/lib/process.js @@ -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) { @@ -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 }