Empty arrays are stripped from request bodies
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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