REST response body annotation.
Annotation used to denote an HTTP response body.
Can be used in the following locations:
- Methods and return types of server-side and client-side @Response-annotated interfaces.
Public methods of @Response-annotated methods
On @Response
-annotated classes, this method can be used to denote a POJO to use as the response.
The method must be public and be one of the following:
- A public no-arg method with a POJO return type.
- A public one-arg method with a void return type that takes in a
Reader
or OutputStream
.
Example:
@RestMethod
public AddPetSuccess addPet() {
addPet(pet);
return new AddPetSuccess(...);
}
@Response
public class AddPetSuccess {
@ResponseBody
public Pet getPet() {...}
}
Example:
@Response
public class MyCustomJsonResponse {
@ResponseHeader("Content-Type")
public String getContentType() {
return "application/json";
}
@ResponseBody
public void writeTo(Writer out) {
out.write("{'foo':'bar'}");
}
}
Methods and return types of server-side and client-side @Response-annotated interfaces