All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mercateo.jsonschema.schema.mapper.ArrayJsonPropertyMapper.kt Maven / Gradle / Ivy

There is a newer version: 0.2.0
Show newest version
package com.mercateo.jsonschema.schema.mapper

import com.fasterxml.jackson.databind.node.JsonNodeFactory
import com.fasterxml.jackson.databind.node.ObjectNode
import com.mercateo.jsonschema.mapper.SchemaPropertyMapper
import com.mercateo.jsonschema.schema.ObjectContext

internal class ArrayJsonPropertyMapper(
        private val schemaPropertyMapper: SchemaPropertyMapper,
        private val nodeFactory: JsonNodeFactory
) : JsonPropertyMapper {

    override fun toJson(property: ObjectContext<*>): ObjectNode {
        val propertyNode = ObjectNode(nodeFactory)
        propertyNode.put("type", "array")
        propertyNode.set("items", schemaPropertyMapper.toJson(ObjectContext(property.property.children[0])));
        /*jsonProperty.sizeConstraints.min?.let { propertyNode.put("minItems", it) }
        jsonProperty.sizeConstraints.max?.let { propertyNode.put("maxItems", it) }*/
        return propertyNode;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy