Search in sources :

Example 6 with SwaggerOperation

use of org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation in project java-chassis by ServiceComb.

the class TestApiResponse method checkResponseDesc.

@Test
public void checkResponseDesc() {
    SwaggerOperation swaggerOperation = swaggerOperations.findOperation("testMulti");
    Assert.assertEquals("/testMulti", swaggerOperation.getPath());
    Response response1 = swaggerOperation.getOperation().getResponses().get("200");
    Response response2 = swaggerOperation.getOperation().getResponses().get("301");
    Assert.assertEquals("msg1", response1.getDescription());
    Assert.assertEquals("msg2", response2.getDescription());
}
Also used : Response(io.swagger.models.Response) ApiResponse(io.swagger.annotations.ApiResponse) SwaggerOperation(org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation) Test(org.junit.Test)

Example 7 with SwaggerOperation

use of org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation in project java-chassis by ServiceComb.

the class TestOperationGenerator method apiOperationThenResponse.

@Test
public void apiOperationThenResponse() throws NoSuchMethodException {
    SwaggerOperation swaggerOperation = swaggerOperations.findOperation("apiOperationThenResponse");
    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.assertNull(response.getHeaders().get("x-user-domain"));
    Assert.assertNotNull(response.getHeaders().get("x-user-name"));
    Assert.assertNotNull(swaggerOperation.getOperation().getVendorExtensions().get("x-class-name"));
}
Also used : Response(io.swagger.models.Response) ApiResponse(io.swagger.annotations.ApiResponse) SwaggerOperation(org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation) Test(org.junit.Test)

Example 8 with SwaggerOperation

use of org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation in project java-chassis by ServiceComb.

the class TestOperationGenerator method apiOperationNoTag.

@Test
public void apiOperationNoTag() {
    SwaggerOperation operation = swaggerOperations.findOperation("apiOperationNoTag");
    List<String> tags = operation.getOperation().getTags();
    assertThat(tags, contains("default0", "default1"));
    assertEquals("value2", operation.getOperation().getSummary());
}
Also used : SwaggerOperation(org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation) Test(org.junit.Test)

Example 9 with SwaggerOperation

use of org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation in project java-chassis by ServiceComb.

the class TestOperationGenerator method noApiOperation.

@Test
public void noApiOperation() {
    SwaggerOperation operation = swaggerOperations.findOperation("noApiOperation");
    List<String> tags = operation.getOperation().getTags();
    assertThat(tags, contains("default0", "default1"));
    assertNull(operation.getOperation().getSummary());
}
Also used : SwaggerOperation(org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation) Test(org.junit.Test)

Example 10 with SwaggerOperation

use of org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation in project java-chassis by ServiceComb.

the class TestArrayType method test.

@Test
public void test() {
    SwaggerOperations swaggerOperations = SwaggerOperations.generate(ArrayType.class);
    SwaggerOperation swaggerOperation = swaggerOperations.findOperation("testBytes");
    BodyParameter bodyParameter = (BodyParameter) swaggerOperation.getOperation().getParameters().get(0);
    ModelImpl model = SwaggerUtils.getModelImpl(swaggerOperations.getSwagger(), bodyParameter);
    Assert.assertEquals(ModelImpl.OBJECT, model.getType());
    Assert.assertEquals(1, model.getProperties().size());
    ByteArrayProperty byteArrayProperty = (ByteArrayProperty) model.getProperties().get("value");
    Assert.assertEquals("string", byteArrayProperty.getType());
    Assert.assertEquals("byte", byteArrayProperty.getFormat());
}
Also used : ByteArrayProperty(io.swagger.models.properties.ByteArrayProperty) SwaggerOperations(org.apache.servicecomb.swagger.generator.core.model.SwaggerOperations) SwaggerOperation(org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation) BodyParameter(io.swagger.models.parameters.BodyParameter) ModelImpl(io.swagger.models.ModelImpl) Test(org.junit.Test)

Aggregations

SwaggerOperation (org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation)36 Test (org.junit.Test)32 ApiResponse (io.swagger.annotations.ApiResponse)14 Response (io.swagger.models.Response)14 SwaggerOperations (org.apache.servicecomb.swagger.generator.core.model.SwaggerOperations)10 Property (io.swagger.models.properties.Property)6 Method (java.lang.reflect.Method)4 ContextArgumentMapperFactory (org.apache.servicecomb.swagger.invocation.arguments.ContextArgumentMapperFactory)4 ConsumerContextArgumentMapperFactory (org.apache.servicecomb.swagger.invocation.arguments.consumer.ConsumerContextArgumentMapperFactory)4 ProducerArgumentsMapper (org.apache.servicecomb.swagger.invocation.arguments.producer.ProducerArgumentsMapper)4 ProducerContextArgumentMapperFactory (org.apache.servicecomb.swagger.invocation.arguments.producer.ProducerContextArgumentMapperFactory)4 ResponseMapperFactorys (org.apache.servicecomb.swagger.invocation.response.ResponseMapperFactorys)4 ModelImpl (io.swagger.models.ModelImpl)2 BodyParameter (io.swagger.models.parameters.BodyParameter)2 ByteArrayProperty (io.swagger.models.properties.ByteArrayProperty)2 ArgumentsMapper (org.apache.servicecomb.swagger.invocation.arguments.ArgumentsMapper)2 ConsumerArgumentsMapperCreator (org.apache.servicecomb.swagger.invocation.arguments.consumer.ConsumerArgumentsMapperCreator)2 ProducerArgumentsMapperCreator (org.apache.servicecomb.swagger.invocation.arguments.producer.ProducerArgumentsMapperCreator)2 ConsumerResponseMapper (org.apache.servicecomb.swagger.invocation.response.consumer.ConsumerResponseMapper)2 ProducerResponseMapper (org.apache.servicecomb.swagger.invocation.response.producer.ProducerResponseMapper)2