Skip to content

Conversation

@developerfred
Copy link

fix #3861

- Fixes zio#3868: OpenAPI generator now includes discriminator property in each case schema
- When using @discriminatorName and @casename annotations on sealed traits,
  the generated OpenAPI spec now properly includes the discriminator property
  in each individual case schema, not just at the union level
- This ensures proper oneOf with discriminator structure as expected by OpenAPI spec
Problem:
- Endpoints with NoContent status failed on client side with "Malformed request body failed to decode: Non-empty body cannot be decoded as Unit"
- Server correctly omits content-length header for NoContent responses (following HTTP spec)
- Client depended on content-length header existence to decode Unit values
- This created a mismatch where client tried to decode non-empty body as Unit

Solution:
- Modified BodyCodec.decodeFromBody signatures to accept Status parameter
- Updated unit decoding logic to treat body as empty for NoContent status
- Updated EncoderDecoder to pass Status to decodeFromBody calls
- Added necessary Status import to BodyCodec

Changes:
- BodyCodec.scala: Updated decodeFromBody method signatures and unit decoding logic
- EncoderDecoder.scala: Updated decodeBody method signature and calls to pass Status
- Added Status import to BodyCodec.scala

This ensures NoContent responses are properly handled on client side while maintaining backward compatibility.
@netlify
Copy link

netlify bot commented Dec 23, 2025

Deploy Preview for zio-http failed. Why did it fail? →

Name Link
🔨 Latest commit 5d4855d
🔍 Latest deploy log https://app.netlify.com/projects/zio-http/deploys/694ad4df1728a9000890fe73

@github-actions
Copy link
Contributor

👋 This PR is being automatically closed because it has had a failed CI build for over 3 days.

If you're still working on this, please:

  1. Fix any failing tests or build issues
  2. Push your changes
  3. Reopen this PR once the build passes

Thank you for your contribution! 🙏

@github-actions github-actions bot closed this Dec 27, 2025
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.

Endpoint with NoContent status cannot succeed on client side

1 participant