-
Notifications
You must be signed in to change notification settings - Fork 0
/
GreetingResource.java
37 lines (30 loc) · 1.14 KB
/
GreetingResource.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.acme.getting.started;
import model.ConcreteChild;
import model.ConcreteContainer;
import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/hello")
public class GreetingResource {
@POST
@Produces(MediaType.TEXT_PLAIN)
public String hello(@RequestBody(description = "some description") ConcreteContainer container) {
ConcreteChild myConcreteChild = container.getChild();
return "Hello RESTEasy" + myConcreteChild.getNickname();
}
@GET
public String testYasson() {
ConcreteContainer concreteContainer = new ConcreteContainer();
concreteContainer.setChild(new ConcreteChild());
concreteContainer.getChild().setNickname("Nick");
Jsonb jsonb = JsonbBuilder.create();
jsonb.toJson(concreteContainer);
ConcreteContainer roundtripContainer = jsonb.fromJson(jsonb.toJson(concreteContainer), ConcreteContainer.class);
return roundtripContainer.getChild().getNickname();
}
}