private List<Map<String, Object>> determineResponses(Method method) { final List<Map<String, Object>> result = Lists.newArrayList(); final ApiResponses annotation = method.getAnnotation(ApiResponses.class); if (null != annotation) { for (ApiResponse response : annotation.value()) { final Map<String, Object> responseDescription = ImmutableMap.<String, Object>of( "code", response.code(), "message", response.message()); result.add(responseDescription); } } return result; }
Response apiOperationResponse = operation.getResponses().get(String.valueOf(apiResponse.code())); if (apiOperationResponse != null) { response.setSchema(apiOperationResponse.getSchema()); Map<String, Response> responses = operation.getResponses(); if (responses != null) { Response apiOperationResponse = responses.get(String.valueOf(apiResponse.code())); if (apiOperationResponse != null) { response.setSchema(apiOperationResponse.getSchema()); if (apiResponse.code() == 0) { operation.defaultResponse(response); } else { operation.response(apiResponse.code(), response);
private static ResponseConfig convert(ApiResponse apiResponse) { ResponseConfig responseConfig = new ResponseConfig(); responseConfig.setCode(apiResponse.code()); responseConfig.setDescription(apiResponse.message()); responseConfig.setResponseClass(apiResponse.response()); responseConfig.setResponseContainer(apiResponse.responseContainer()); responseConfig.setResponseReference(apiResponse.reference()); responseConfig.setResponseHeaders(apiResponse.responseHeaders()); return responseConfig; }
private List<Map<String, Object>> determineResponses(Method method) { final List<Map<String, Object>> result = Lists.newArrayList(); final ApiResponses annotation = method.getAnnotation(ApiResponses.class); if (null != annotation) { for (ApiResponse response : annotation.value()) { final Map<String, Object> responseDescription = ImmutableMap.<String, Object>of( "code", response.code(), "message", response.message()); result.add(responseDescription); } } return result; }
private ApiResponse getApiResponseForErrorCode(int errorCode, HandlerMethod method) { ApiResponses apiResponses = method.getMethodAnnotation(ApiResponses.class); if (apiResponses != null) { for (ApiResponse apiResponse : apiResponses.value()) { if (apiResponse.code() == errorCode) { return apiResponse; } } } return method.getMethodAnnotation(ApiResponse.class); } }
ApiResponse[] apiResponseAnnotations = apiResponses.value(); for (ApiResponse apiResponse : apiResponseAnnotations) { if (!seenResponsesByCode.containsKey(apiResponse.code())) { seenResponsesByCode.put(apiResponse.code(), apiResponse); ModelContext modelContext = returnValue( context.getGroupName(), apiResponse.response(), Optional<ModelReference> responseModel = Optional.absent(); Optional<ResolvedType> type = resolvedType(null, apiResponse); if (isSuccessful(apiResponse.code())) { type = type.or(operationResponse); .code(apiResponse.code()) .message(apiResponse.message()) .responseModel(responseModel.orNull())
private void addResponse(Operation operation, ApiResponse apiResponse) { Map<String, Property> responseHeaders = parseResponseHeaders(apiResponse.responseHeaders()); Response response = new Response().description(apiResponse.message()).headers(responseHeaders); if (apiResponse.code() == 0) { operation.defaultResponse(response); } else { operation.response(apiResponse.code(), response); } if (StringUtils.isNotEmpty(apiResponse.reference())) { response.schema(new RefProperty(apiResponse.reference())); } else if (!isVoid(apiResponse.response())) { Type responseType = apiResponse.response(); final Property property = ModelConverters.getInstance().readAsProperty(responseType); if (property != null) { response.schema(ContainerWrapper.wrapContainer(apiResponse.responseContainer(), property)); appendModels(responseType); } } }
private void addResponse(Operation operation, ApiResponse apiResponse) { Map<String, Property> responseHeaders = parseResponseHeaders(apiResponse.responseHeaders()); Response response = new Response().description(apiResponse.message()).headers(responseHeaders); if (apiResponse.code() == 0) { operation.defaultResponse(response); } else { operation.response(apiResponse.code(), response); } if (StringUtils.isNotEmpty(apiResponse.reference())) { response.schema(new RefProperty(apiResponse.reference())); } else if (!isVoid(apiResponse.response())) { Type responseType = apiResponse.response(); final Property property = ModelConverters.getInstance().readAsProperty(responseType); if (property != null) { response.schema(ContainerWrapper.wrapContainer(apiResponse.responseContainer(), property)); appendModels(responseType); } } }
private void addResponse(Operation operation, ApiResponse apiResponse) { Map<String, Property> responseHeaders = parseResponseHeaders(apiResponse.responseHeaders()); Response response = new Response().description(apiResponse.message()).headers(responseHeaders); if (apiResponse.code() == 0) { operation.defaultResponse(response); } else { operation.response(apiResponse.code(), response); } if (StringUtils.isNotEmpty(apiResponse.reference())) { response.schema(new RefProperty(apiResponse.reference())); } else if (!isVoid(apiResponse.response())) { Type responseType = apiResponse.response(); final Property property = ModelConverters.getInstance().readAsProperty(responseType); if (property != null) { response.schema(ContainerWrapper.wrapContainer(apiResponse.responseContainer(), property)); appendModels(responseType); } } }
private static ResponseConfig convert(ApiResponse apiResponse) { ResponseConfig responseConfig = new ResponseConfig(); responseConfig.setCode(apiResponse.code()); responseConfig.setDescription(apiResponse.message()); responseConfig.setResponseClass(apiResponse.response()); responseConfig.setResponseContainer(apiResponse.responseContainer()); responseConfig.setResponseReference(apiResponse.reference()); responseConfig.setResponseHeaders(apiResponse.responseHeaders()); return responseConfig; }
result.put(apiResponse.code(), response);
private void addResponse(Operation operation, ApiResponse apiResponse, JsonView jsonView) { Map<String, Property> responseHeaders = parseResponseHeaders(apiResponse.responseHeaders(), jsonView); Map<String, Object> examples = parseExamples(apiResponse.examples()); Response response = new Response() .description(apiResponse.message()) .headers(responseHeaders); response.setExamples(examples); if (apiResponse.code() == 0) { operation.defaultResponse(response); } else { operation.response(apiResponse.code(), response); } if (StringUtils.isNotEmpty(apiResponse.reference())) { response.schema(new RefProperty(apiResponse.reference())); } else if (!isVoid(apiResponse.response())) { Type responseType = apiResponse.response(); final Property property = ModelConverters.getInstance().readAsProperty(responseType, jsonView); if (property != null) { response.schema(ContainerWrapper.wrapContainer(apiResponse.responseContainer(), property)); appendModels(responseType); } } }
result.put(apiResponse.code(), response);
for (ApiResponse swaggerResponse : swaggerResponses.value()) { ResponseCode rc = new ResponseCode(this); rc.setCode(swaggerResponse.code()); rc.setCondition(swaggerResponse.message());
@SuppressWarnings("deprecation") private void addResponse(Operation operation, ApiResponse apiResponse, JsonView jsonView) { Map<String, Property> responseHeaders = parseResponseHeaders(apiResponse.responseHeaders(), jsonView); Map<String, Object> examples = parseExamples(apiResponse.examples()); Response response = new Response().description(apiResponse.message()).headers(responseHeaders); response.setExamples(examples); if (apiResponse.code() == 0) { operation.defaultResponse(response); } else { operation.response(apiResponse.code(), response); } if (StringUtils.isNotEmpty(apiResponse.reference())) { response.schema(new RefProperty(apiResponse.reference())); } else if (!isVoid(apiResponse.response())) { Type responseType = apiResponse.response(); final Property property = ModelConverters.getInstance().readAsProperty(responseType, jsonView); if (property != null) { response.schema(ContainerWrapper.wrapContainer(apiResponse.responseContainer(), property)); appendModels(responseType); } } }