use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class UrlPathAccessItem method appendClientFormattedItem.
@Override
public void appendClientFormattedItem(InvocationFinishEvent finishEvent, StringBuilder builder) {
OperationMeta operationMeta = finishEvent.getInvocation().getOperationMeta();
SchemaMeta schemaMeta = finishEvent.getInvocation().getSchemaMeta();
if (operationMeta != null && schemaMeta != null && schemaMeta.getSwagger() != null) {
builder.append(schemaMeta.getSwagger().getBasePath()).append(operationMeta.getOperationPath());
return;
}
RestClientRequestImpl restRequestImpl = (RestClientRequestImpl) finishEvent.getInvocation().getHandlerContext().get(RestConst.INVOCATION_HANDLER_REQUESTCLIENT);
if (null == restRequestImpl || null == restRequestImpl.getRequest() || StringUtils.isEmpty(restRequestImpl.getRequest().path())) {
builder.append(EMPTY_RESULT);
return;
}
builder.append(restRequestImpl.getRequest().path());
}
use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class InvokerUtils method createInvocation.
private static Invocation createInvocation(String microserviceName, String microserviceVersion, String transport, String schemaId, String operationId, Map<String, Object> swaggerArguments, Type responseType) {
MicroserviceReferenceConfig microserviceReferenceConfig = SCBEngine.getInstance().createMicroserviceReferenceConfig(microserviceName, microserviceVersion);
MicroserviceMeta microserviceMeta = microserviceReferenceConfig.getLatestMicroserviceMeta();
SchemaMeta schemaMeta = microserviceMeta.ensureFindSchemaMeta(schemaId);
OperationMeta operationMeta = schemaMeta.ensureFindOperation(operationId);
ReferenceConfig referenceConfig = microserviceReferenceConfig.createReferenceConfig(transport, operationMeta);
InvocationRuntimeType invocationRuntimeType = operationMeta.buildBaseConsumerRuntimeType();
invocationRuntimeType.setSuccessResponseType(responseType);
return InvocationFactory.forConsumer(referenceConfig, operationMeta, invocationRuntimeType, swaggerArguments);
}
use of org.apache.servicecomb.core.definition.SchemaMeta 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);
}
Aggregations