Search in sources :

Example 6 with ResponseHeaders

use of org.apache.servicecomb.swagger.extend.annotations.ResponseHeaders in project incubator-servicecomb-java-chassis by apache.

the class CodeFirstJaxrs method cseResponse.

// public Response getUserResponse() {
// 
// }
@ApiResponse(code = 200, response = User.class, message = "")
@ResponseHeaders({ @ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class) })
@Path("/cseResponse")
@GET
public Response cseResponse(InvocationContext c1) {
    Response response = Response.createSuccess(Status.ACCEPTED, new User());
    Headers headers = response.getHeaders();
    headers.addHeader("h1", "h1v " + c1.getContext().get(Const.SRC_MICROSERVICE).toString());
    InvocationContext c2 = ContextUtils.getInvocationContext();
    headers.addHeader("h2", "h2v " + c2.getContext().get(Const.SRC_MICROSERVICE).toString());
    return response;
}
Also used : Response(org.apache.servicecomb.swagger.invocation.Response) ApiResponse(io.swagger.annotations.ApiResponse) User(org.apache.servicecomb.demo.server.User) ResponseHeaders(org.apache.servicecomb.swagger.extend.annotations.ResponseHeaders) Headers(org.apache.servicecomb.swagger.invocation.response.Headers) InvocationContext(org.apache.servicecomb.swagger.invocation.context.InvocationContext) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ResponseHeaders(org.apache.servicecomb.swagger.extend.annotations.ResponseHeaders) ApiResponse(io.swagger.annotations.ApiResponse)

Aggregations

ResponseHeaders (org.apache.servicecomb.swagger.extend.annotations.ResponseHeaders)6 InvocationContext (org.apache.servicecomb.swagger.invocation.context.InvocationContext)5 ApiResponse (io.swagger.annotations.ApiResponse)3 User (org.apache.servicecomb.demo.server.User)3 Response (org.apache.servicecomb.swagger.invocation.Response)3 Headers (org.apache.servicecomb.swagger.invocation.response.Headers)3 HttpHeaders (org.springframework.http.HttpHeaders)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 ResponseEntity (org.springframework.http.ResponseEntity)2 ResponseHeader (io.swagger.annotations.ResponseHeader)1 MethodAnnotationProcessor (org.apache.servicecomb.swagger.generator.core.MethodAnnotationProcessor)1