Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema version no longer validated since version 1.0.83 #829

Closed
alexruf opened this issue Jun 20, 2023 · 4 comments · Fixed by #980
Closed

Schema version no longer validated since version 1.0.83 #829

alexruf opened this issue Jun 20, 2023 · 4 comments · Fixed by #980

Comments

@alexruf
Copy link

alexruf commented Jun 20, 2023

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.

@fdutton
Copy link
Contributor

fdutton commented Jun 20, 2023

@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.

@alexruf
Copy link
Author

alexruf commented Jun 20, 2023

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.

@fdutton
Copy link
Contributor

fdutton commented Jun 20, 2023

Let me see what I can do.

@alexruf
Copy link
Author

alexruf commented Jun 20, 2023

Let me see what I can do.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants