mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Import all available header properties from Postman (#6162)
* import all available header properties from Postman * ignore undefined optional field * fix lint * fix test --------- Co-authored-by: Peter C <petoc@users.noreply.github.com> Co-authored-by: jackkav <jackkav@gmail.com>
This commit is contained in:
parent
ee3695064c
commit
45ee825087
@ -33,6 +33,41 @@ describe('postman', () => {
|
|||||||
})) as HttpsSchemaGetpostmanComJsonCollectionV210;
|
})) as HttpsSchemaGetpostmanComJsonCollectionV210;
|
||||||
|
|
||||||
describe('headers', () => {
|
describe('headers', () => {
|
||||||
|
describe('properties', () => {
|
||||||
|
it('should import headers with all properties', () => {
|
||||||
|
const request: Request1 = {
|
||||||
|
header: [
|
||||||
|
{
|
||||||
|
key: 'X-Header1',
|
||||||
|
value: 'value1',
|
||||||
|
description: 'description1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'X-Header2',
|
||||||
|
value: 'value2',
|
||||||
|
disabled: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
const schema = postmanSchema({ requests: [request] });
|
||||||
|
const postman = new ImportPostman(schema);
|
||||||
|
const { headers } = postman.importRequestItem({ request }, 'n/a');
|
||||||
|
|
||||||
|
expect(headers).toEqual([
|
||||||
|
{
|
||||||
|
name: 'X-Header1',
|
||||||
|
value: 'value1',
|
||||||
|
description: 'description1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'X-Header2',
|
||||||
|
value: 'value2',
|
||||||
|
disabled: true,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('awsv4', () => {
|
describe('awsv4', () => {
|
||||||
it('should not duplicate headers', () => {
|
it('should not duplicate headers', () => {
|
||||||
const request: Request1 = {
|
const request: Request1 = {
|
||||||
|
@ -136,9 +136,11 @@ export class ImportPostman {
|
|||||||
url: this.importUrl(request.url),
|
url: this.importUrl(request.url),
|
||||||
parameters: parameters,
|
parameters: parameters,
|
||||||
method: request.method || 'GET',
|
method: request.method || 'GET',
|
||||||
headers: headers.map(({ key, value }) => ({
|
headers: headers.map(({ key, value, disabled, description }) => ({
|
||||||
name: key,
|
name: key,
|
||||||
value,
|
value,
|
||||||
|
...(typeof disabled !== 'undefined' ? { disabled } : {}),
|
||||||
|
...(typeof description !== 'undefined' ? { description } : {}),
|
||||||
})),
|
})),
|
||||||
body: this.importBody(request.body, headers.find(({ key }) => key === 'Content-Type')?.value),
|
body: this.importBody(request.body, headers.find(({ key }) => key === 'Content-Type')?.value),
|
||||||
authentication,
|
authentication,
|
||||||
|
@ -48,17 +48,14 @@ const convertToPostman = (items: Swagger[]) => {
|
|||||||
{
|
{
|
||||||
key: 'SOAPAction',
|
key: 'SOAPAction',
|
||||||
value: api['x-ibm-soap']['soap-action'],
|
value: api['x-ibm-soap']['soap-action'],
|
||||||
disabled: false,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'Content-Type',
|
key: 'Content-Type',
|
||||||
value: swagger.consumes[0],
|
value: swagger.consumes[0],
|
||||||
disabled: false,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'Accept',
|
key: 'Accept',
|
||||||
value: swagger.produces[0],
|
value: swagger.produces[0],
|
||||||
disabled: false,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
body: {
|
body: {
|
||||||
|
Loading…
Reference in New Issue
Block a user