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());
}
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"));
}
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());
}
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());
}
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());
}
Aggregations