use of org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation in project java-chassis by ServiceComb.
the class ApiProcessorTest method process.
@Test
public void process() {
SwaggerOperations swaggerOperations = SwaggerOperations.generate(SwaggerTestTarget.class);
SwaggerOperation swaggerOperation = swaggerOperations.findOperation("op");
assertThat(swaggerOperation.getOperation().getTags(), contains("tag1", "tag2"));
assertThat(swaggerOperation.getSwagger().getConsumes(), Matchers.contains(MediaType.APPLICATION_JSON));
assertThat(swaggerOperation.getSwagger().getProduces(), Matchers.contains(MediaType.APPLICATION_JSON));
}
use of org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation in project incubator-servicecomb-java-chassis by apache.
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 incubator-servicecomb-java-chassis by apache.
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 incubator-servicecomb-java-chassis by apache.
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());
}
use of org.apache.servicecomb.swagger.generator.core.model.SwaggerOperation in project incubator-servicecomb-java-chassis by apache.
the class ApiProcessorTest method processOnNoTag.
@Test
public void processOnNoTag() {
SwaggerOperations swaggerOperations = SwaggerOperations.generate(SwaggerTestTargetWithNoTag.class);
SwaggerOperation swaggerOperation = swaggerOperations.findOperation("op");
assertNull(swaggerOperation.getOperation().getTags());
assertThat(swaggerOperation.getSwagger().getConsumes(), Matchers.contains(MediaType.APPLICATION_JSON));
assertThat(swaggerOperation.getSwagger().getProduces(), Matchers.contains(MediaType.APPLICATION_JSON));
}
Aggregations