mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +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;
|
||||
|
||||
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', () => {
|
||||
it('should not duplicate headers', () => {
|
||||
const request: Request1 = {
|
||||
|
@ -136,9 +136,11 @@ export class ImportPostman {
|
||||
url: this.importUrl(request.url),
|
||||
parameters: parameters,
|
||||
method: request.method || 'GET',
|
||||
headers: headers.map(({ key, value }) => ({
|
||||
headers: headers.map(({ key, value, disabled, description }) => ({
|
||||
name: key,
|
||||
value,
|
||||
...(typeof disabled !== 'undefined' ? { disabled } : {}),
|
||||
...(typeof description !== 'undefined' ? { description } : {}),
|
||||
})),
|
||||
body: this.importBody(request.body, headers.find(({ key }) => key === 'Content-Type')?.value),
|
||||
authentication,
|
||||
|
@ -48,17 +48,14 @@ const convertToPostman = (items: Swagger[]) => {
|
||||
{
|
||||
key: 'SOAPAction',
|
||||
value: api['x-ibm-soap']['soap-action'],
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
key: 'Content-Type',
|
||||
value: swagger.consumes[0],
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
key: 'Accept',
|
||||
value: swagger.produces[0],
|
||||
disabled: false,
|
||||
},
|
||||
],
|
||||
body: {
|
||||
|
Loading…
Reference in New Issue
Block a user