Search in sources :

Example 61 with Response

use of io.swagger.models.Response in project incubator-servicecomb-java-chassis by apache.

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 62 with Response

use of io.swagger.models.Response in project incubator-servicecomb-java-chassis by apache.

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)

Example 63 with Response

use of io.swagger.models.Response in project incubator-servicecomb-java-chassis by apache.

the class TestApiResponse method checkResponseDesc.

private void checkResponseDesc(SwaggerGenerator generator) {
    Swagger swagger = generator.getSwagger();
    Path path = swagger.getPaths().get("/testMulti");
    Operation operation = path.getOperations().get(0);
    Response response1 = operation.getResponses().get("200");
    Response response2 = operation.getResponses().get("301");
    Assert.assertEquals("msg1", response1.getDescription());
    Assert.assertEquals("msg2", response2.getDescription());
}
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 64 with Response

use of io.swagger.models.Response in project incubator-servicecomb-java-chassis by apache.

the class TestApiResponse method checkApiResponseHeader.

private void checkApiResponseHeader(SwaggerGenerator generator) {
    Swagger swagger = generator.getSwagger();
    Path path = swagger.getPaths().get("/testApiResponseHeader");
    Operation operation = path.getOperations().get(0);
    Assert.assertEquals("testApiResponseHeader", operation.getOperationId());
    Response response = operation.getResponses().get("200");
    Property property = response.getHeaders().get("k1");
    Assert.assertEquals(Integer.class, ConverterMgr.findJavaType(generator, property).getRawClass());
    property = response.getHeaders().get("k2");
    Assert.assertEquals(String.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)

Example 65 with Response

use of io.swagger.models.Response in project incubator-servicecomb-java-chassis by apache.

the class TestSwaggerUtils method correctResponsesOperationDefaultTo200.

@Test
public void correctResponsesOperationDefaultTo200() {
    Response response = new Response();
    Operation operation = new Operation();
    operation.addResponse("default", response);
    SwaggerUtils.correctResponses(operation);
    Assert.assertSame(response, operation.getResponses().get("200"));
}
Also used : Response(io.swagger.models.Response) Operation(io.swagger.models.Operation) Test(org.junit.Test)

Aggregations

Response (io.swagger.models.Response)93 Operation (io.swagger.models.Operation)51 Property (io.swagger.models.properties.Property)30 Path (io.swagger.models.Path)29 Swagger (io.swagger.models.Swagger)29 ApiResponse (io.swagger.annotations.ApiResponse)24 Test (org.testng.annotations.Test)23 RefProperty (io.swagger.models.properties.RefProperty)21 ArrayProperty (io.swagger.models.properties.ArrayProperty)20 Test (org.junit.Test)17 MapProperty (io.swagger.models.properties.MapProperty)14 Parameter (io.swagger.models.parameters.Parameter)13 Model (io.swagger.models.Model)12 BodyParameter (io.swagger.models.parameters.BodyParameter)12 StringProperty (io.swagger.models.properties.StringProperty)12 HashMap (java.util.HashMap)12 RefModel (io.swagger.models.RefModel)10 PathParameter (io.swagger.models.parameters.PathParameter)10 IntegerProperty (io.swagger.models.properties.IntegerProperty)10 QueryParameter (io.swagger.models.parameters.QueryParameter)9