@@ -3,6 +3,7 @@ import fetch from 'node-fetch'
33import { getOperations } from '../operations.js'
44
55import { addBody } from './body.js'
6+ import { getRequestParams } from './params.js'
67import { parseResponse , getFetchError } from './response.js'
78import { shouldRetry , waitForRetry , MAX_RETRY } from './retry.js'
89import { getUrl } from './url.js'
@@ -32,12 +33,23 @@ const callMethod = async function ({ method, basePath, defaultHeaders, agent, gl
3233 return parsedResponse
3334}
3435
35- const getOpts = function ( { method : { verb, parameters } , defaultHeaders, agent, requestParams : { body } , opts } ) {
36+ const getOpts = function ( { method : { verb, parameters } , defaultHeaders, agent, requestParams, opts } ) {
37+ const { body } = requestParams
3638 const optsA = addHttpMethod ( verb , opts )
37- const optsB = addDefaultHeaders ( defaultHeaders , optsA )
38- const optsC = addBody ( body , parameters , optsB )
39- const optsD = addAgent ( agent , optsC )
40- return optsD
39+ const optsB = addHeaderParams ( parameters , requestParams , optsA )
40+ const optsC = addDefaultHeaders ( defaultHeaders , optsB )
41+ const optsD = addBody ( body , parameters , optsC )
42+ const optsE = addAgent ( agent , optsD )
43+ return optsE
44+ }
45+
46+ // Add header parameters
47+ const addHeaderParams = function ( parameters , requestParams , opts ) {
48+ if ( parameters . header === undefined ) {
49+ return opts
50+ }
51+
52+ return { ...opts , headers : getRequestParams ( parameters . header , requestParams , 'header parameter' ) }
4153}
4254
4355// Add the HTTP method based on the OpenAPI definition
0 commit comments