You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like $ref schemas are not useable when schema validation is enabled. The following schema is valid, but is only useable to validate documents if schema validation is disabled:
The problem seems to be that when validated with :validate_schema, the schema is first validated. Then, the cache is cleared, which has a side-effect of removing the schema for #/definitions/test as well has the schemas for schema itself. Then, when you validate a document against it the $ref fails to resolve.
One easy workaround for this (but not necessarily the right fix) would be to turn schema caching on before validating:
JSON::Validator.cache_schemas = true
This causes the cache to be retained between validating the schema and the data, so the $ref URI resolves. But since this is probably the desired behavior whenever doing a schema validation plus a validation against the schema, it's probably better to implicitly set @@cache_schemas = true when schema validation is requested.
The text was updated successfully, but these errors were encountered:
It occurs to me that another approach may be to retain the current caching behavior, but to selectively purge the cache of the "schema schemas"; i.e. the ones used to validate the schema itself, after validating the schema.
This should be fixed in 2.1.9. Clearing of the schema cache will become a validation option, which will explicitly be set to false for schema validation. The old cache_schemas= method will be deprecated and removed in a future version.
It looks like $ref schemas are not useable when schema validation is enabled. The following schema is valid, but is only useable to validate documents if schema validation is disabled:
The problem seems to be that when validated with :validate_schema, the schema is first validated. Then, the cache is cleared, which has a side-effect of removing the schema for #/definitions/test as well has the schemas for schema itself. Then, when you validate a document against it the $ref fails to resolve.
One easy workaround for this (but not necessarily the right fix) would be to turn schema caching on before validating:
This causes the cache to be retained between validating the schema and the data, so the $ref URI resolves. But since this is probably the desired behavior whenever doing a schema validation plus a validation against the schema, it's probably better to implicitly set
@@cache_schemas = true
when schema validation is requested.The text was updated successfully, but these errors were encountered: