eclipsesource/play-json-schema-validator

support for other draft versions

Closed this issue · 5 comments

Hi,

Would there will be support for other draft versions ?
Maybe at least the last one, 7 ?

Thanks,

Hi,
so far there were no plans to update as we still use v4, but I'll look into it.

Sorry, this took a while, but we've released a first milestone version 0.9.5-M1 with support for v7. Could you give it a try a let me know whether you encounter any issues?
Note that in contrast to to v4, v7 support does not resolve external references automatically any more (as described here). You can either add all schemas via addSchema or override the default option:

import com.eclipsesource.schema.drafts.Version7
// add geo schema to known schemas
val validator = SchemaValidator(Some(Version7))
        .addSchema("http://json-schema.org/geo", geoSchema)

Alternatively, override default option supportsExternalReferences:

val options = new SchemaConfigOptions  {
  // override option
  override def supportsExternalReferences: Boolean = true
  override def formats: Map[String, SchemaFormat] = DefaultFormats.formats
}
val validator = SchemaValidator(Some(Version7(options)))

Another remark about the usage: the SchemaValidator now takes a optional Version argument as you see, which determines the version to be used. If it is omitted the version will be determined via the $schema keyword in the schema if applicable, otherwise it falls back to using v7.

Note that this API is not yet finalized and support for v7 specific formats has not been implemented yet, but we'd be happy about any feedback or issues you might have.

v7 is supported since 0.9.5-M1.

Hi,

Sorry, I completely forgot about my request.
Thanks a lot for implementation.
I hope to have some free time in the following weeks in order to test it.

Thanks

Sure, no worries, if you find any issues, let me know.