public static void setParameterType(Swagger swagger, Method method, int paramIdx, AbstractSerializableParameter<?> parameter) { Type paramType = ParamUtils.getGenericParameterType(method, paramIdx); ParamUtils.addDefinitions(swagger, paramType); Property property = ModelConverters.getInstance().readAsProperty(paramType); if (isComplexProperty(property)) { // cannot set a simple parameter(header, query, etc.) as complex type String msg = String.format("not allow complex type for %s parameter, method=%s:%s, paramIdx=%d, type=%s", parameter.getIn(), method.getDeclaringClass().getName(), method.getName(), paramIdx, paramType.getTypeName()); throw new Error(msg); } parameter.setProperty(property); }
private Model getParamModel(OperationGenerator operationGenerator, int paramIndex) { Type paramType = ParamUtils.getGenericParameterType(operationGenerator.getProviderMethod(), paramIndex); Property property = ModelConverters.getInstance().readAsProperty(paramType); // ensure type if (!RefProperty.class.isInstance(property)) { LOGGER.error("Unsupported property type: [{}], paramIndex is [{}]", property.getClass().getName(), paramIndex); return null; } Map<String, Model> models = ModelConverters.getInstance().readAll(paramType); // find param root RefProperty refProperty = (RefProperty) property; String refTypeName = refProperty.getSimpleRef(); Model paramRoot = null; for (Entry<String, Model> entry : models.entrySet()) { if (refTypeName.equals(entry.getKey())) { paramRoot = entry.getValue(); break; } } return paramRoot; }
public static PendingBodyParameter createPendingBodyParameter(OperationGenerator operationGenerator, int paramIdx) { Method method = operationGenerator.getProviderMethod(); String paramName = ParamUtils.getParameterName(method, paramIdx); Type paramType = ParamUtils.getGenericParameterType(method, paramIdx); return createPendingBodyParameter(operationGenerator, paramName, paramType); }
public static BodyParameter createBodyParameter(OperationGenerator operationGenerator, int paramIdx) { Method method = operationGenerator.getProviderMethod(); String paramName = getParameterName(method, paramIdx); Type paramType = getGenericParameterType(method, paramIdx); return createBodyParameter(operationGenerator.getSwagger(), paramName, paramType); }
@Override public void process(OperationGenerator operationGenerator, int paramIdx) { Type paramType = ParamUtils.getGenericParameterType(operationGenerator.getProviderMethod(), paramIdx); Property property = ModelConverters.getInstance().readAsProperty(paramType); if (RefProperty.class.isInstance(property)) { objectParameterProcessor.process(operationGenerator, paramIdx); return; } if (!ParamUtils.isComplexProperty(property)) { simpleParameterProcessor.process(operationGenerator, paramIdx); return; } // unsupported param type String msg = String.format("cannot process parameter [%s], method=%s:%s, paramIdx=%d, type=%s", ParamUtils.getParameterName(operationGenerator.getProviderMethod(), paramIdx), operationGenerator.getProviderMethod().getDeclaringClass().getName(), operationGenerator.getProviderMethod().getName(), paramIdx, paramType.getTypeName()); throw new Error(msg); } }
public static void setParameterType(Swagger swagger, Method method, int paramIdx, AbstractSerializableParameter<?> parameter) { Type paramType = ParamUtils.getGenericParameterType(method, paramIdx); ParamUtils.addDefinitions(swagger, paramType); Property property = ModelConverters.getInstance().readAsProperty(paramType); if (isComplexProperty(property)) { // cannot set a simple parameter(header, query, etc.) as complex type String msg = String.format("not allow complex type for %s parameter, method=%s:%s, paramIdx=%d, type=%s", parameter.getIn(), method.getDeclaringClass().getName(), method.getName(), paramIdx, paramType.getTypeName()); throw new Error(msg); } parameter.setProperty(property); }
public static PendingBodyParameter createPendingBodyParameter(OperationGenerator operationGenerator, int paramIdx) { Method method = operationGenerator.getProviderMethod(); String paramName = ParamUtils.getParameterName(method, paramIdx); Type paramType = ParamUtils.getGenericParameterType(method, paramIdx); return createPendingBodyParameter(operationGenerator, paramName, paramType); }
private Model getParamModel(OperationGenerator operationGenerator, int paramIndex) { Type paramType = ParamUtils.getGenericParameterType(operationGenerator.getProviderMethod(), paramIndex); Property property = ModelConverters.getInstance().readAsProperty(paramType); // ensure type if (!RefProperty.class.isInstance(property)) { LOGGER.error("Unsupported property type: [{}], paramIndex is [{}]", property.getClass().getName(), paramIndex); return null; } Map<String, Model> models = ModelConverters.getInstance().readAll(paramType); // find param root RefProperty refProperty = (RefProperty) property; String refTypeName = refProperty.getSimpleRef(); Model paramRoot = null; for (Entry<String, Model> entry : models.entrySet()) { if (refTypeName.equals(entry.getKey())) { paramRoot = entry.getValue(); break; } } return paramRoot; }
public static BodyParameter createBodyParameter(OperationGenerator operationGenerator, int paramIdx) { Method method = operationGenerator.getProviderMethod(); String paramName = getParameterName(method, paramIdx); Type paramType = getGenericParameterType(method, paramIdx); return createBodyParameter(operationGenerator.getSwagger(), paramName, paramType); }
@Override public void process(OperationGenerator operationGenerator, int paramIdx) { Type paramType = ParamUtils.getGenericParameterType(operationGenerator.getProviderMethod(), paramIdx); Property property = ModelConverters.getInstance().readAsProperty(paramType); if (RefProperty.class.isInstance(property)) { objectParameterProcessor.process(operationGenerator, paramIdx); return; } if (!ParamUtils.isComplexProperty(property)) { simpleParameterProcessor.process(operationGenerator, paramIdx); return; } // unsupported param type String msg = String.format("cannot process parameter [%s], method=%s:%s, paramIdx=%d, type=%s", ParamUtils.getParameterName(operationGenerator.getProviderMethod(), paramIdx), operationGenerator.getProviderMethod().getDeclaringClass().getName(), operationGenerator.getProviderMethod().getName(), paramIdx, paramType.getTypeName()); throw new Error(msg); } }