- Common ways to obtain Response
private void myMethod () {Response r =
new Response()
String description;new Response().description(description)
Operation operation;Object key;operation.getResponses().get(key)
- Smart code suggestions by Codota
}
/** * This method will convert ballerina @Resource to ballerina @OperationAdaptor. * * @param resource Resource array to be convert. * @return Operation Adaptor object of given resource */ private OperationAdaptor convertResourceToOperation(BLangFunction resource, String httpMethod, int idIncrement) { OperationAdaptor op = new OperationAdaptor(); if (resource != null) { op.setHttpOperation(httpMethod); op.setPath('/' + resource.getName().getValue()); Response response = new Response() .description("Successful") .example(MediaType.APPLICATION_JSON, "Ok"); op.getOperation().response(200, response); // Replacing all '_' with ' ' to keep the consistency with what we are doing in swagger -> bal // @see BallerinaOperation#buildContext String resName = resource.getName().getValue().replaceAll("_", " "); op.getOperation().setOperationId(getOperationId(idIncrement, resName)); op.getOperation().setParameters(null); // Parsing annotations. this.parseResourceConfigAnnotationAttachment(resource, op); this.parseResourceInfo(resource, op.getOperation(), httpMethod); this.addResourceParameters(resource, op); this.parseResponsesAnnotationAttachment(resource, op.getOperation()); } return op; }
final MediaType type = IterableExtensions.<MediaType>head(rapidResponse.getMediaTypes()); if ((type != null)) { swaggerResponse.example(IterableExtensions.<MediaType>head(rapidResponse.getMediaTypes()).getName(), this.renderExample(example.getBody(), type.getName()));