本文整理汇总了Java中com.fasterxml.jackson.module.jsonSchema.JsonSchema.setId方法的典型用法代码示例。如果您正苦于以下问题:Java JsonSchema.setId方法的具体用法?Java JsonSchema.setId怎么用?Java JsonSchema.setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.module.jsonSchema.JsonSchema
的用法示例。
在下文中一共展示了JsonSchema.setId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSchema
import com.fasterxml.jackson.module.jsonSchema.JsonSchema; //导入方法依赖的package包/类
protected void getSchema(Class<?> clazz, ObjectNode schema, ArrayNode form) throws JsonMappingException {
SchemaFactoryWrapper factoryWrapper = new SchemaFactoryWrapper();
JsonSubTypes subtype = clazz.getAnnotation(JsonSubTypes.class);
if (subtype != null) {
doForSubtype(factoryWrapper, schema, form, subtype);
} else {
objectMapper.acceptJsonFormatVisitor(objectMapper.constructType(clazz), factoryWrapper);
JsonSchema jsonSchema = factoryWrapper.finalSchema();
jsonSchema.setId(null);
String title = clazz.getSimpleName().replaceAll("\\.", "_");
jsonSchema.asObjectSchema().setTitle(title);
iterateOnProperties(jsonSchema.asObjectSchema().getProperties());
schema.putPOJO(title, jsonSchema);
}
}
示例2: iterateOnProperties
import com.fasterxml.jackson.module.jsonSchema.JsonSchema; //导入方法依赖的package包/类
public void iterateOnProperties(Map<String, JsonSchema> properties) {
properties.remove("type");
for (Entry<String, JsonSchema> entry : properties.entrySet()) {
entry.getValue().setId(null);
if (entry.getValue().isSimpleTypeSchema()) {
entry.getValue().asSimpleTypeSchema().setTitle(entry.getKey());
if (entry.getValue().isObjectSchema()) {
iterateOnProperties(entry.getValue().asObjectSchema().getProperties());
}
if (entry.getValue().isArraySchema()) {
JsonSchema arraySchema = entry.getValue().asArraySchema().getItems().asSingleItems().getSchema();
arraySchema.setId(null);
if (arraySchema.isSimpleTypeSchema()) {
arraySchema.asSimpleTypeSchema().setTitle(entry.getKey().substring(0, entry.getKey().length() - 1));
if (arraySchema.isObjectSchema()) {
iterateOnProperties(arraySchema.asObjectSchema().getProperties());
}
}
}
}
}
}
示例3: doForSubtype
import com.fasterxml.jackson.module.jsonSchema.JsonSchema; //导入方法依赖的package包/类
public void doForSubtype(SchemaFactoryWrapper factoryWrapper, ObjectNode schema, ArrayNode form, JsonSubTypes subtype) throws JsonMappingException {
List<String> types = new ArrayList<>();
for (JsonSubTypes.Type type : subtype.value()) {
objectMapper.acceptJsonFormatVisitor(objectMapper.constructType(type.value()), factoryWrapper);
JsonSchema jsonSchema = factoryWrapper.finalSchema();
jsonSchema.setId(null);
String title = type.name().replaceAll("\\.", "_");
jsonSchema.asObjectSchema().setTitle(title);
iterateOnProperties(jsonSchema.asObjectSchema().getProperties());
schema.putPOJO(title, jsonSchema);
types.add(title);
}
ObjectNode choice = objectMapper.createObjectNode();
choice.put("type", "string");
choice.putPOJO("enum", types);
schema.set("choice", choice);
form.addPOJO(objectMapper
.createObjectNode()
.put("type", "fieldset")
.put("title", "Sources")
.set("items",
objectMapper.createArrayNode().add(
objectMapper.createObjectNode().put("type", "selectfieldset").put("key", "choice").put("title", "Choose a source")
.putPOJO("items", types))));
}