Search in sources :

Example 31 with Response

use of io.swagger.models.Response in project java-chassis by ServiceComb.

the class TestApiResponse method checkMulti.

public void checkMulti(SwaggerGenerator generator) {
    Swagger swagger = generator.getSwagger();
    Path path = swagger.getPaths().get("/testMulti");
    Operation operation = path.getOperations().get(0);
    Assert.assertEquals("testMulti", operation.getOperationId());
    Response response = operation.getResponses().get("200");
    Assert.assertEquals(Integer.class, ConverterMgr.findJavaType(generator, response.getSchema()).getRawClass());
    response = operation.getResponses().get("301");
    Assert.assertEquals(String.class, ConverterMgr.findJavaType(generator, response.getSchema()).getRawClass());
}
Also used : Path(io.swagger.models.Path) Response(io.swagger.models.Response) ApiResponse(io.swagger.annotations.ApiResponse) Swagger(io.swagger.models.Swagger) Operation(io.swagger.models.Operation)

Example 32 with Response

use of io.swagger.models.Response in project java-chassis by ServiceComb.

the class TestApiResponse method checkResponseHeader.

private void checkResponseHeader(SwaggerGenerator generator) {
    Swagger swagger = generator.getSwagger();
    Path path = swagger.getPaths().get("/testResponseHeader");
    Operation operation = path.getOperations().get(0);
    Assert.assertEquals("testResponseHeader", operation.getOperationId());
    Response response = operation.getResponses().get("200");
    Property property = response.getHeaders().get("k1");
    Assert.assertEquals(Integer.class, ConverterMgr.findJavaType(generator, property).getRawClass());
}
Also used : Path(io.swagger.models.Path) Response(io.swagger.models.Response) ApiResponse(io.swagger.annotations.ApiResponse) Swagger(io.swagger.models.Swagger) Operation(io.swagger.models.Operation) Property(io.swagger.models.properties.Property)

Aggregations

Response (io.swagger.models.Response)32 Operation (io.swagger.models.Operation)23 Test (org.testng.annotations.Test)17 Property (io.swagger.models.properties.Property)16 Swagger (io.swagger.models.Swagger)14 Path (io.swagger.models.Path)12 ArrayProperty (io.swagger.models.properties.ArrayProperty)10 MapProperty (io.swagger.models.properties.MapProperty)10 RefProperty (io.swagger.models.properties.RefProperty)10 ApiResponse (io.swagger.annotations.ApiResponse)8 IntegerProperty (io.swagger.models.properties.IntegerProperty)8 StringProperty (io.swagger.models.properties.StringProperty)7 ResourceWithResponse (io.swagger.resources.ResourceWithResponse)6 BodyParameter (io.swagger.models.parameters.BodyParameter)5 JavaType (com.fasterxml.jackson.databind.JavaType)4 Parameter (io.swagger.models.parameters.Parameter)4 PathParameter (io.swagger.models.parameters.PathParameter)4 QueryParameter (io.swagger.models.parameters.QueryParameter)4 LongProperty (io.swagger.models.properties.LongProperty)4 Type (java.lang.reflect.Type)4