use of org.apache.servicecomb.swagger.generator.pojo.PojoSwaggerGeneratorContext in project incubator-servicecomb-java-chassis by apache.
the class TestOperationGenerator method testConvertTagsOnMethodWithNoAnnotation.
@Test
public void testConvertTagsOnMethodWithNoAnnotation() throws NoSuchMethodException {
Method function = TestClass.class.getMethod("functionWithNoAnnotation");
SwaggerGenerator swaggerGenerator = new SwaggerGenerator(new PojoSwaggerGeneratorContext(), TestClass.class);
OperationGenerator operationGenerator = new OperationGenerator(swaggerGenerator, function);
swaggerGenerator.addDefaultTag("default0");
swaggerGenerator.addDefaultTag("default1");
operationGenerator.generate();
List<String> tagList = operationGenerator.getOperation().getTags();
assertThat(tagList, contains("default0", "default1"));
}
use of org.apache.servicecomb.swagger.generator.pojo.PojoSwaggerGeneratorContext in project incubator-servicecomb-java-chassis by apache.
the class TestOperationGenerator method testPathPlaceHolder.
@Test
public void testPathPlaceHolder() {
StringValueResolver stringValueResolver = SpringUtils.createStringValueResolver(Collections.singletonMap("var", "varValue"));
PojoSwaggerGeneratorContext context = new PojoSwaggerGeneratorContext();
context.setEmbeddedValueResolver(stringValueResolver);
SwaggerGenerator swaggerGenerator = new SwaggerGenerator(context, null);
OperationGenerator operationGenerator = new OperationGenerator(swaggerGenerator, null);
operationGenerator.setPath("/a/${var}/b");
assertEquals("/a/varValue/b", operationGenerator.getPath());
}
use of org.apache.servicecomb.swagger.generator.pojo.PojoSwaggerGeneratorContext in project incubator-servicecomb-java-chassis by apache.
the class TestSwaggerGenerator method testAddDefaultTag.
@Test
public void testAddDefaultTag() {
SwaggerGenerator swaggerGenerator = new SwaggerGenerator(new PojoSwaggerGeneratorContext(), null);
swaggerGenerator.addDefaultTag("test1");
swaggerGenerator.addDefaultTag("");
swaggerGenerator.addDefaultTag(null);
swaggerGenerator.addDefaultTag("test2");
assertThat(swaggerGenerator.getDefaultTags(), contains("test1", "test2"));
}
Aggregations