Fixed validation issue where content type header was reported missing even if present

This commit is contained in:
Vishal Shingala
2021-02-17 15:02:25 +05:30
parent 845737fa63
commit 3c082c6873
3 changed files with 13 additions and 2 deletions

View File

@@ -1865,7 +1865,7 @@ module.exports = {
return null;
}
_.forOwn(response.headers, (value, key) => {
if (key !== 'Content-Type') {
if (_.toLower(key) !== 'content-type') {
if (value.$ref) {
// the convert to PmHeader function handles the
// schema-faking
@@ -3726,7 +3726,8 @@ module.exports = {
return false;
}
h.name = hName;
return h.required;
// exclude non-required and implicit header from further validation
return h.required && !_.includes(IMPLICIT_HEADERS, _.toLower(hName));
}), (header) => {
if (!_.find(resHeaders, (param) => { return param.key === header.name; })) {

View File

@@ -35,6 +35,12 @@ paths:
description: Null response
default:
description: unexpected error
headers:
content-type:
description: content-type of response body
required: true
schema:
type: string
content:
application/json:
schema:

View File

@@ -415,6 +415,10 @@ describe('VALIDATE FUNCTION TESTS ', function () {
the mismatch for header-1 should contain correct index as in request.
*/
expect(_.endsWith(resultObj.mismatches[0].transactionJsonPath, '[2].value')).to.eql(true);
_.forEach(resultObj.responses, (response) => {
expect(response.matched).to.be.true;
expect(response.mismatches).to.have.lengthOf(0);
});
done();
});
});