Java Code Examples for io.swagger.util.ReflectionUtils#typeFromString()

The following examples show how to use io.swagger.util.ReflectionUtils#typeFromString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Reader.java    From proteus with Apache License 2.0 6 votes vote down vote up
protected Parameter readImplicitParam(ApiImplicitParam param) {
    final Parameter p;
    if (param.paramType().equalsIgnoreCase("path")) {
        p = new PathParameter();
    } else if (param.paramType().equalsIgnoreCase("query")) {
        p = new QueryParameter();
    } else if (param.paramType().equalsIgnoreCase("form") || param.paramType().equalsIgnoreCase("formData")) {
        p = new FormParameter();
    } else if (param.paramType().equalsIgnoreCase("body")) {
        p = null;
    } else if (param.paramType().equalsIgnoreCase("header")) {
        p = new HeaderParameter();
    } else {
        LOGGER.warn("Unknown implicit parameter type: [{}]", param.paramType());
        return null;
    }
    final Type type = ReflectionUtils.typeFromString(param.dataType());
     return ParameterProcessor.applyAnnotations(swagger, p, (type == null) ? String.class : type,
            Arrays.<Annotation>asList(param));
}
 
Example 2
Source File: ApiImplicitParamProcessor.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
@Override
public Type getGenericType(ApiImplicitParam apiImplicitParam) {
  Type dataTypeClass = apiImplicitParam.dataTypeClass();
  if (ReflectionUtils.isVoid(dataTypeClass)) {
    if (StringUtils.isEmpty(apiImplicitParam.dataType())) {
      return null;
    }

    dataTypeClass = ReflectionUtils.typeFromString(apiImplicitParam.dataType());
  }

  if ("array".equals(apiImplicitParam.type())) {
    return Types.arrayOf(dataTypeClass);
  }

  return dataTypeClass;
}
 
Example 3
Source File: RpcReaderExtension.java    From sofa-rpc with Apache License 2.0 5 votes vote down vote up
private Parameter readImplicitParam(Swagger swagger, ApiImplicitParam param) {
    PrimitiveType fromType = PrimitiveType.fromName(param.paramType());
    final Parameter p = null == fromType ? new FormParameter() : new QueryParameter();
    final Type type = ReflectionUtils.typeFromString(param.dataType());
    return ParameterProcessor.applyAnnotations(swagger, p, type == null ? String.class : type,
        Collections.<Annotation> singletonList(param));
}
 
Example 4
Source File: DubboReaderExtension.java    From swagger-dubbo with Apache License 2.0 5 votes vote down vote up
private Parameter readImplicitParam(Swagger swagger, ApiImplicitParam param) {
	PrimitiveType fromType = PrimitiveType.fromName(param.paramType());
	final Parameter p = null == fromType ? new FormParameter() : new QueryParameter();
	final Type type = ReflectionUtils.typeFromString(param.dataType());
	return ParameterProcessor.applyAnnotations(swagger, p, type == null ? String.class : type,
			Collections.<Annotation> singletonList(param));
}
 
Example 5
Source File: ControllerReaderExtension.java    From jboot with Apache License 2.0 5 votes vote down vote up
private Parameter readImplicitParam(Swagger swagger, ApiImplicitParam param) {
    final Parameter p = ParameterFactory.createParam(param.paramType());
    if (p == null) {
        return null;
    }
    final Type type = ReflectionUtils.typeFromString(param.dataType());
    return ParameterProcessor.applyAnnotations(swagger, p, type == null ? String.class : type,
            Collections.<Annotation>singletonList(param));
}