Search in sources :

Example 1 with JsonSerializableSchema

use of com.fasterxml.jackson.databind.jsonschema.JsonSerializableSchema in project jackson-databind by FasterXML.

the class BeanSerializerBase method getSchema.

@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException {
    ObjectNode o = createSchemaNode("object", true);
    // [JACKSON-813]: Add optional JSON Schema id attribute, if found
    // NOTE: not optimal, does NOT go through AnnotationIntrospector etc:
    JsonSerializableSchema ann = _handledType.getAnnotation(JsonSerializableSchema.class);
    if (ann != null) {
        String id = ann.id();
        if (id != null && id.length() > 0) {
            o.put("id", id);
        }
    }
    //todo: should the classname go in the title?
    //o.put("title", _className);
    ObjectNode propertiesNode = o.objectNode();
    final PropertyFilter filter;
    if (_propertyFilterId != null) {
        filter = findPropertyFilter(provider, _propertyFilterId, null);
    } else {
        filter = null;
    }
    for (int i = 0; i < _props.length; i++) {
        BeanPropertyWriter prop = _props[i];
        if (filter == null) {
            prop.depositSchemaProperty(propertiesNode, provider);
        } else {
            filter.depositSchemaProperty(prop, propertiesNode, provider);
        }
    }
    o.set("properties", propertiesNode);
    return o;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonSerializableSchema(com.fasterxml.jackson.databind.jsonschema.JsonSerializableSchema)

Aggregations

JsonSerializableSchema (com.fasterxml.jackson.databind.jsonschema.JsonSerializableSchema)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1