当前位置: 首页>>代码示例>>Java>>正文


Java AbstractSerializableParameter.getType方法代码示例

本文整理汇总了Java中io.swagger.models.parameters.AbstractSerializableParameter.getType方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractSerializableParameter.getType方法的具体用法?Java AbstractSerializableParameter.getType怎么用?Java AbstractSerializableParameter.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.swagger.models.parameters.AbstractSerializableParameter的用法示例。


在下文中一共展示了AbstractSerializableParameter.getType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convert

import io.swagger.models.parameters.AbstractSerializableParameter; //导入方法依赖的package包/类
@Override
public JavaType convert(ClassLoader classLoader, String packageName, Swagger swagger, Object def) {
  AbstractSerializableParameter<?> param = (AbstractSerializableParameter<?>) def;

  switch (param.getType()) {
    case ArrayProperty.TYPE:
      return ArrayPropertyConverter.findJavaType(classLoader,
          packageName,
          swagger,
          param.getItems(),
          param.isUniqueItems());
    case StringProperty.TYPE:
      return StringPropertyConverter.findJavaType(classLoader,
          packageName,
          swagger,
          param.getType(),
          param.getFormat(),
          param.getEnum());
    default:
      return ConverterMgr.findJavaType(param.getType(), param.getFormat());
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:23,代码来源:AbstractSerializableParameterConverter.java

示例2: getDefaultValue

import io.swagger.models.parameters.AbstractSerializableParameter; //导入方法依赖的package包/类
public static String getDefaultValue(Parameter parameter){
    Validate.notNull(parameter, "property must not be null!");
    String defaultValue = "";
    if(parameter instanceof AbstractSerializableParameter){
        AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter)parameter;
        defaultValue = serializableParameter.getDefaultValue();
        if(defaultValue == null || defaultValue.isEmpty()) {
            switch (serializableParameter.getType()) {
                case "string":
                    return "\"str\"";
                case "integer":
                    return "0";
                default:
                    return "";
            }
        }
    }

    return StringUtils.defaultString(defaultValue);
}
 
开发者ID:buremba,项目名称:swagger-slate,代码行数:21,代码来源:ParameterUtils.java

示例3: getValue

import io.swagger.models.parameters.AbstractSerializableParameter; //导入方法依赖的package包/类
private String getValue(AbstractSerializableParameter value)
{
    switch (value.getType()) {
        case "date":
            return "\"2015-01-20\"";
        case "string":
            return "\"str\"";
        case "integer":
        case "long":
            return "0";
        case "double":
            return "0.0";
        case "boolean":
            return "false";
        case "map":
            return "{\"prop\": value}";
        case "array":
            return "[\n\t" + getValue(value.getItems()) + "\n]";
        default:
            return "";
    }
}
 
开发者ID:buremba,项目名称:swagger-slate,代码行数:23,代码来源:SlateDocumentGenerator.java

示例4: readParam

import io.swagger.models.parameters.AbstractSerializableParameter; //导入方法依赖的package包/类
private Parameter readParam(Swagger swagger, Type type,Class<?> cls, ApiParam param) {
	PrimitiveType fromType = PrimitiveType.fromType(type);
	final Parameter para = null == fromType ? new FormParameter() : new QueryParameter();
	Parameter parameter = ParameterProcessor.applyAnnotations(swagger, para,
			type == null ? String.class : type, null == param ? new ArrayList<Annotation>()
					: Collections.<Annotation> singletonList(param));
	if (parameter instanceof AbstractSerializableParameter) {
		final AbstractSerializableParameter<?> p = (AbstractSerializableParameter<?>) parameter;
		if (p.getType() == null) p.setType(null == fromType ? "string" : fromType.getCommonName());
		p.setRequired(p.getRequired() == true ? true : cls.isPrimitive());
	}
	return parameter;
}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:14,代码来源:DubboReaderExtension.java

示例5: generateExample

import io.swagger.models.parameters.AbstractSerializableParameter; //导入方法依赖的package包/类
/**
 * Generate a default example value for parameter.
 *
 * @param parameter parameter
 * @return a generated example for the parameter
 */
public static Object generateExample(AbstractSerializableParameter parameter) {
    switch (parameter.getType()) {
        case "integer":
            return 0;
        case "number":
            return 0.0;
        case "boolean":
            return true;
        case "string":
            return "string";
        default:
            return parameter.getType();
    }
}
 
开发者ID:Swagger2Markup,项目名称:swagger2markup,代码行数:21,代码来源:ParameterAdapter.java

示例6: getType

import io.swagger.models.parameters.AbstractSerializableParameter; //导入方法依赖的package包/类
/**
 * Retrieves the type of a parameter, or otherwise null
 *
 * @param definitionDocumentResolver the definition document resolver
 * @return the type of the parameter, or otherwise null
 */
private Type getType(Map<String, Model> definitions, DocumentResolver definitionDocumentResolver) {
    Validate.notNull(parameter, "parameter must not be null!");
    Type type = null;

    if (parameter instanceof BodyParameter) {
        BodyParameter bodyParameter = (BodyParameter) parameter;
        Model model = bodyParameter.getSchema();

        if (model != null) {
            type = ModelUtils.getType(model, definitions, definitionDocumentResolver);
        } else {
            type = new BasicType("string", bodyParameter.getName());
        }

    } else if (parameter instanceof AbstractSerializableParameter) {
        AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter) parameter;
        @SuppressWarnings("unchecked")
        List<String> enums = serializableParameter.getEnum();

        if (CollectionUtils.isNotEmpty(enums)) {
            type = new EnumType(serializableParameter.getName(), enums);
        } else {
            type = new BasicType(serializableParameter.getType(), serializableParameter.getName(), serializableParameter.getFormat());
        }
        if (serializableParameter.getType().equals("array")) {
            String collectionFormat = serializableParameter.getCollectionFormat();

            type = new ArrayType(serializableParameter.getName(), new PropertyAdapter(serializableParameter.getItems()).getType(definitionDocumentResolver), collectionFormat);
        }
    } else if (parameter instanceof RefParameter) {
        String refName = ((RefParameter) parameter).getSimpleRef();

        type = new RefType(definitionDocumentResolver.apply(refName), new ObjectType(refName, null /* FIXME, not used for now */));
    }
    return type;
}
 
