Search in sources :

Example 1 with ProducerArgumentsMapper

use of io.servicecomb.swagger.invocation.arguments.producer.ProducerArgumentsMapper 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);
    }
}
Also used : ProducerArgumentsMapper(io.servicecomb.swagger.invocation.arguments.producer.ProducerArgumentsMapper) Parameter(io.swagger.models.parameters.Parameter) 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)1 OperationGenerator (io.servicecomb.swagger.generator.core.OperationGenerator)1 ProducerArgumentsMapper (io.servicecomb.swagger.invocation.arguments.producer.ProducerArgumentsMapper)1 Parameter (io.swagger.models.parameters.Parameter)1 Method (java.lang.reflect.Method)1