Search in sources :

Example 1 with ConsumerArgumentsMapper

use of io.servicecomb.swagger.invocation.arguments.consumer.ConsumerArgumentsMapper in project java-chassis by ServiceComb.

the class ConsumerSchemaFactory method mapSameIntfParameters.

protected void mapSameIntfParameters(ConsumerSchemaContext context) {
    for (OperationMeta operationMeta : context.getSchemaMeta().getOperations()) {
        List<ArgumentMapper> consumerArgMapperList = new ArrayList<>();
        int swaggerParameterCount = operationMeta.getSwaggerOperation().getParameters().size();
        for (int idx = 0; idx < swaggerParameterCount; idx++) {
            ConsumerArgumentSame argMapper = new ConsumerArgumentSame(idx, idx);
            consumerArgMapperList.add(argMapper);
        }
        ConsumerArgumentsMapper argsMapper = new ConsumerArgumentsMapper(consumerArgMapperList, swaggerParameterCount);
        createOperation(context, operationMeta, argsMapper);
    }
}
Also used : ConsumerArgumentsMapper(io.servicecomb.swagger.invocation.arguments.consumer.ConsumerArgumentsMapper) ArrayList(java.util.ArrayList) ConsumerArgumentSame(io.servicecomb.swagger.invocation.arguments.consumer.ConsumerArgumentSame) ConsumerOperationMeta(io.servicecomb.core.provider.consumer.ConsumerOperationMeta) OperationMeta(io.servicecomb.core.definition.OperationMeta) ArgumentMapper(io.servicecomb.swagger.invocation.arguments.ArgumentMapper)

Example 2 with ConsumerArgumentsMapper

use of io.servicecomb.swagger.invocation.arguments.consumer.ConsumerArgumentsMapper 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);
    }
}
Also used : ConsumerArgumentsMapper(io.servicecomb.swagger.invocation.arguments.consumer.ConsumerArgumentsMapper) SwaggerGenerator(io.servicecomb.swagger.generator.core.SwaggerGenerator) Parameter(io.swagger.models.parameters.Parameter) ConsumerOperationMeta(io.servicecomb.core.provider.consumer.ConsumerOperationMeta) OperationMeta(io.servicecomb.core.definition.OperationMeta) Method(java.lang.reflect.Method) OperationGenerator(io.servicecomb.swagger.generator.core.OperationGenerator)

Aggregations

OperationMeta (io.servicecomb.core.definition.OperationMeta)2 ConsumerOperationMeta (io.servicecomb.core.provider.consumer.ConsumerOperationMeta)2 ConsumerArgumentsMapper (io.servicecomb.swagger.invocation.arguments.consumer.ConsumerArgumentsMapper)2 OperationGenerator (io.servicecomb.swagger.generator.core.OperationGenerator)1 SwaggerGenerator (io.servicecomb.swagger.generator.core.SwaggerGenerator)1 ArgumentMapper (io.servicecomb.swagger.invocation.arguments.ArgumentMapper)1 ConsumerArgumentSame (io.servicecomb.swagger.invocation.arguments.consumer.ConsumerArgumentSame)1 Parameter (io.swagger.models.parameters.Parameter)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1