Closed williamdes closed 5 years ago
cc @vearutop
This is interesting, though it seem to work according to JSON Schema spec.
$id
sets base for following $ref
, in this case you have $id
: urn:example:api:response-example
and then you refer to example_item.json
which has to be resolved against urn:...
.
https://json-schema.org/latest/json-schema-core.html#rfc.section.8.3.2:
In all cases, dereferencing a "$ref" reference involves first resolving its value as a URI reference against the current base URI per RFC 3986 [RFC3986].
This does not make sense and falls under RFC 3986 requirements:
When presented with a URI that violates one or more scheme-specific restrictions, the scheme-specific resolution process should flag the reference as an error rather than ignore the unused parts; doing so reduces the number of equivalent URIs and helps detect abuses of the generic syntax, which might indicate that the URI has been constructed to mislead the user (Section 7.6).
Your options to fix the issue:
urn:...
identifiersurn
identifiers, e.g. "$ref":"urn:example:api:example_item"
In case your schema identity does not allow any discovery (urn
) you need to preload your schemas before validation, example.
https://github.com/swaggest/php-json-schema/releases/tag/v0.12.7 broke file resolve process
Test data
stats.json
example_item.json
index.php
See #66
Introduced by #69