Generated openAPI shows example in application/json instead of specified text/plain
Describe the bug
Specifying text/plain media type for response causes openAPI shows response example in wrong media type (stilll uses application/json).
To Reproduce
Following endpoint specifies response media type to text/plain:
val ep2 = Endpoint(RoutePattern.GET / "greeting" / string("name"))
.outCodec(HttpCodec.content[Greeting](MediaType.text.plain))
and generated openAPI shows response as (the media type is right text/plain):
{
"msg": "string"
}
Expected behaviour The response example should be:
string
Dependencies:
"dev.zio" %% "zio" % "2.1.9",
"dev.zio" %% "zio-http" % "3.0.1"
"dev.zio" %% "zio-schema" % "1.4.1"
The same is also true for error channel:
val ep5 = Endpoint(RoutePattern.GET / "greeting3" / nameParam / "exclamation" / boolParam)
.copy(error = HttpCodec.content[Greeting](MediaType.text.plain) ++ HttpCodec.status(Status.NotFound))
.outCodec(HttpCodec.content[Greeting](MediaType.text.plain))
the example error response is
{
"msg": "string"
}
not plain text
string
The examples are currently explicitly created for json. We need to make this dynamic by the media type in the codec
/bounty $150
💎 $150 bounty • ZIO
Steps to solve:
- Start working: Comment
/attempt #3260with your implementation plan - Submit work: Create a pull request including
/claim #3260in the PR body to claim the bounty - Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts
❗ Important guidelines:
- To claim a bounty, you need to provide a short demo video of your changes in your pull request
- If anything is unclear, ask for clarification before starting as this will help avoid potential rework
- Low quality AI PRs will not receive review and will be closed
- Do not ask to be assigned unless you've contributed before
Thank you for contributing to zio/zio-http!
| Attempt | Started (UTC) | Solution | Actions |
|---|---|---|---|
| 🟢 @AltuisticIsopod | Nov 01, 2025, 05:39:35 AM | #3775 | Reward |
| 🟢 @luffy-orf | Jun 05, 2025, 06:34:12 AM | WIP | |
| 🟢 @ffprivacy | Jan 24, 2025, 08:17:51 PM | WIP | |
| 🟢 @Pranav-P-S | Sep 26, 2025, 02:16:14 PM | WIP |
/attempt #3260
/attempt #3260
/attempt #3260