use of io.servicecomb.swagger.generator.core.OperationGenerator in project java-chassis by ServiceComb.
the class OpMeta method init.
protected void init() {
Class<?> swaggerInterface = ClassUtils.getOrCreateInterface(swagger, null, null);
for (OperationGenerator operationGenerator : providerGenerator.getOperationGeneratorMap().values()) {
String methodName = operationGenerator.getProviderMethod().getName();
Method swaggerMethod = ReflectUtils.findMethod(swaggerInterface, methodName);
List<Parameter> swaggerParameters = findParameter(swagger, methodName);
List<Parameter> providerParameters = findParameter(providerGenerator, methodName);
ARGS_MAPPER argsMapper = factory.createArgumentsMapper(swagger, swaggerMethod, swaggerParameters, operationGenerator.getProviderMethod(), providerParameters);
swaggerMethodMap.put(methodName, swaggerMethod);
operationArgsMapperMap.put(methodName, argsMapper);
}
}
use of io.servicecomb.swagger.generator.core.OperationGenerator in project java-chassis by ServiceComb.
the class ProducerSchemaFactory method connectToProvider.
@Override
protected void connectToProvider(ProducerSchemaContext context) {
if (context.getGenerator() == null) {
generateSwagger(context);
}
// 建立契约与producer之间的参数映射关系
Class<?> swaggerIntf = ClassUtils.getJavaInterface(context.getSchemaMeta().getSwagger());
for (OperationMeta operationMeta : context.getSchemaMeta().getOperations()) {
OperationGenerator operationGenerator = context.getGenerator().getOperationGeneratorMap().get(operationMeta.getOperationId());
Method swaggerMethod = ReflectUtils.findMethod(swaggerIntf, operationMeta.getOperationId());
List<Parameter> swaggerParameters = operationMeta.getSwaggerOperation().getParameters();
Method producerMethod = operationGenerator.getProviderMethod();
List<Parameter> producerParameters = operationGenerator.getProviderParameters();
ProducerArgumentsMapper argsMapper = producerArgsMapperFactory.createArgumentsMapper(context.getSchemaMeta().getSwagger(), swaggerMethod, swaggerParameters, producerMethod, producerParameters);
createOperation(context, operationMeta, argsMapper);
}
}
use of io.servicecomb.swagger.generator.core.OperationGenerator in project java-chassis by ServiceComb.
the class ConsumerSchemaFactory method mapDiffIntfParameters.
protected void mapDiffIntfParameters(ConsumerSchemaContext context) {
// 建立契约与consumer之间的参数映射关系
Class<?> swaggerIntf = ClassUtils.getJavaInterface(context.getSchemaMeta().getSwagger());
SwaggerGenerator generator = generateSwagger(context);
for (OperationMeta operationMeta : context.getSchemaMeta().getOperations()) {
OperationGenerator operationGenerator = generator.getOperationGeneratorMap().get(operationMeta.getOperationId());
// swagger集合可能大于consumer集合
if (operationGenerator == null) {
continue;
}
Method swaggerMethod = ReflectUtils.findMethod(swaggerIntf, operationMeta.getOperationId());
List<Parameter> swaggerParameters = operationMeta.getSwaggerOperation().getParameters();
Method consumerMethod = operationGenerator.getProviderMethod();
List<Parameter> consumerParameters = operationGenerator.getProviderParameters();
ConsumerArgumentsMapper argsMapper = consumerArgsMapperFactory.createArgumentsMapper(context.getSchemaMeta().getSwagger(), swaggerMethod, swaggerParameters, consumerMethod, consumerParameters);
createOperation(context, operationMeta, argsMapper);
}
}
Aggregations