mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Skip automatic header detection when "keepImplicitHeaders" is active, to prevent duplicate headers.
This commit is contained in:
@@ -2356,7 +2356,10 @@ module.exports = {
|
||||
}
|
||||
pmBody = this.convertToPmBody(reqBody, REQUEST_TYPE.ROOT, components, options, schemaCache);
|
||||
item.request.body = pmBody.body;
|
||||
if (!options.keepImplicitHeaders || (reqParams.header && reqParams.header.length === 0)) {
|
||||
if (!options.keepImplicitHeaders || (!_.find(reqParams.header, (h) => {
|
||||
return _.toLower(_.get(h, 'name')) === 'content-type';
|
||||
}))) {
|
||||
// Add detected content-type header
|
||||
item.request.addHeader(pmBody.contentHeader);
|
||||
}
|
||||
// extra form headers if encoding is present in request Body.
|
||||
|
||||
@@ -317,7 +317,7 @@ describe('CONVERT FUNCTION TESTS ', function() {
|
||||
.to.equal('Content-Type');
|
||||
expect(conversionResult.output[0].data.item[0].item[1].request.header[1].value)
|
||||
.to.equal('application/json');
|
||||
expect(conversionResult.output[0].data.item[0].item[1].request.header[2]).to.equal(undefined);
|
||||
expect(conversionResult.output[0].data.item[0].item[1].request.header).to.have.length(2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -329,7 +329,7 @@ describe('CONVERT FUNCTION TESTS ', function() {
|
||||
keepImplicitHeaders: false
|
||||
}, (err, conversionResult) => {
|
||||
expect(err).to.be.null;
|
||||
expect(conversionResult.output[0].data.item[0].item[0].request.header).to.equal(undefined);
|
||||
expect(conversionResult.output[0].data.item[0].item[1].request.header).to.have.length(1);
|
||||
expect(conversionResult.output[0].data.item[0].item[1].request.header[0].key)
|
||||
.to.equal('Content-Type');
|
||||
expect(conversionResult.output[0].data.item[0].item[1].request.header[0].value)
|
||||
|
||||
Reference in New Issue
Block a user