Validation issue
elect86 opened this issue · comments
Is there an existing issue for this?
- I have searched the existing issues
Schema and json here
Validation passes with online validator
import io.github.optimumcode.json.schema.JsonSchema
import io.github.optimumcode.json.schema.ValidationError
import io.github.optimumcode.json.schema.fromStream
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonElement
import java.io.File
fun main() {
val schema = JsonSchema.fromStream(File("/home/elect/Downloads/SCHEMA.json").inputStream())
val errors = mutableListOf<ValidationError>()
val elementToValidate: JsonElement = Json.parseToJsonElement(File("/home/elect/Downloads/DATASETS.json").readText())
println(schema.validate(elementToValidate, errors::add))
errors.forEach { println(it) }
false
ValidationError(schemaPath=/type, objectPath=, message=element is not a object, details={}, absoluteLocation=null)
Library version
0.0.9
Hi, @elect86. Thank you for raising this issue.
I looked at the dataset.json and schema.json you attached and cannot reproduce the problem locally. However, I have noticed that in your problem description, you have DATASETS.json file but in the attached github gist file is called dataset.json. My assumption is that your file contains the dataset objects list, which is why you have this error.
Could you please check the content of the DATASETS.json file you tried to validate?
Sorry for the stupid mistake, you are right
My bad
No worries, was happy to help)