Search in sources :

Example 1 with SpringmvcSwaggerGenerator

use of org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator in project java-chassis by ServiceComb.

the class TestSchemaMetaCodec method testProtoSchemaOperationBaseSpringMVC.

@Test
public void testProtoSchemaOperationBaseSpringMVC() throws Exception {
    mockSchemaMeta("ProtoSchema", new SpringmvcSwaggerGenerator(ProtoSchema.class), new ProtoSchema());
    testProtoSchemaOperationBaseImpl(false);
}
Also used : ProtoSchema(org.apache.servicecomb.codec.protobuf.internal.converter.model.ProtoSchema) SpringmvcSwaggerGenerator(org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator) Test(org.junit.Test)

Example 2 with SpringmvcSwaggerGenerator

use of org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator in project incubator-servicecomb-java-chassis by apache.

the class TestSchemaMetaCodecRestTemplate method setUp.

@Before
public void setUp() {
    ProtobufManager.clear();
    new Expectations() {

        {
            providerMicroserviceMeta.getMicroserviceName();
            result = "test";
            providerMicroserviceMeta.getExtData(ProtobufManager.EXT_ID);
            result = null;
            consumerMicroserviceMeta.getMicroserviceName();
            result = "test";
            consumerMicroserviceMeta.getExtData(ProtobufManager.EXT_ID);
            result = null;
        }
    };
    SpringmvcSwaggerGenerator swaggerGenerator = new SpringmvcSwaggerGenerator(ProtoSchema.class);
    Swagger swagger = swaggerGenerator.generate();
    SwaggerEnvironment swaggerEnvironment = new SwaggerEnvironment();
    providerSchemaMeta = new SchemaMeta(providerMicroserviceMeta, "ProtoSchema", swagger);
    SwaggerProducer swaggerProducer = swaggerEnvironment.createProducer(new ProtoSchema(), swagger);
    for (SwaggerProducerOperation producerOperation : swaggerProducer.getAllOperations()) {
        OperationMeta operationMeta = providerSchemaMeta.ensureFindOperation(producerOperation.getOperationId());
        operationMeta.setSwaggerProducerOperation(producerOperation);
    }
    consumerSchemaMeta = new SchemaMeta(consumerMicroserviceMeta, "ProtoSchema", swagger);
}
Also used : Expectations(mockit.Expectations) ProtoSchema(org.apache.servicecomb.codec.protobuf.internal.converter.model.ProtoSchema) SwaggerProducer(org.apache.servicecomb.swagger.engine.SwaggerProducer) Swagger(io.swagger.models.Swagger) SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) SwaggerProducerOperation(org.apache.servicecomb.swagger.engine.SwaggerProducerOperation) SwaggerEnvironment(org.apache.servicecomb.swagger.engine.SwaggerEnvironment) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta) SpringmvcSwaggerGenerator(org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator) Before(org.junit.Before)

Example 3 with SpringmvcSwaggerGenerator

use of org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator in project incubator-servicecomb-java-chassis by apache.

the class TestSwaggerToProtoGenerator method convert.

@Test
public void convert() throws IOException {
    URL url = TestSwaggerToProtoGenerator.class.getClassLoader().getResource("ProtoSchema.proto");
    String protoContent = IOUtils.toString(url, "UTF-8");
    int idx = protoContent.indexOf("syntax = ");
    protoContent = protoContent.substring(idx);
    SpringmvcSwaggerGenerator swaggerGenerator = new SpringmvcSwaggerGenerator(ProtoSchema.class);
    Swagger swagger = swaggerGenerator.generate();
    SwaggerToProtoGenerator generator = new SwaggerToProtoGenerator("a.b", swagger);
    Proto proto = generator.convert();
    Assert.assertEquals(protoContent.replaceAll("\r\n", "\n"), new ProtoToStringGenerator(proto).protoToString().replaceAll("\r\n", "\n"));
}
Also used : Proto(io.protostuff.compiler.model.Proto) Swagger(io.swagger.models.Swagger) URL(java.net.URL) SpringmvcSwaggerGenerator(org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator) Test(org.junit.Test)

Example 4 with SpringmvcSwaggerGenerator

use of org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator in project incubator-servicecomb-java-chassis by apache.

the class TestSchemaMetaCodec method testProtoSchemaOperationBaseSpringMVC.

@Test
public void testProtoSchemaOperationBaseSpringMVC() throws Exception {
    mockSchemaMeta("ProtoSchema", new SpringmvcSwaggerGenerator(ProtoSchema.class), new ProtoSchema());
    testProtoSchemaOperationBaseImpl(false);
}
Also used : ProtoSchema(org.apache.servicecomb.codec.protobuf.internal.converter.model.ProtoSchema) SpringmvcSwaggerGenerator(org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator) Test(org.junit.Test)

Example 5 with SpringmvcSwaggerGenerator

use of org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator in project incubator-servicecomb-java-chassis by apache.

the class TestSchemaMetaCodec method testProtoSchemaOperationmapUserSpringMVC.

@Test
public void testProtoSchemaOperationmapUserSpringMVC() throws Exception {
    mockSchemaMeta("ProtoSchema", new SpringmvcSwaggerGenerator(ProtoSchema.class), new ProtoSchema());
    testProtoSchemaOperationmapUserImpl(false);
}
Also used : ProtoSchema(org.apache.servicecomb.codec.protobuf.internal.converter.model.ProtoSchema) SpringmvcSwaggerGenerator(org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator) Test(org.junit.Test)

Aggregations

SpringmvcSwaggerGenerator (org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator)14 ProtoSchema (org.apache.servicecomb.codec.protobuf.internal.converter.model.ProtoSchema)12 Test (org.junit.Test)12 Swagger (io.swagger.models.Swagger)4 Proto (io.protostuff.compiler.model.Proto)2 URL (java.net.URL)2 Expectations (mockit.Expectations)2 OperationMeta (org.apache.servicecomb.core.definition.OperationMeta)2 SchemaMeta (org.apache.servicecomb.core.definition.SchemaMeta)2 SwaggerEnvironment (org.apache.servicecomb.swagger.engine.SwaggerEnvironment)2 SwaggerProducer (org.apache.servicecomb.swagger.engine.SwaggerProducer)2 SwaggerProducerOperation (org.apache.servicecomb.swagger.engine.SwaggerProducerOperation)2 Before (org.junit.Before)2