Search in sources :

Example 1 with ResponseHeaders

use of io.servicecomb.swagger.extend.annotations.ResponseHeaders in project java-chassis by ServiceComb.

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() {
    Response response = Response.createSuccess(Status.ACCEPTED, new User());
    response.getHeaders().addHeader("h1", "h1v").addHeader("h2", "h2v");
    return response;
}
Also used : ApiResponse(io.swagger.annotations.ApiResponse) Response(io.servicecomb.core.Response) User(io.servicecomb.demo.server.User) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ResponseHeaders(io.servicecomb.swagger.extend.annotations.ResponseHeaders) ApiResponse(io.swagger.annotations.ApiResponse)

Example 2 with ResponseHeaders

use of io.servicecomb.swagger.extend.annotations.ResponseHeaders in project java-chassis by ServiceComb.

the class CodeFirstSpringmvc method cseResponse.

@ApiResponse(code = 200, response = User.class, message = "")
@ResponseHeaders({ @ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class) })
@RequestMapping(path = "/cseResponse", method = RequestMethod.GET)
public Response cseResponse() {
    Response response = Response.createSuccess(Status.ACCEPTED, new User());
    response.getHeaders().addHeader("h1", "h1v").addHeader("h2", "h2v");
    return response;
}
Also used : ApiResponse(io.swagger.annotations.ApiResponse) Response(io.servicecomb.core.Response) User(io.servicecomb.demo.server.User) ResponseHeaders(io.servicecomb.swagger.extend.annotations.ResponseHeaders) ApiResponse(io.swagger.annotations.ApiResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with ResponseHeaders

use of io.servicecomb.swagger.extend.annotations.ResponseHeaders in project java-chassis by ServiceComb.

the class ResponseHeadersProcessor method process.

@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
    ResponseHeaders responseHeaders = (ResponseHeaders) annotation;
    MethodAnnotationProcessor processor = operationGenerator.getContext().findMethodAnnotationProcessor(ResponseHeader.class);
    for (ResponseHeader responseHeader : responseHeaders.value()) {
        processor.process(responseHeader, operationGenerator);
    }
}
Also used : ResponseHeader(io.swagger.annotations.ResponseHeader) MethodAnnotationProcessor(io.servicecomb.swagger.generator.core.MethodAnnotationProcessor) ResponseHeaders(io.servicecomb.swagger.extend.annotations.ResponseHeaders)

Example 4 with ResponseHeaders

use of io.servicecomb.swagger.extend.annotations.ResponseHeaders in project java-chassis by ServiceComb.

the class CodeFirstSpringmvc method responseEntity.

@ResponseHeaders({ @ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class) })
@RequestMapping(path = "/responseEntity", method = RequestMethod.GET)
public ResponseEntity<User> responseEntity() {
    HttpHeaders headers = new HttpHeaders();
    headers.add("h1", "h1v");
    headers.add("h2", "h2v");
    return new ResponseEntity<User>(new User(), headers, HttpStatus.ACCEPTED);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) User(io.servicecomb.demo.server.User) ResponseHeaders(io.servicecomb.swagger.extend.annotations.ResponseHeaders) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ResponseHeaders (io.servicecomb.swagger.extend.annotations.ResponseHeaders)4 User (io.servicecomb.demo.server.User)3 Response (io.servicecomb.core.Response)2 ApiResponse (io.swagger.annotations.ApiResponse)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 MethodAnnotationProcessor (io.servicecomb.swagger.generator.core.MethodAnnotationProcessor)1 ResponseHeader (io.swagger.annotations.ResponseHeader)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 HttpHeaders (org.springframework.http.HttpHeaders)1 ResponseEntity (org.springframework.http.ResponseEntity)1