Schema version no longer validated since version 1.0.83
I noticed that sice the release of version 1.0.83 the behaviour changed, and wrong schema versions do no longer throw an exception.
With version 1.0.82 the following Kotlin example code would have thrown a JsonSchemaException because the schema version doesn't match:
val schemaNode = jacksonObjectMapper().readTree("{\"\$schema\": \"http://json-schema.org/draft-06/schema\", \"properties\": { \"id\": {\"type\": \"number\"}}}")
val factory = com.networknt.schema.JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012)
val schema = factory.getSchema(schemaNode) // since 1.0.83 this will no longer throw 'JsonSchemaException' because of wrong schema version
Now, since version 1.0.83 this is no longer the case and regardless what version flag is specified, all schema versions are accepted.
@alexruf This is intentional (#778) and exists to support Cross-draft validation. This allows a schema written against a newer version to reference a schema written against an older version.
OK, but since this is a breaking change, is there a way to get back the old behaviour?
Since we want to enforce a specific schema version, we were relying on the fact that if the JsonSchemaFactory is initialized with a specific VersionFlag, that this is causing a validation error if the schema doesn't match that version.
Maybe I am misunderstanding something, but for me, the new behaviour doesn't make much sense.
Let me see what I can do.
Let me see what I can do.
Thanks!