use of org.apache.servicecomb.swagger.generator.pojo.PojoSwaggerGeneratorContext in project incubator-servicecomb-java-chassis by apache.
the class TestOperationGenerator method testConvertTagsOnMethodWithNoTag.
@Test
public void testConvertTagsOnMethodWithNoTag() throws NoSuchMethodException {
Method function = TestClass.class.getMethod("functionWithNoTag");
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 testConvertTags.
@Test
public void testConvertTags() throws NoSuchMethodException {
Method function = TestClass.class.getMethod("function");
SwaggerGenerator swaggerGenerator = new SwaggerGenerator(new PojoSwaggerGeneratorContext(), TestClass.class);
OperationGenerator operationGenerator = new OperationGenerator(swaggerGenerator, function);
operationGenerator.generate();
List<String> tagList = operationGenerator.getOperation().getTags();
assertThat(tagList, contains("tag1", "tag2"));
}
use of org.apache.servicecomb.swagger.generator.pojo.PojoSwaggerGeneratorContext in project incubator-servicecomb-java-chassis by apache.
the class TestSwaggerGenerator method testBasePathPlaceHolder.
@Test
public void testBasePathPlaceHolder() {
StringValueResolver stringValueResolver = SpringUtils.createStringValueResolver(Collections.singletonMap("var", "varValue"));
PojoSwaggerGeneratorContext context = new PojoSwaggerGeneratorContext();
context.setEmbeddedValueResolver(stringValueResolver);
SwaggerGenerator swaggerGenerator = new SwaggerGenerator(context, null);
swaggerGenerator.setBasePath("/a/${var}/b");
Assert.assertEquals("/a/varValue/b", swaggerGenerator.getSwagger().getBasePath());
}
use of org.apache.servicecomb.swagger.generator.pojo.PojoSwaggerGeneratorContext in project incubator-servicecomb-java-chassis by apache.
the class ApiOperationProcessorTest method testConvertTags.
@Test
public void testConvertTags() throws NoSuchMethodException {
ApiOperationProcessor apiOperationProcessor = new ApiOperationProcessor();
Method function = TestClass.class.getMethod("function");
SwaggerGenerator swaggerGenerator = new SwaggerGenerator(new PojoSwaggerGeneratorContext(), TestClass.class);
OperationGenerator operationGenerator = new OperationGenerator(swaggerGenerator, function);
apiOperationProcessor.process(function.getAnnotation(ApiOperation.class), operationGenerator);
assertThat(operationGenerator.getOperation().getTags(), containsInAnyOrder("tag1", "tag2"));
}
use of org.apache.servicecomb.swagger.generator.pojo.PojoSwaggerGeneratorContext in project incubator-servicecomb-java-chassis by apache.
the class ApiOperationProcessorTest method testConvertTagsOnMethodWithNoTag.
@Test
public void testConvertTagsOnMethodWithNoTag() throws NoSuchMethodException {
ApiOperationProcessor apiOperationProcessor = new ApiOperationProcessor();
Method function = TestClass.class.getMethod("functionWithNoTag");
SwaggerGenerator swaggerGenerator = new SwaggerGenerator(new PojoSwaggerGeneratorContext(), TestClass.class);
OperationGenerator operationGenerator = new OperationGenerator(swaggerGenerator, function);
apiOperationProcessor.process(function.getAnnotation(ApiOperation.class), operationGenerator);
List<String> tagList = operationGenerator.getOperation().getTags();
assertNull(tagList);
}
Aggregations