private void addHeaderToResponse() { for (Entry<String, Response> responseEntry : operation.getResponses().entrySet()) { Response response = responseEntry.getValue(); for (Entry<String, Property> entry : responseHeaderMap.entrySet()) { if (response.getHeaders() != null && response.getHeaders().containsKey(entry.getKey())) { continue; } response.addHeader(entry.getKey(), entry.getValue()); } } }
public void init(SwaggerToClassGenerator swaggerToClassGenerator, Response response) { if (javaType == null) { javaType = swaggerToClassGenerator.convert(response.getSchema()); } if (response.getHeaders() == null) { return; } for (Entry<String, Property> entry : response.getHeaders().entrySet()) { JavaType headerJavaType = swaggerToClassGenerator.convert(entry.getValue()); headers.put(entry.getKey(), headerJavaType); } }
Map<String, Property> headers = response.getHeaders(); if (MapUtils.isNotEmpty(headers)) { descriptionBuilder.newLine(true).boldText(labels.getLabel(HEADERS_COLUMN)).text(COLON);
protected void convertResponses() { if (swagger.getPaths() == null) { return; } for (Path path : swagger.getPaths().values()) { for (Operation operation : path.getOperations()) { for (Response response : operation.getResponses().values()) { convert(response.getSchema()); Map<String, Property> headers = response.getHeaders(); if (headers == null) { continue; } for (Property header : headers.values()) { convert(header); } } } } }
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 void addHeaderToResponse() { for (Entry<String, Response> responseEntry : operation.getResponses().entrySet()) { Response response = responseEntry.getValue(); for (Entry<String, Property> entry : responseHeaderMap.entrySet()) { if (response.getHeaders() != null && response.getHeaders().containsKey(entry.getKey())) { continue; } response.addHeader(entry.getKey(), entry.getValue()); } } }
private boolean doSetLocation() { Map<String, Property> headers = operation.getResponses().get("201").getHeaders(); return headers != null && headers.containsKey("Location"); } }
@Override public void response(String status, Response response) { if (!(response instanceof RefResponse)) { response.setHeaders(fillMap(response.getHeaders())); } }
public void init(SwaggerToClassGenerator swaggerToClassGenerator, Response response) { if (javaType == null) { javaType = swaggerToClassGenerator.convert(response.getSchema()); } if (response.getHeaders() == null) { return; } for (Entry<String, Property> entry : response.getHeaders().entrySet()) { JavaType headerJavaType = swaggerToClassGenerator.convert(entry.getValue()); headers.put(entry.getKey(), headerJavaType); } }
public void init(ClassLoader classLoader, String packageName, Swagger swagger, Response response) { if (javaType == null) { Property property = response.getSchema(); javaType = ConverterMgr.findJavaType(classLoader, packageName, swagger, property); } if (response.getHeaders() == null) { return; } for (Entry<String, Property> entry : response.getHeaders().entrySet()) { JavaType headerJavaType = ConverterMgr.findJavaType(classLoader, packageName, swagger, entry.getValue()); headers.put(entry.getKey(), headerJavaType); } }
private void validateResponse(Response actualResponse, Response expectedResponse, String responseName, String httpMethod, String path) { if (expectedResponse != null) { validateProperty(actualResponse.getSchema(), expectedResponse.getSchema(), String.format("Checking response schema of response '%s' of '%s' operation of path '%s'", responseName, httpMethod, path)); validateResponseHeaders(actualResponse.getHeaders(), expectedResponse.getHeaders(), responseName, httpMethod, path); } }
private void validateResponse(Response actualResponse, Response expectedResponse, String responseName, String httpMethod, String path) { if (expectedResponse != null) { validateProperty(actualResponse.getSchema(), expectedResponse.getSchema(), String.format("Checking response schema of response '%s' of '%s' operation of path '%s'", responseName, httpMethod, path)); validateResponseHeaders(actualResponse.getHeaders(), expectedResponse.getHeaders(), responseName, httpMethod, path); } }
private void walkResponse(Response response) { // response has already been visited Model schema = response.getResponseSchema(); if (schema != null) { callbacks.model(schema); callbacks.any(schema); walkModel(schema); } if (response.getHeaders() != null) { for (Entry<String, Property> header : response.getHeaders().entrySet()) { callbacks.header(header.getKey(), header.getValue()); callbacks.property(null, header.getValue()); callbacks.any(header.getValue()); walkProperty(header.getValue()); } } }
private PutMethodResponseInput getCreateResponseInput(RestApi api, String modelContentType, Response response) { final PutMethodResponseInput input = new PutMethodResponseInput(); // add response headers if (response.getHeaders() != null) { input.setResponseParameters(new HashMap<>()); response.getHeaders().entrySet().forEach( e -> input.getResponseParameters().put("method.response.header." + e.getKey(), e.getValue().getRequired())); } // if the schema references an existing model, use that model for the response Optional<Model> modelOpt = getModel(api, response); if (modelOpt.isPresent()) { input.setResponseModels(new HashMap<>()); String modelName = modelOpt.get().getName(); input.getResponseModels().put(modelContentType, modelName); this.processedModels.add(modelName); LOG.info("Found reference to existing model " + modelName); } else { // generate a model based on the schema if the model doesn't already exist if (response.getSchema() != null) { String modelName = generateModelName(response); LOG.info("Creating new model referenced from response: " + modelName); createModel(api, modelName, response.getSchema(), modelContentType); input.setResponseModels(new HashMap<>()); input.getResponseModels().put(modelContentType, modelName); } } return input; }
protected void convertResponses() { if (swagger.getPaths() == null) { return; } for (Path path : swagger.getPaths().values()) { for (Operation operation : path.getOperations()) { for (Response response : operation.getResponses().values()) { convert(response.getSchema()); Map<String, Property> headers = response.getHeaders(); if (headers == null) { continue; } for (Property header : headers.values()) { convert(header); } } } } }
/** * The method generates a mocked response based on the provided {@link Response} and the * <code>httpStatusCode</code>. * @param httpStatusCode The HTTP status code that the mocked response will have. Please note that * any mock response with status code different from OK (200), will be * marked as disabled. * @param response The Swagger response that the mocked response will be based on. * @return A new {@link RestMockResponse} based on the provided {@link Response}. */ private RestMockResponse generateResponse(final int httpStatusCode, final Response response){ RestMockResponse restMockResponse = new RestMockResponse(); restMockResponse.setName(response.getDescription()); restMockResponse.setHttpStatusCode(httpStatusCode); restMockResponse.setUsingExpressions(true); if(httpStatusCode == DEFAULT_RESPONSE_CODE){ restMockResponse.setStatus(RestMockResponseStatus.ENABLED); } else { restMockResponse.setStatus(RestMockResponseStatus.DISABLED); } if(response.getHeaders() != null){ for(Map.Entry<String, Property> headerEntry : response.getHeaders().entrySet()){ String headerName = headerEntry.getKey(); HttpHeader httpHeader = new HttpHeader(); httpHeader.setName(headerName); // Swagger does not include an example value for the response. restMockResponse.getHttpHeaders().add(httpHeader); } } return restMockResponse; }
response.setExtensions(convert(v2Response.getVendorExtensions())); if (v2Response.getHeaders() != null && v2Response.getHeaders().size() > 0) { response.setHeaders(convertHeaders(v2Response.getHeaders()));
response.setExtensions(convert(v2Response.getVendorExtensions())); if (v2Response.getHeaders() != null && v2Response.getHeaders().size() > 0) { response.setHeaders(convertHeaders(v2Response.getHeaders()));
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()); } }
Map<String, Property> _headers = swaggerResponse.getHeaders(); boolean _tripleEquals = (_headers == null); if (_tripleEquals) { prop.setItems(this.createSwaggerPropertyWithConstraints(it)); prop.setDescription(this._zenModelHelper.getDocumentation(it)); swaggerResponse.getHeaders().put(it.getName(), prop); } else { final Property prop_1 = this.createSwaggerPropertyWithConstraints(it); prop_1.setDescription(this._zenModelHelper.getDocumentation(it)); swaggerResponse.getHeaders().put(it.getName(), prop_1);