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
{{ message }}
Repository navigation
Resolver relies on getPrimaryResourceIdentifier() being unique for each schema #11
Resolver relies e.g. in registerSchema on getPrimaryResourceIdentifier being unique for each schema however when Validator::validate is called without the third argument, the getPrimaryResourceIdentifier() returns empty string every time.
My guess is that we must either make the 3rd parameter of Validator::validate required or generate primary resource identifier differently (maybe random?) when empty Uri is passed.
Unless a $ref pointing to another document is encountered, we never leave the current schema, so it's expected to get always the same identifier (here the empty string) and the same schema from the cache. If an external $ref is met, the identifier returned by getPrimaryResourceIdentifier()must be different. Isn't this the case? Can you provide a schema illustrating the issue?
I guess you're right. The registerSchema behavior is wrong (relying on uniqueness of primary resource identifier even when it's empty string), but resolve does never actually read those schemas with empty identifier so it never actually breaks anything.
Therefore the best solution would likely be to just ignore empty identifiers in registerSchema as caching them is both wrong and pointless.
The registerSchema behavior is wrong (relying on uniqueness of primary resource identifier even when it's empty string)
I don't agree. The empty string is also a valid identifier. It's unique and will always denote the document from which we started, in case no path/url was provided.
It's unique and will always denote the document from which we started
When you call validate with schema A without URL and then validate with schema B without URL, references such as {"$ref": "#"} in schema B would resolve against schema A.
You're right, and actually even for #6, the schema should probably be taken from $stack and not $schemas, so we can safely exclude the empty string as you suggested.
Activity
JanTvrdik commentedon Apr 10, 2016
Maybe we can just put sth like this to
Validator::validatestefk commentedon Apr 10, 2016
Unless a $ref pointing to another document is encountered, we never leave the current schema, so it's expected to get always the same identifier (here the empty string) and the same schema from the cache. If an external $ref is met, the identifier returned by
getPrimaryResourceIdentifier()must be different. Isn't this the case? Can you provide a schema illustrating the issue?JanTvrdik commentedon Apr 10, 2016
I guess you're right. The
registerSchemabehavior is wrong (relying on uniqueness of primary resource identifier even when it's empty string), butresolvedoes never actually read those schemas with empty identifier so it never actually breaks anything.Therefore the best solution would likely be to just ignore empty identifiers in
registerSchemaas caching them is both wrong and pointless.Ignore empty primary resource identifier in Resolve::registerSchema
stefk commentedon Apr 10, 2016
I don't agree. The empty string is also a valid identifier. It's unique and will always denote the document from which we started, in case no path/url was provided.
It will when a solution will be provided for #6.
JanTvrdik commentedon Apr 10, 2016
The collision with #6 is a good observation.
When you call validate with schema A without URL and then validate with schema B without URL, references such as
{"$ref": "#"}in schema B would resolve against schema A.stefk commentedon Apr 10, 2016
You're right, and actually even for #6, the schema should probably be taken from
$stackand not$schemas, so we can safely exclude the empty string as you suggested.JanTvrdik commentedon Apr 10, 2016
What about implementing check in
registerSchemato prevent accidental overrides