本文整理汇总了Java中io.swagger.models.parameters.SerializableParameter.getType方法的典型用法代码示例。如果您正苦于以下问题:Java SerializableParameter.getType方法的具体用法?Java SerializableParameter.getType怎么用?Java SerializableParameter.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.swagger.models.parameters.SerializableParameter
的用法示例。
在下文中一共展示了SerializableParameter.getType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: javaTypeFor
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
static String javaTypeFor(final SerializableParameter parameter) {
final String type = parameter.getType();
if ("array".equals(type)) {
final Property items = parameter.getItems();
final String elementType = items.getType();
final String elementFormat = items.getFormat();
return javaTypeFor(elementType, elementFormat) + "[]";
}
final String format = parameter.getFormat();
return javaTypeFor(type, format);
}
示例2: getParameterValue
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
private static Object getParameterValue(Swagger swagger, SerializableParameter param, TestType testType) {
RandomGenerator generator = RandomGeneratorFactory.getRandomGenerator(testType);
if (param.getRequired() || generator.getBool() || generator.getBool()) {
if (param.getEnum() != null && !param.getEnum().isEmpty()) {
return generator.getValue(param.getEnum());
} else {
switch (param.getType()) {
case "string":
return FormatGenerator.getString(generator, param.getFormat(),
(param.getMinLength() != null ? param.getMinLength() : 1),
(param.getMaxLength() != null ? param.getMaxLength() : 25));
case "number":
return FormatGenerator.getNumber(generator, param.getFormat(),
(param.getMinimum() != null ? param.getMinimum() : Double.MIN_VALUE),
(param.getMaximum() != null ? param.getMaximum() : Double.MAX_VALUE));
case "integer":
return FormatGenerator.getInteger(generator, param.getFormat(),
(param.getMinimum() != null ? param.getMinimum().longValue() : Integer.MIN_VALUE),
(param.getMaximum() != null ? param.getMaximum().longValue() : Integer.MAX_VALUE));
case "boolean":
return FormatGenerator.getBoolean(generator);
case "array":
return getArray(swagger, generator, param,
(param.getMinItems() != null ? param.getMinItems() : (param.getRequired() ? 1 : 0)),
(param.getMaxItems() != null ? param.getMaxItems() : 10));
case "file":
return getFile();
default:
throw new RuntimeException("This type is not supported (" + param.getType() + ").");
}
}
} else {
return null;
}
}
示例3: createPropertyFromParameter
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的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 SerializableParameter)) {
throw new IllegalStateException(
"Unexpected parameter type received, neither ref, body nor serializable: " + parameter);
}
final String name = parameter.getName();
final String description = 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 SerializableParameter serializableParameter = (SerializableParameter) parameter;
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());
}
示例4: invalidTypeMessage
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
protected String invalidTypeMessage(SerializableParameter param, String value, int index) {
return "invalid " + param.getType() + " value for " + param.getIn() + " param " + param.getName()
+ (index == -1 ? "" : "[" + index + "]") + ": " + value;
}