React-jsonschema-form: $ref doesn't support url

Created on 13 Nov 2019  路  4Comments  路  Source: rjsf-team/react-jsonschema-form

Here is a valid schema:

{
"title": "A registration form",
"description": "A simple form example.",
"type": "object",
"required": [
"address"
],
"properties": {
"address": {
"$ref": "https://api.myjson.com/bins/3bkzl.json#/definitions/address"
}
}
}

It throws exception when dereference $ref.

enhancement help wanted

Most helpful comment

馃憤 +1 for URL $ref

All 4 comments

Not sure if we should implement this... could you look through the JSON Schema spec (https://json-schema.org/) and see what it might have to say about $ref's with a HTTPS url?

The specification is very explicit in saying on section 8.3 that:

The "$ref" keyword is used to reference a schema, and provides the
ability to validate recursive structures through self-reference.

An object schema with a "$ref" property MUST be interpreted as a
"$ref" reference. The value of the "$ref" property MUST be a URI
Reference. Resolved against the current URI base, it identifies the
URI of a schema to use. All other properties in a "$ref" object MUST
be ignored.

The URI is not a network locator, only an identifier. A schema need
not be downloadable from the address if it is a network-addressable
URL, and implementations SHOULD NOT assume they should perform a
network operation when they encounter a network-addressable URI.

On the latest draft, this section is here.

Nevertheless, I would also like to see this feature supported being it out-of-the-box or by allowing its users to provide their own URL resolver implementation.

I like the idea of users being able to choose between several given $ref resolver implementations (JSON pointer, URL, or a combination of multiple ones), and also provide their own custom $ref resolver implementation if they want.

馃憤 +1 for URL $ref

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mfulton26 picture mfulton26  路  3Comments

anttivikman picture anttivikman  路  3Comments

pablen picture pablen  路  3Comments

ClockerZadq picture ClockerZadq  路  3Comments

jabaren picture jabaren  路  3Comments