com.mercateo.jsonschema.schema.mapper.ArrayJsonPropertyMapper.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json-schema Show documentation
Show all versions of json-schema Show documentation
json-schema generator for the JVM.
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;
}
}