com.fasterxml.jackson.module.jsonSchema.JsonSchema.isStringSchema()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中com.fasterxml.jackson.module.jsonSchema.JsonSchema.isStringSchema()方法的一些代码示例,展示了JsonSchema.isStringSchema()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonSchema.isStringSchema()方法的具体详情如下:
包路径:com.fasterxml.jackson.module.jsonSchema.JsonSchema
类名称:JsonSchema
方法名:isStringSchema

JsonSchema.isStringSchema介绍

[英]determine if this JsonSchema is an StringSchema.
[中]确定此JsonSchema是否为StringSchema。

代码示例

代码示例来源:origin: com.github.terran4j/terran4j-commons-api2doc

public static ApiDataType toDataType(JsonSchema schema) {
  if (schema == null) {
    return null;
  }
  if (schema.isBooleanSchema()) {
    return ApiDataType.BOOLEAN;
  }
  if (schema.isIntegerSchema()) {
    return ApiDataType.INT;
  }
  if (schema.isStringSchema()) {
    return ApiDataType.STRING;
  }
  if (schema.isNumberSchema()) {
    return ApiDataType.NUMBER;
  }
  if (schema.isObjectSchema()) {
    return ApiDataType.OBJECT;
  }
  if (schema.isArraySchema()) {
    return ApiDataType.ARRAY;
  }
  return null;
}

代码示例来源:origin: com.fasterxml.jackson.module/jackson-module-jsonSchema

protected JsonSchema addValidationConstraints(JsonSchema schema, BeanProperty prop) {
  {
    Boolean required = constraintResolver.getRequired(prop);
    if (required != null) {
      schema.setRequired(required);
    }
  }
  if (schema.isArraySchema()) {
    ArraySchema arraySchema = schema.asArraySchema();
    arraySchema.setMaxItems(constraintResolver.getArrayMaxItems(prop));
    arraySchema.setMinItems(constraintResolver.getArrayMinItems(prop));
  } else if (schema.isNumberSchema()) {
    NumberSchema numberSchema = schema.asNumberSchema();
    numberSchema.setMaximum(constraintResolver.getNumberMaximum(prop));
    numberSchema.setMinimum(constraintResolver.getNumberMinimum(prop));
  } else if (schema.isStringSchema()) {
    StringSchema stringSchema = schema.asStringSchema();
    stringSchema.setMaxLength(constraintResolver.getStringMaxLength(prop));
    stringSchema.setMinLength(constraintResolver.getStringMinLength(prop));
    stringSchema.setPattern(constraintResolver.getStringPattern(prop));
  }
  return schema;
}

代码示例来源:origin: FasterXML/jackson-module-jsonSchema

protected JsonSchema addValidationConstraints(JsonSchema schema, BeanProperty prop) {
  {
    Boolean required = constraintResolver.getRequired(prop);
    if (required != null) {
      schema.setRequired(required);
    }
  }
  if (schema.isArraySchema()) {
    ArraySchema arraySchema = schema.asArraySchema();
    arraySchema.setMaxItems(constraintResolver.getArrayMaxItems(prop));
    arraySchema.setMinItems(constraintResolver.getArrayMinItems(prop));
  } else if (schema.isNumberSchema()) {
    NumberSchema numberSchema = schema.asNumberSchema();
    numberSchema.setMaximum(constraintResolver.getNumberMaximum(prop));
    numberSchema.setMinimum(constraintResolver.getNumberMinimum(prop));
  } else if (schema.isStringSchema()) {
    StringSchema stringSchema = schema.asStringSchema();
    stringSchema.setMaxLength(constraintResolver.getStringMaxLength(prop));
    stringSchema.setMinLength(constraintResolver.getStringMinLength(prop));
    stringSchema.setPattern(constraintResolver.getStringPattern(prop));
  }
  return schema;
}

相关文章