Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated openAPI shows example in application/json instead of specified text/plain #3260

Open
jiramares opened this issue Dec 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jiramares
Copy link

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"
@jiramares jiramares added the bug Something isn't working label Dec 19, 2024
@jiramares
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant