Skip to content

fix(tsoa/runtime): handle empty body as undefined#1840

Open
MathieuRA wants to merge 1 commit intolukeautry:masterfrom
MathieuRA:mra-empty-body-fix
Open

fix(tsoa/runtime): handle empty body as undefined#1840
MathieuRA wants to merge 1 commit intolukeautry:masterfrom
MathieuRA:mra-empty-body-fix

Conversation

@MathieuRA
Copy link
Copy Markdown

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you written unit tests?
  • Have you written unit tests that cover the negative cases (i.e.: if bad data is submitted, does the library respond properly)?
  • This PR is associated with an existing issue?

Closing issues

Closes #1839

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello there MathieuRA 👋

Thank you and congrats 🎉 for opening your first PR on this project.✨

We will review the following PR soon! 👀

VannaDii added a commit to tsoa-next/tsoa-next that referenced this pull request Mar 22, 2026
This branch implements behavior derived from
lukeautry/tsoa#1840 in
https://github.com/VannaDii/tsoa-next.

Summary:
- normalize absent request bodies to `undefined` before validation and
controller invocation
- preserve explicit `{}` payloads and malformed JSON behavior
- keep Express, Koa, and Hapi runtime handling aligned
- add focused integration regressions for optional and required
`@Body()` behavior

Tests:
- `npm run build` in `packages/runtime`
- `npm run prepare-test && npm run typecheck && npx mocha --require
ts-node/register --require tsconfig-paths/register
integration/express-server.spec.ts integration/koa-server.spec.ts
integration/hapi-server.spec.ts --grep "treats an absent optional body
as undefined|keeps an explicit empty object body distinct from an absent
body|preserves non-empty body payloads|fails validation for a missing
required body|still errors on malformed json"`
- `npx mocha --require ts-node/register --require
tsconfig-paths/register integration/express-server.spec.ts
integration/koa-server.spec.ts integration/hapi-server.spec.ts`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optional body throw ValidateError if using body-parser

1 participant