开发者ID:Swagger2Markup,项目名称:swagger2markup,代码行数:43,代码来源:ParameterAdapter.java

示例7: createPropertyFromParameter

import io.swagger.models.parameters.AbstractSerializableParameter; //导入方法依赖的package包/类
static Optional<ConfigurationProperty> createPropertyFromParameter(final Parameter parameter) {
    if (parameter instanceof RefParameter || parameter instanceof BodyParameter) {
        // Reference parameters are not supported, body parameters are
        // handled in createShape* methods

        return Optional.empty();
    }

    if (!(parameter instanceof AbstractSerializableParameter<?>)) {
        throw new IllegalArgumentException("Unexpected parameter type received, neither ref, body nor serializable: " + parameter);
    }

    final String name = trimToNull(parameter.getName());
    final String description = trimToNull(parameter.getDescription());
    final boolean required = parameter.getRequired();

    final ConfigurationProperty.Builder propertyBuilder = new ConfigurationProperty.Builder()//
        .kind("property")//
        .displayName(name)//
        .description(description)//
        .group("producer")//
        .required(required)//
        .componentProperty(false)//
        .deprecated(false)//
        .secret(false);

    final AbstractSerializableParameter<?> serializableParameter = (AbstractSerializableParameter<?>) parameter;

    final Object defaultValue = serializableParameter.getDefaultValue();
    if (defaultValue != null) {
        propertyBuilder.defaultValue(String.valueOf(defaultValue));
    }

    final String type = serializableParameter.getType();
    propertyBuilder.type(type).javaType(JsonSchemaHelper.javaTypeFor(serializableParameter));

    final List<String> enums = serializableParameter.getEnum();
    if (enums != null) {
        propertyBuilder.addAllEnum(createEnums(enums));
    }

    return Optional.of(propertyBuilder.build());
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:44,代码来源:BaseSwaggerConnectorGenerator.java

示例8: convertParameterToType

import io.swagger.models.parameters.AbstractSerializableParameter; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private AbstractType convertParameterToType(Parameter p) {
	if (p instanceof AbstractSerializableParameter<?>) {
		AbstractSerializableParameter<?> basicModel = (AbstractSerializableParameter<?>) p;
		String type = basicModel.getType();
		if (type == null && basicModel.getMinimum() != null) {
			type = "number";
		}
		if (type == null && basicModel.getMaximum() != null) {
			type = "number";
		}

		if (type == null && basicModel.getEnum() != null) {
			type = "string";
		}

		if (type != null && type.equals("array")) {
			if (basicModel.getEnum() != null) {
				type = "string";
			}
			// FIXME
		}
		if (type != null && type.equals("boolean")) {
			basicModel.setEnum(null);// FIXME
		}
		String format = basicModel.getFormat();
		FormatMapper mapFormat = FormatMapper.mapFormat(new FormatMapper(type, format));
		type = mapFormat.type;
		if (((AbstractSerializableParameter) p).getEnum() != null) {
			@SuppressWarnings("unchecked")
			LinkedHashSet<Object> linkedHashSet = new LinkedHashSet<>(
					((AbstractSerializableParameter) p).getEnum());
			linkedHashSet.remove(null);
			((AbstractSerializableParameter) p).setEnum(new ArrayList<>(linkedHashSet));
		}
		format = mapFormat.format;
		AbstractType st = base(type);
		AbstractType derive = TypeOps.derive("", st);
		transferTo(derive, Description.class, basicModel.getDescription());
		transferTo(derive, Example.class, basicModel.getExample());
		transferTo(derive, DisplayName.class, basicModel.getName());
		transferTo(derive, Default.class, basicModel.getDefaultValue());
		transferTo(derive, Enum.class, basicModel.getEnum());

		transferTo(derive, Format.class, format);
		transferTo(derive, MaxLength.class, basicModel.getMaxLength());
		transferTo(derive, MinLength.class, basicModel.getMinLength());
		transferTo(derive, Pattern.class, basicModel.getPattern());
		transferTo(derive, Enum.class, basicModel.getEnum());
		transferTo(derive, Minimum.class, basicModel.getMinimum());
		transferTo(derive, Maximum.class, basicModel.getMaximum());
		Property items = basicModel.getItems();
		if (items != null) {
			derive.addMeta(new ComponentShouldBeOfType(propertyToType(items)));
		}
		return derive;
	} else if (p instanceof RefParameter) {
		throw new IllegalStateException();
	} else if (p instanceof BodyParameter) {
		BodyParameter bp = (BodyParameter) p;
		Model schema = bp.getSchema();
		AbstractType convertType = convertType("", schema);
		transferTo(convertType, Description.class, bp.getDescription());
		transferTo(convertType, Example.class, bp.getExamples());
		return convertType;
	} else {
		throw new IllegalStateException();
	}
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:70,代码来源:SwaggerReader.java


注:本文中的io.swagger.models.parameters.AbstractSerializableParameter.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。