Skip to content

Vert.x JSON wrapped in a Multi is not working as expected #8830

@nweike

Description

@nweike

Describe the bug
(Describe the problem clearly and concisely.)
When the JSON content is wrapped in a 'Multi', it is not recognised as a Quarkus web resource, instead it embeds the entire json object in a new object called 'map'.

Here is the code:

@Path("/users/v1")
@Produces(MediaType.APPLICATION_JSON)
public class UserResource {
@GET
@Path("{name}/multi")
@Produces(MediaType.APPLICATION_JSON)
public Multi<JsonObject> multi(@PathParam String name) {
    Multi<JsonObject> multi = Multi.createFrom().items(new JsonObject().put("Hello", name));
    return multi;
}
@GET
@Path("{name}/uni")
@Produces(MediaType.APPLICATION_JSON)
public Uni<JsonObject> uni(@PathParam String name) {
    Uni<JsonObject> multi = Uni.createFrom().item(new JsonObject().put("Hello", name));
    return multi;
}
}

when I access this end point:
localhost:82/users/v1/all/uni
I
it returns a nicely formated json like this:

{
    "Hello": "all"
}

however, when i access localhost:82/users/v1/all/multi

[
    {
        "empty": false,
        "map": {
            "Hello": "all"
        }
    }
]

Expected behavior
(Describe the expected behavior clearly and concisely.)
It is expected to return this :

{
    "Hello": "all"
}

Actual behavior
(Describe the actual behavior clearly and concisely.)

It returns this:

[
    {
        "empty": false,
        "map": {
            "Hello": "all"
        }
    }
]

To Reproduce
Steps to reproduce the behavior:

  1. Create a JAX-RS resource method that returns a Multi
  2. Annotate the method with @produces(MediaType.APPLICATION_JSON) on the methos
  3. Add Multi multi = Multi.createFrom().items(new JsonObject().put("Hello", name));
    return multi; to the bosy of the method

Configuration

# Add your application.properties here, if applicable.

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • Output of uname -a or ver:
  • Output of java -version:
  • GraalVM version (if different from Java):
  • Quarkus version or git rev:
  • Build tool (ie. output of mvnw --version or gradlew --version):

Additional context
(Add any other context about the problem here.)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions