Search in sources :

Example 1 with SwaggerGeneratorContext

use of org.apache.servicecomb.swagger.generator.core.SwaggerGeneratorContext in project incubator-servicecomb-java-chassis by apache.

the class UnitTestSwaggerUtils method generateSwagger.

public static SwaggerGenerator generateSwagger(Class<?> cls) {
    SwaggerGeneratorContext context = compositeContext.selectContext(cls);
    SwaggerGenerator generator = new SwaggerGenerator(context, cls);
    generator.generate();
    return generator;
}
Also used : SwaggerGenerator(org.apache.servicecomb.swagger.generator.core.SwaggerGenerator) SwaggerGeneratorContext(org.apache.servicecomb.swagger.generator.core.SwaggerGeneratorContext) CompositeSwaggerGeneratorContext(org.apache.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext)

Example 2 with SwaggerGeneratorContext

use of org.apache.servicecomb.swagger.generator.core.SwaggerGeneratorContext in project incubator-servicecomb-java-chassis by apache.

the class AbstractSchemaFactory method generateSwagger.

protected SwaggerGenerator generateSwagger(CONTEXT context) {
    SwaggerGeneratorContext generatorContext = compositeSwaggerGeneratorContext.selectContext(context.getProviderClass());
    SwaggerGenerator generator = new SwaggerGenerator(generatorContext, context.getProviderClass());
    generator.setClassLoader(context.getMicroserviceMeta().getClassLoader());
    generator.setPackageName(SchemaUtils.generatePackageName(context.getMicroserviceMeta(), context.getSchemaId()));
    generator.generate();
    // 确保接口是存在的
    ClassUtils.getOrCreateInterface(generator);
    return generator;
}
Also used : SwaggerGenerator(org.apache.servicecomb.swagger.generator.core.SwaggerGenerator) CompositeSwaggerGeneratorContext(org.apache.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext) SwaggerGeneratorContext(org.apache.servicecomb.swagger.generator.core.SwaggerGeneratorContext)

Example 3 with SwaggerGeneratorContext

use of org.apache.servicecomb.swagger.generator.core.SwaggerGeneratorContext in project incubator-servicecomb-java-chassis by apache.

the class TestSpringmvc method testComposite.

@Test
public void testComposite() {
    CompositeSwaggerGeneratorContext composite = new CompositeSwaggerGeneratorContext();
    SwaggerGeneratorContext context = composite.selectContext(Echo.class);
    Assert.assertEquals(SpringmvcSwaggerGeneratorContext.class, context.getClass());
}
Also used : CompositeSwaggerGeneratorContext(org.apache.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext) SwaggerGeneratorContext(org.apache.servicecomb.swagger.generator.core.SwaggerGeneratorContext) CompositeSwaggerGeneratorContext(org.apache.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext) Test(org.junit.Test)

Example 4 with SwaggerGeneratorContext

use of org.apache.servicecomb.swagger.generator.core.SwaggerGeneratorContext in project incubator-servicecomb-java-chassis by apache.

the class TestJaxrs method testComposite.

@Test
public void testComposite() {
    CompositeSwaggerGeneratorContext composite = new CompositeSwaggerGeneratorContext();
    SwaggerGeneratorContext context = composite.selectContext(Echo.class);
    Assert.assertEquals(JaxrsSwaggerGeneratorContext.class, context.getClass());
}
Also used : CompositeSwaggerGeneratorContext(org.apache.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext) SwaggerGeneratorContext(org.apache.servicecomb.swagger.generator.core.SwaggerGeneratorContext) CompositeSwaggerGeneratorContext(org.apache.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext) Test(org.junit.Test)

Aggregations

CompositeSwaggerGeneratorContext (org.apache.servicecomb.swagger.generator.core.CompositeSwaggerGeneratorContext)4 SwaggerGeneratorContext (org.apache.servicecomb.swagger.generator.core.SwaggerGeneratorContext)4 SwaggerGenerator (org.apache.servicecomb.swagger.generator.core.SwaggerGenerator)2 Test (org.junit.Test)2