Skip to content

Commit 86ee54a

Browse files
Copilotmrlubos
andcommitted
fix: preserve empty array body in stripEmptySlots
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
1 parent f505c8c commit 86ee54a

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

packages/openapi-ts/src/plugins/@hey-api/client-core/__tests__/params.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,18 @@ describe('buildClientParams', () => {
344344
description: 'strip empty slots',
345345
params: {},
346346
},
347+
{
348+
args: [[]],
349+
config: [
350+
{
351+
in: 'body',
352+
},
353+
],
354+
description: 'empty array body',
355+
params: {
356+
body: [],
357+
},
358+
},
347359
];
348360

349361
it.each(scenarios)('$description', async ({ args, config, params }) => {

packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/params.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ interface Params {
9494

9595
const stripEmptySlots = (params: Params) => {
9696
for (const [slot, value] of Object.entries(params)) {
97-
if (value && typeof value === 'object' && !Object.keys(value).length) {
97+
if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
9898
delete params[slot as Slot];
9999
}
100100
}

0 commit comments

Comments
 (0)