private ResponseWithStatusCode buildResponse(Function<Type, Model> modelFactory, Map<String, Object> attributes, Predicate<Integer> statusCode) { Response response = new Response(); String description = (String) attributes.get("apiResponse.message"); Class type = (Class) attributes.get("apiResponse.response"); if (!isVoid(type)) { response.setResponseSchema(modelFactory.apply(type)); } response.setDescription(description); buildResponseHeader(attributes, "apiResponse.responseHeaders", response::addHeader); Integer code = (Integer) attributes.get("apiResponse.code"); String key = code.toString(); if (statusCode.test(code)) { key += "(" + type.getSimpleName() + ")"; } return new ResponseWithStatusCode(key, response); }
public static void correctResponses(Operation operation) { int okCode = Status.OK.getStatusCode(); String strOkCode = String.valueOf(okCode); Response okResponse = null; for (Entry<String, Response> responseEntry : operation.getResponses().entrySet()) { Response response = responseEntry.getValue(); if (StringUtils.isEmpty(response.getDescription())) { response.setDescription("response of " + responseEntry.getKey()); } if (operation.getResponses().get(strOkCode) != null) { continue; } int statusCode = NumberUtils.toInt(responseEntry.getKey()); if ("default".equals(responseEntry.getKey())) { statusCode = okCode; } if (Family.SUCCESSFUL.equals(Family.familyOf(statusCode))) { okResponse = response; } } if (okResponse != null) { operation.addResponse(strOkCode, okResponse); } }
private static void generateResponse(Swagger swagger, ResponseConfig responseConfig) { Response response = new Response(); Property property = generateResponseProperty(swagger, responseConfig); response.setSchema(property); response.setDescription(responseConfig.getDescription()); if (responseConfig.getResponseHeaders() != null) { Map<String, Property> headers = generateResponseHeader(swagger, responseConfig.getResponseHeaders()); response.setHeaders(headers); } responseConfig.setResponse(response); }
public Response description(String description) { this.setDescription(description); return this; }
private static void mergeResponse(Operation operation, ResponseConfig responseConfig) { if (operation.getResponses() == null) { operation.response(responseConfig.getCode(), responseConfig.getResponse()); return; } Response response = operation.getResponses().get(String.valueOf(responseConfig.getCode())); if (response == null) { operation.response(responseConfig.getCode(), responseConfig.getResponse()); return; } Response sourceResp = responseConfig.getResponse(); if (StringUtils.isNotEmpty(sourceResp.getDescription()) && StringUtils.isEmpty(response.getDescription())) { response.setDescription(sourceResp.getDescription()); } if (sourceResp.getSchema() != null && response.getSchema() == null) { response.setSchema(sourceResp.getSchema()); } if (sourceResp.getExamples() != null && response.getExamples() == null) { response.setExamples(sourceResp.getExamples()); } if (sourceResp.getHeaders() != null && response.getHeaders() == null) { response.setHeaders(sourceResp.getHeaders()); } if (sourceResp.getVendorExtensions() != null && response.getVendorExtensions() == null) { response.setVendorExtensions(sourceResp.getVendorExtensions()); } }
private Response responseNoContent() { Response res = new Response(); res.setDescription(DESCRIPTION_ERROR); return res; }
private Response getDefaultResponse() { Response response = new Response(); response.setDescription("OK"); return response; }
private Response getDefaultResponse() { Response response = new Response(); response.setDescription("OK"); return response; }
private Response responseOk() { Response res = new Response(); res.setDescription(DESCRIPTION_SUCCESS); return res; }
private ResponseWithStatusCode buildResponse(Function<Type, Model> modelFactory, Map<String, Object> attributes, Predicate<Integer> statusCode) { Response response = new Response(); String description = (String) attributes.get("apiResponse.message"); Class type = (Class) attributes.get("apiResponse.response"); if (!isVoid(type)) { response.setResponseSchema(modelFactory.apply(type)); } response.setDescription(description); buildResponseHeader(attributes, "apiResponse.responseHeaders", response::addHeader); Integer code = (Integer) attributes.get("apiResponse.code"); String key = code.toString(); if (statusCode.test(code)) { key += "(" + type.getSimpleName() + ")"; } return new ResponseWithStatusCode(key, response); }
public static void correctResponses(Operation operation) { int okCode = Status.OK.getStatusCode(); String strOkCode = String.valueOf(okCode); Response okResponse = null; for (Entry<String, Response> responseEntry : operation.getResponses().entrySet()) { Response response = responseEntry.getValue(); if (StringUtils.isEmpty(response.getDescription())) { response.setDescription("response of " + responseEntry.getKey()); } if (operation.getResponses().get(strOkCode) != null) { continue; } int statusCode = NumberUtils.toInt(responseEntry.getKey()); if ("default".equals(responseEntry.getKey())) { statusCode = okCode; } if (Family.SUCCESSFUL.equals(Family.familyOf(statusCode))) { okResponse = response; } } if (okResponse != null) { operation.addResponse(strOkCode, okResponse); } }
private Response responseGenericError() { Response res = new Response(); res.setDescription(DESCRIPTION_ERROR); res.setSchema(refProperty(modelForPodo(ServiceErrorResponse.class))); return res; }
private Response responseOk(Class<?> type) { Response res = new Response(); res.setDescription(DESCRIPTION_SUCCESS); if (type == null) { return res; } res.setSchema(refProperty(modelForPodo(type))); return res; }
private Response responseOk(ServiceDocument template) { Response res = new Response(); res.setDescription(DESCRIPTION_SUCCESS); res.setSchema(refProperty(modelForServiceDocument(template))); return res; }
Response response = new Response(); if (attributes.containsKey(ConverterConstants.ATTR_DESCRIPTION)) { response.setDescription(ConverterUtils .getStringLiteralValue(attributes.get(ConverterConstants.ATTR_DESCRIPTION)));
private static void generateResponse(Swagger swagger, ResponseConfig responseConfig) { Response response = new Response(); Property property = generateResponseProperty(swagger, responseConfig); response.setSchema(property); response.setDescription(responseConfig.getDescription()); if (responseConfig.getResponseHeaders() != null) { Map<String, Property> headers = generateResponseHeader(swagger, responseConfig.getResponseHeaders()); response.setHeaders(headers); } responseConfig.setResponse(response); }
private static void mergeResponse(Operation operation, ResponseConfig responseConfig) { if (operation.getResponses() == null) { operation.response(responseConfig.getCode(), responseConfig.getResponse()); return; } Response response = operation.getResponses().get(String.valueOf(responseConfig.getCode())); if (response == null) { operation.response(responseConfig.getCode(), responseConfig.getResponse()); return; } Response sourceResp = responseConfig.getResponse(); if (StringUtils.isNotEmpty(sourceResp.getDescription()) && StringUtils.isEmpty(response.getDescription())) { response.setDescription(sourceResp.getDescription()); } if (sourceResp.getSchema() != null && response.getSchema() == null) { response.setSchema(sourceResp.getSchema()); } if (sourceResp.getExamples() != null && response.getExamples() == null) { response.setExamples(sourceResp.getExamples()); } if (sourceResp.getHeaders() != null && response.getHeaders() == null) { response.setHeaders(sourceResp.getHeaders()); } if (sourceResp.getVendorExtensions() != null && response.getVendorExtensions() == null) { response.setVendorExtensions(sourceResp.getVendorExtensions()); } }
response.setDescription(translate(aReturn.descriptionKey(), aReturn.description()));
response.setDescription(translate(aReturn.descriptionKey(), aReturn.description()));
swaggerResponse.setDescription(this.getMessageDocumentation(rapidResponse)); if ((typeName != null)) { final RefProperty property = new RefProperty();