use of io.swagger.models.Response in project syndesis by syndesisio.
the class UnifiedXmlDataShapeGenerator method createResponseBodySchema.
private static Element createResponseBodySchema(final Swagger swagger, final Operation operation, final Map<String, SchemaPrefixAndElement> moreSchemas) {
final Optional<Response> maybeResponse = findResponse(operation);
if (!maybeResponse.isPresent()) {
return null;
}
final Response body = maybeResponse.get();
final Property bodySchema = body.getSchema();
if (bodySchema instanceof RefProperty) {
return defineComplexElement((RefProperty) bodySchema, null, swagger, moreSchemas);
} else if (bodySchema instanceof ArrayProperty) {
final ArrayProperty array = (ArrayProperty) bodySchema;
final String targetNamespace = xmlTargetNamespaceOrNull(array);
final Element schema = newXmlSchema(targetNamespace);
defineElementProperty(ofNullable(array.getName()).orElse("array"), array, schema, swagger, moreSchemas);
return schema;
} else {
throw new IllegalArgumentException("Unsupported response schema type: " + bodySchema);
}
}
use of io.swagger.models.Response in project java-chassis by ServiceComb.
the class TestApiResponse method checkSingle.
@Test
public void checkSingle() {
SwaggerOperation swaggerOperation = swaggerOperations.findOperation("testSingle");
Assert.assertEquals("/testSingle", swaggerOperation.getPath());
Response response = swaggerOperation.getOperation().getResponses().get("200");
Assert.assertEquals("integer", ((ModelImpl) response.getResponseSchema()).getType());
Assert.assertEquals("int32", ((ModelImpl) response.getResponseSchema()).getFormat());
}
use of io.swagger.models.Response in project java-chassis by ServiceComb.
the class TestApiResponse method checkMulti.
@Test
public void checkMulti() {
SwaggerOperation swaggerOperation = swaggerOperations.findOperation("testMulti");
Assert.assertEquals("/testMulti", swaggerOperation.getPath());
Response response = swaggerOperation.getOperation().getResponses().get("200");
Assert.assertEquals("integer", ((ModelImpl) response.getResponseSchema()).getType());
Assert.assertEquals("int32", ((ModelImpl) response.getResponseSchema()).getFormat());
response = swaggerOperation.getOperation().getResponses().get("301");
Assert.assertEquals("string", ((ModelImpl) response.getResponseSchema()).getType());
Assert.assertNull(((ModelImpl) response.getResponseSchema()).getFormat());
}
use of io.swagger.models.Response in project java-chassis by ServiceComb.
the class TestApiResponse method checkApiResponseHeader.
@Test
public void checkApiResponseHeader() {
SwaggerOperation swaggerOperation = swaggerOperations.findOperation("testApiResponseHeader");
Assert.assertEquals("/testApiResponseHeader", swaggerOperation.getPath());
Response response = swaggerOperation.getOperation().getResponses().get("200");
Property property = response.getHeaders().get("k1");
Assert.assertEquals("integer", property.getType());
Assert.assertEquals("int32", property.getFormat());
property = response.getHeaders().get("k2");
Assert.assertEquals("string", property.getType());
Assert.assertNull(property.getFormat());
}
use of io.swagger.models.Response in project java-chassis by ServiceComb.
the class TestOperationGenerator method responseThenApiOperation.
@Test
public void responseThenApiOperation() {
SwaggerOperation swaggerOperation = swaggerOperations.findOperation("responseThenApiOperation");
List<String> tags = swaggerOperation.getOperation().getTags();
assertThat(tags, contains("tag1", "tag2"));
Response response = swaggerOperation.getOperation().getResponses().get("200");
assertEquals("200 is ok............", response.getDescription());
Assert.assertNotNull(response.getHeaders().get("x-user-domain"));
Assert.assertNull(response.getHeaders().get("x-user-name"));
Assert.assertNotNull(swaggerOperation.getOperation().getVendorExtensions().get("x-class-name"));
}
Aggregations