use of org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator in project java-chassis by ServiceComb.
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"));
}
use of org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator in project java-chassis by ServiceComb.
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);
}
use of org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator in project incubator-servicecomb-java-chassis by apache.
the class TestSchemaMetaCodec method testProtoSchemaOperationObjSpringMVC.
@Test
public void testProtoSchemaOperationObjSpringMVC() throws Exception {
mockSchemaMeta("ProtoSchema", new SpringmvcSwaggerGenerator(ProtoSchema.class), new ProtoSchema());
testProtoSchemaOperationObjImpl(false);
}
use of org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator in project incubator-servicecomb-java-chassis by apache.
the class TestSchemaMetaCodec method testProtoSchemaOperationlistListUserSpringMVC.
@Test
public void testProtoSchemaOperationlistListUserSpringMVC() throws Exception {
mockSchemaMeta("ProtoSchema", new SpringmvcSwaggerGenerator(ProtoSchema.class), new ProtoSchema());
testProtoSchemaOperationlistListUserImpl(false);
}
Aggregations