本文整理汇总了Java中io.swagger.models.properties.DecimalProperty类的典型用法代码示例。如果您正苦于以下问题:Java DecimalProperty类的具体用法?Java DecimalProperty怎么用?Java DecimalProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DecimalProperty类属于io.swagger.models.properties包,在下文中一共展示了DecimalProperty类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initPropertyMap
import io.swagger.models.properties.DecimalProperty; //导入依赖的package包/类
private static void initPropertyMap() {
PROPERTY_MAP.put(BooleanProperty.class, SimpleType.constructUnsafe(Boolean.class));
PROPERTY_MAP.put(FloatProperty.class, SimpleType.constructUnsafe(Float.class));
PROPERTY_MAP.put(DoubleProperty.class, SimpleType.constructUnsafe(Double.class));
PROPERTY_MAP.put(DecimalProperty.class, SimpleType.constructUnsafe(BigDecimal.class));
PROPERTY_MAP.put(ByteProperty.class, SimpleType.constructUnsafe(Byte.class));
PROPERTY_MAP.put(ShortProperty.class, SimpleType.constructUnsafe(Short.class));
PROPERTY_MAP.put(IntegerProperty.class, SimpleType.constructUnsafe(Integer.class));
PROPERTY_MAP.put(BaseIntegerProperty.class, SimpleType.constructUnsafe(Integer.class));
PROPERTY_MAP.put(LongProperty.class, SimpleType.constructUnsafe(Long.class));
// stringProperty包含了enum的场景,并不一定是转化为string
// 但是,如果统一走StringPropertyConverter则可以处理enum的场景
PROPERTY_MAP.put(StringProperty.class, SimpleType.constructUnsafe(String.class));
PROPERTY_MAP.put(DateProperty.class, SimpleType.constructUnsafe(LocalDate.class));
PROPERTY_MAP.put(DateTimeProperty.class, SimpleType.constructUnsafe(Date.class));
PROPERTY_MAP.put(ByteArrayProperty.class, SimpleType.constructUnsafe(byte[].class));
PROPERTY_MAP.put(FileProperty.class, SimpleType.constructUnsafe(Part.class));
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:25,代码来源:ConverterMgr.java
示例2: getSwaggerValidator
import io.swagger.models.properties.DecimalProperty; //导入依赖的package包/类
protected SwaggerValidator getSwaggerValidator(Request<JSONObject> request) {
SwaggerValidator val = new SwaggerValidator(request);
val.addValidator(DecimalProperty.class, (json, property, path, strict) -> {
if (property.getName().equals("rating")) {
BigDecimal value = json.getBigDecimal(property.getName());
if (value.floatValue() % 0.5 != 0)
return new Result(Status.BAD_REQUEST, path + ": value '" + value + "' must be a multiple of 0.5");
}
return new Result(Status.OK);
});
return val;
}
开发者ID:limberest,项目名称:limberest-demo,代码行数:13,代码来源:MoviesService.java
示例3: build
import io.swagger.models.properties.DecimalProperty; //导入依赖的package包/类
public Property build() {
DecimalProperty property = new DecimalProperty();
property.setFormat(format);
property.setExample(example);
return property;
}
开发者ID:pegasystems,项目名称:api2swagger,代码行数:7,代码来源:NumberPropertyBuilder.java
示例4: fillProperty
import io.swagger.models.properties.DecimalProperty; //导入依赖的package包/类
public static Object fillProperty(Swagger swagger, RandomGenerator gen, Property property) {
switch (property.getType()) {
case "string":
if (property instanceof StringProperty) {
StringProperty stringProp = (StringProperty) property;
if (stringProp.getEnum() != null && !stringProp.getEnum().isEmpty()) {
return gen.getValue(stringProp.getEnum());
} else {
return FormatGenerator.getString(gen, stringProp.getFormat(),
(stringProp.getMinLength() != null ? stringProp.getMinLength() : 1),
(stringProp.getMaxLength() != null ? stringProp.getMaxLength() : 25));
}
} else if (property instanceof DateTimeProperty) {
DateTimeProperty dateTimeProp = (DateTimeProperty) property;
if (dateTimeProp.getEnum() != null && !dateTimeProp.getEnum().isEmpty()) {
return gen.getValue(dateTimeProp.getEnum());
} else {
return FormatGenerator.getString(gen, dateTimeProp.getFormat(), 0, 0);
}
} else if (property instanceof DateProperty) {
DateProperty dateProp = (DateProperty) property;
if (dateProp.getEnum() != null && !dateProp.getEnum().isEmpty()) {
return gen.getValue(dateProp.getEnum());
} else {
return FormatGenerator.getString(gen, dateProp.getFormat(), 0, 0);
}
} else {
throw new RuntimeException(
"This String format is not supported : " + property.getClass().getSimpleName());
}
case "integer":
BaseIntegerProperty intProp = (BaseIntegerProperty) property;
return FormatGenerator.getInteger(gen, intProp.getFormat(),
(intProp.getMinimum() != null ? intProp.getMinimum().intValue() : Integer.MIN_VALUE),
(intProp.getMaximum() != null ? intProp.getMaximum().intValue() : Integer.MAX_VALUE));
case "number":
DecimalProperty numberProp = (DecimalProperty) property;
return FormatGenerator.getNumber(gen, numberProp.getFormat(),
(numberProp.getMinimum() != null ? numberProp.getMinimum() : Double.MIN_VALUE),
(numberProp.getMaximum() != null ? numberProp.getMaximum() : Double.MAX_VALUE));
case "boolean":
return FormatGenerator.getBoolean(gen);
case "ref":
return getRef(swagger, gen, (RefProperty) property);
case "array":
return getArray(swagger, gen, (ArrayProperty) property);
default:
throw new RuntimeException("This type is not supported.");
}
}
开发者ID:lpelleau,项目名称:SwagTester,代码行数:51,代码来源:BodyGenerator.java
注:本文中的io.swagger.models.properties.DecimalProperty类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论