Skip to content

Commit 4018387

Browse files
committed
feat(operationalParameter): Default to config headers for header params
1 parent f3c384d commit 4018387

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

package-lock.json

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/openApi/v3/parser/getOperationParameter.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ export const getOperationParameter = (openApi: OpenApi, parameter: OpenApiParame
5454
operationParameter.base = model.base;
5555
operationParameter.template = model.template;
5656
operationParameter.imports.push(...model.imports);
57-
operationParameter.default = getModelDefault(schema);
57+
operationParameter.default =
58+
parameter.in === 'header'
59+
? `this.httpRequest.config.HEADERS['${parameter.name}']`
60+
: getModelDefault(schema);
61+
5862
return operationParameter;
5963
} else {
6064
const model = getModel(openApi, schema);
@@ -80,11 +84,15 @@ export const getOperationParameter = (openApi: OpenApi, parameter: OpenApiParame
8084
operationParameter.maxProperties = model.maxProperties;
8185
operationParameter.minProperties = model.minProperties;
8286
operationParameter.pattern = getPattern(model.pattern);
83-
operationParameter.default = model.default;
8487
operationParameter.imports.push(...model.imports);
8588
operationParameter.enum.push(...model.enum);
8689
operationParameter.enums.push(...model.enums);
8790
operationParameter.properties.push(...model.properties);
91+
92+
// param default if the value is a header should be the config header
93+
operationParameter.default =
94+
parameter.in === 'header' ? `this.httpRequest.config.HEADERS['${parameter.name}']` : model.default;
95+
8896
return operationParameter;
8997
}
9098
}

0 commit comments

Comments
 (0)