use of io.swagger.models.RefResponse in project swagger-parser by swagger-api.
the class OperationProcessor method processOperation.
public void processOperation(Operation operation) {
final List<Parameter> processedOperationParameters = parameterProcessor.processParameters(operation.getParameters());
operation.setParameters(processedOperationParameters);
final Map<String, Response> responses = operation.getResponses();
if (responses != null) {
for (String responseCode : responses.keySet()) {
Response response = responses.get(responseCode);
if (response != null) {
if (response instanceof RefResponse) {
RefResponse refResponse = (RefResponse) response;
Response resolvedResponse = cache.loadRef(refResponse.get$ref(), refResponse.getRefFormat(), Response.class);
if (resolvedResponse != null) {
response = resolvedResponse;
responses.put(responseCode, resolvedResponse);
}
}
responseProcessor.processResponse(response);
}
}
}
}
use of io.swagger.models.RefResponse in project swagger-parser by swagger-api.
the class OperationProcessorTest method testProcessOperation.
@Test
public void testProcessOperation(@Injectable final List<Parameter> inputParameterList, @Injectable final List<Parameter> outputParameterList, @Injectable final Response incomingResponse, @Injectable final Response resolvedResponse) throws Exception {
Operation operation = new Operation();
operation.setParameters(inputParameterList);
final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
RefResponse refResponse = new RefResponse(ref);
operation.response(200, refResponse);
operation.response(400, incomingResponse);
new Expectations() {
{
new ParameterProcessor(cache, swagger);
times = 1;
result = parameterProcessor;
new ResponseProcessor(cache, swagger);
times = 1;
result = responseProcessor;
parameterProcessor.processParameters(inputParameterList);
times = 1;
result = outputParameterList;
cache.loadRef(ref, RefFormat.URL, Response.class);
times = 1;
result = resolvedResponse;
responseProcessor.processResponse(incomingResponse);
times = 1;
responseProcessor.processResponse(resolvedResponse);
times = 1;
}
};
new OperationProcessor(cache, swagger).processOperation(operation);
new FullVerifications() {
{
}
};
assertEquals(operation.getResponses().get("200"), resolvedResponse);
assertEquals(operation.getParameters(), outputParameterList);
}
Aggregations