@Test public void testProcessOperation(@Injectable final List<Parameter> inputParameterList, @Injectable final List<Parameter> outputParameterList, @Injectable final ApiResponse incomingResponse, @Injectable final ApiResponse resolvedResponse) throws Exception { Operation operation = new Operation(); operation.setParameters(inputParameterList); final String ref = "http: ApiResponse refResponse = new ApiResponse().$ref(ref); operation.responses(new ApiResponses().addApiResponse("200", refResponse)); operation.getResponses().addApiResponse("400", incomingResponse); new Expectations() {{ new ParameterProcessor(cache, openAPI); times = 1; result = parameterProcessor; new ResponseProcessor(cache, openAPI); times = 1; result = responseProcessor; parameterProcessor.processParameters(inputParameterList); times = 1; result = outputParameterList; responseProcessor.processResponse(refResponse); times = 1; RefUtils.computeRefFormat(ref); times = 1; cache.loadRef(ref, RefFormat.URL, ApiResponse.class); times = 1; result = resolvedResponse; RefUtils.computeRefFormat(ref); times = 1; incomingResponse.get$ref(); times = 1; responseProcessor.processResponse(incomingResponse); times = 1; responseProcessor.processResponse(resolvedResponse); times = 1; }}; new OperationProcessor(cache, openAPI).processOperation(operation); new FullVerifications() {{}}; assertEquals(operation.getResponses().get("200"), resolvedResponse); assertEquals(operation.getParameters(), outputParameterList); }
public void processOperation(Operation operation) { final List<Parameter> processedOperationParameters = parameterProcessor.processParameters(operation.getParameters()); if(processedOperationParameters != null) { operation.setParameters(processedOperationParameters); } final RequestBody requestBody = operation.getRequestBody(); if(requestBody != null) { requestBodyProcessor.processRequestBody(requestBody); } final Map<String, ApiResponse> responses = operation.getResponses(); if (responses != null) { for (String responseCode : responses.keySet()) { ApiResponse response = responses.get(responseCode); if(response != null) { if (response.get$ref() != null) { responseProcessor.processResponse(response); RefFormat refFormat = computeRefFormat(response.get$ref()); ApiResponse resolvedResponse = cache.loadRef(response.get$ref(), refFormat, ApiResponse.class); if (resolvedResponse != null) { response = resolvedResponse; responses.put(responseCode, resolvedResponse); } } responseProcessor.processResponse(response); } } } final Map<String, Callback> callbacks = operation.getCallbacks(); if (callbacks != null) { for (String name : callbacks.keySet()) { Callback callback = callbacks.get(name); if(callback != null) { if (callback.get$ref() != null){ String $ref = callback.get$ref(); RefFormat refFormat = computeRefFormat($ref); if (isAnExternalRefFormat(refFormat)){ final String newRef = externalRefProcessor.processRefToExternalCallback($ref, refFormat); if (newRef != null) { callback.set$ref(newRef); } } } for(String callbackName : callback.keySet()) { PathItem pathItem = callback.get(callbackName); final Map<PathItem.HttpMethod, Operation> operationMap = pathItem.readOperationsMap(); for (PathItem.HttpMethod httpMethod : operationMap.keySet()) { Operation op = operationMap.get(httpMethod); processOperation(op); } List<Parameter> parameters = pathItem.getParameters(); if (parameters != null) { for (Parameter parameter : parameters) { parameterProcessor.processParameter(parameter); } } } } } } }
OperationProcessor { public void processOperation(Operation operation) { final List<Parameter> processedOperationParameters = parameterProcessor.processParameters(operation.getParameters()); if(processedOperationParameters != null) { operation.setParameters(processedOperationParameters); } final RequestBody requestBody = operation.getRequestBody(); if(requestBody != null) { requestBodyProcessor.processRequestBody(requestBody); } final Map<String, ApiResponse> responses = operation.getResponses(); if (responses != null) { for (String responseCode : responses.keySet()) { ApiResponse response = responses.get(responseCode); if(response != null) { if (response.get$ref() != null) { responseProcessor.processResponse(response); RefFormat refFormat = computeRefFormat(response.get$ref()); ApiResponse resolvedResponse = cache.loadRef(response.get$ref(), refFormat, ApiResponse.class); if (resolvedResponse != null) { response = resolvedResponse; responses.put(responseCode, resolvedResponse); } } responseProcessor.processResponse(response); } } } final Map<String, Callback> callbacks = operation.getCallbacks(); if (callbacks != null) { for (String name : callbacks.keySet()) { Callback callback = callbacks.get(name); if(callback != null) { if (callback.get$ref() != null){ String $ref = callback.get$ref(); RefFormat refFormat = computeRefFormat($ref); if (isAnExternalRefFormat(refFormat)){ final String newRef = externalRefProcessor.processRefToExternalCallback($ref, refFormat); if (newRef != null) { callback.set$ref(newRef); } } } for(String callbackName : callback.keySet()) { PathItem pathItem = callback.get(callbackName); final Map<PathItem.HttpMethod, Operation> operationMap = pathItem.readOperationsMap(); for (PathItem.HttpMethod httpMethod : operationMap.keySet()) { Operation op = operationMap.get(httpMethod); processOperation(op); } List<Parameter> parameters = pathItem.getParameters(); if (parameters != null) { for (Parameter parameter : parameters) { parameterProcessor.processParameter(parameter); } } } } } } } }
OperationProcessor { public void processOperation(Operation operation) { final List<Parameter> processedOperationParameters = parameterProcessor.processParameters(operation.getParameters()); if(processedOperationParameters != null) { operation.setParameters(processedOperationParameters); } final RequestBody requestBody = operation.getRequestBody(); if(requestBody != null) { requestBodyProcessor.processRequestBody(requestBody); } final Map<String, ApiResponse> responses = operation.getResponses(); if (responses != null) { for (String responseCode : responses.keySet()) { ApiResponse response = responses.get(responseCode); if(response != null) { if (response.get$ref() != null) { responseProcessor.processResponse(response); RefFormat refFormat = computeRefFormat(response.get$ref()); ApiResponse resolvedResponse = cache.loadRef(response.get$ref(), refFormat, ApiResponse.class); if (resolvedResponse != null) { response = resolvedResponse; responses.put(responseCode, resolvedResponse); } } responseProcessor.processResponse(response); } } } final Map<String, Callback> callbacks = operation.getCallbacks(); if (callbacks != null) { for (String name : callbacks.keySet()) { Callback callback = callbacks.get(name); if(callback != null) { if (callback.get$ref() != null){ String $ref = callback.get$ref(); RefFormat refFormat = computeRefFormat($ref); if (isAnExternalRefFormat(refFormat)){ final String newRef = externalRefProcessor.processRefToExternalCallback($ref, refFormat); if (newRef != null) { callback.set$ref(newRef); } } } for(String callbackName : callback.keySet()) { PathItem pathItem = callback.get(callbackName); final Map<PathItem.HttpMethod, Operation> operationMap = pathItem.readOperationsMap(); for (PathItem.HttpMethod httpMethod : operationMap.keySet()) { Operation op = operationMap.get(httpMethod); processOperation(op); } List<Parameter> parameters = pathItem.getParameters(); if (parameters != null) { for (Parameter parameter : parameters) { parameterProcessor.processParameter(parameter); } } } } } } } OperationProcessor(ResolverCache cache, OpenAPI openAPI); }
OperationProcessor { public void processOperation(Operation operation) { final List<Parameter> processedOperationParameters = parameterProcessor.processParameters(operation.getParameters()); if(processedOperationParameters != null) { operation.setParameters(processedOperationParameters); } final RequestBody requestBody = operation.getRequestBody(); if(requestBody != null) { requestBodyProcessor.processRequestBody(requestBody); } final Map<String, ApiResponse> responses = operation.getResponses(); if (responses != null) { for (String responseCode : responses.keySet()) { ApiResponse response = responses.get(responseCode); if(response != null) { if (response.get$ref() != null) { responseProcessor.processResponse(response); RefFormat refFormat = computeRefFormat(response.get$ref()); ApiResponse resolvedResponse = cache.loadRef(response.get$ref(), refFormat, ApiResponse.class); if (resolvedResponse != null) { response = resolvedResponse; responses.put(responseCode, resolvedResponse); } } responseProcessor.processResponse(response); } } } final Map<String, Callback> callbacks = operation.getCallbacks(); if (callbacks != null) { for (String name : callbacks.keySet()) { Callback callback = callbacks.get(name); if(callback != null) { if (callback.get$ref() != null){ String $ref = callback.get$ref(); RefFormat refFormat = computeRefFormat($ref); if (isAnExternalRefFormat(refFormat)){ final String newRef = externalRefProcessor.processRefToExternalCallback($ref, refFormat); if (newRef != null) { callback.set$ref(newRef); } } } for(String callbackName : callback.keySet()) { PathItem pathItem = callback.get(callbackName); final Map<PathItem.HttpMethod, Operation> operationMap = pathItem.readOperationsMap(); for (PathItem.HttpMethod httpMethod : operationMap.keySet()) { Operation op = operationMap.get(httpMethod); processOperation(op); } List<Parameter> parameters = pathItem.getParameters(); if (parameters != null) { for (Parameter parameter : parameters) { parameterProcessor.processParameter(parameter); } } } } } } } OperationProcessor(ResolverCache cache, OpenAPI openAPI); void processOperation(Operation operation); }
OperationProcessor { public void processOperation(Operation operation) { final List<Parameter> processedOperationParameters = parameterProcessor.processParameters(operation.getParameters()); if(processedOperationParameters != null) { operation.setParameters(processedOperationParameters); } final RequestBody requestBody = operation.getRequestBody(); if(requestBody != null) { requestBodyProcessor.processRequestBody(requestBody); } final Map<String, ApiResponse> responses = operation.getResponses(); if (responses != null) { for (String responseCode : responses.keySet()) { ApiResponse response = responses.get(responseCode); if(response != null) { if (response.get$ref() != null) { responseProcessor.processResponse(response); RefFormat refFormat = computeRefFormat(response.get$ref()); ApiResponse resolvedResponse = cache.loadRef(response.get$ref(), refFormat, ApiResponse.class); if (resolvedResponse != null) { response = resolvedResponse; responses.put(responseCode, resolvedResponse); } } responseProcessor.processResponse(response); } } } final Map<String, Callback> callbacks = operation.getCallbacks(); if (callbacks != null) { for (String name : callbacks.keySet()) { Callback callback = callbacks.get(name); if(callback != null) { if (callback.get$ref() != null){ String $ref = callback.get$ref(); RefFormat refFormat = computeRefFormat($ref); if (isAnExternalRefFormat(refFormat)){ final String newRef = externalRefProcessor.processRefToExternalCallback($ref, refFormat); if (newRef != null) { callback.set$ref(newRef); } } } for(String callbackName : callback.keySet()) { PathItem pathItem = callback.get(callbackName); final Map<PathItem.HttpMethod, Operation> operationMap = pathItem.readOperationsMap(); for (PathItem.HttpMethod httpMethod : operationMap.keySet()) { Operation op = operationMap.get(httpMethod); processOperation(op); } List<Parameter> parameters = pathItem.getParameters(); if (parameters != null) { for (Parameter parameter : parameters) { parameterProcessor.processParameter(parameter); } } } } } } } OperationProcessor(ResolverCache cache, OpenAPI openAPI); void processOperation(Operation operation);  }