readmeio / readmeio/api

Empty arrays are stripped from request bodies

Open
#882 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
697
Forks
31
Avg merge
3d 21h
Merged PRs (30d)
10

Description

Empty arrays stripped from my request bodies, even when they are specified as "required" in the schema. Is this the intended behavior?

https://github.com/readmeio/oas/blob/main/packages/oas-to-har/src/index.ts#L442
https://github.com/readmeio/remove-undefined-objects/blob/5.0.0/src/index.ts#L27

My current workaround is the following

import * as ruo from 'remove-undefined-objects';
Object.defineProperty(ruo, 'default', {
  get: () => (obj: unknown) => obj,
});

The API I'm working with needs me to send an empty array, it won't accept a missing field in the body.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at packages/oas-to-har/src/index.ts around line 442 and compare its use of remove-undefined-objects with src/index.ts at remove-undefined-objects 5.0.0 line 27. Reproduce a request body containing a required empty array, then verify that undefined values are still removed while the empty array remains present.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.