Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/oas-to-har/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ export default function oasToHar(

if (operation.isFormUrlEncoded()) {
if (Object.keys(formData.formData || {}).length) {
const cleanFormData = removeUndefinedObjects(JSON.parse(JSON.stringify(formData.formData)));
const cleanFormData = removeUndefinedObjects(formData.formData);

if (cleanFormData !== undefined) {
const postData: PostData = { params: [], mimeType: 'application/x-www-form-urlencoded' };

Expand All @@ -444,7 +445,7 @@ export default function oasToHar(

if (isMultipart || isJSON) {
try {
let cleanBody = removeUndefinedObjects(JSON.parse(JSON.stringify(formData.body)));
let cleanBody = removeUndefinedObjects(formData.body);

if (isMultipart) {
har.postData = { params: [], mimeType: 'multipart/form-data' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,21 @@ function encodeArray({
escape,
isAllowedReserved = false,
}: Omit<StylizerConfig, 'value'> & { value: string[] }) {
const valueEncoder = (str: string) =>
encodeDisallowedCharacters(str, {
const valueEncoder = (str: string) => {
// Handle null values explicitly to prevent join() from converting to empty string
if (str === null) {
return 'null';
}

const result = encodeDisallowedCharacters(str, {
escape,
returnIfEncoded: location === 'query',
isAllowedReserved,
});

return result;
};

switch (style) {
/**
* @example <caption>`style: simple`</caption>
Expand Down
4 changes: 2 additions & 2 deletions packages/oas-to-har/test/parameters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('parameter handling', () => {
parameters: [{ name: 'id', in: 'query' }],
},
{ query: { id: [null, null] } },
[{ name: 'id', value: '&id=' }],
[{ name: 'id', value: 'null&id=null' }],
),
);

Expand Down Expand Up @@ -207,7 +207,7 @@ describe('parameter handling', () => {
],
},
{ query: {} },
[{ name: 'id', value: '&id=' }],
[{ name: 'id', value: 'null&id=null' }],
),
);

Expand Down