json-schema-org / json-schema-spec

The JSON Schema specification

Home Page:http://json-schema.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Confusing behavior of `$id`

EmilyGraceSeville7cf opened this issue · comments

Given this JSON schema in VS Code:

{
    "$id": "http://emily.json",
    "$schema": "http://json-schema.org/draft-07/schema",
    "type": "object",
    "properties": {
        "first": {
            "$id": "#a",
            "type": "boolean"
        },
        "second": {
            "$ref": "http://emily.json#a"
        }
    }
}

and this test file:

first: true

I obtain: Problems loading reference 'http://emily.json/#a': Unable to load schema from 'http://emily.json/': Request vscode/content failed unexpectedly without providing any details. error. While executing jsonschema-cli validate schema.json test.yaml works fine. Is it a VS Code YAML Red Hat extension bug, or I am missing something?

I'd call that a bug.
If you go file an issue, please reference this issue so we can see it easily? =]

If you go file an issue, please reference this issue so we can see it easily? =]

Sure. :)

Feel free to suggest they add their implementation to BowTie: https://bowtie-json-schema.readthedocs.io/en/latest/implementers/

Or, if you have the time, feel free to try yourself =D

The results in case anyone's curious, for Bowtie's currently supported implementations:

⊙  bowtie validate $(find $DEVELOPMENT/bowtie/implementations -maxdepth 1 -mindepth 1 | sed 's/.*implementations\//-i /') <(printf '                                                                                                                                             julian@Postmac ●
{
    "$id": "http://emily.json",
    "$schema": "http://json-schema.org/draft-07/schema",
    "type": "object",
    "properties": {
        "first": {
            "$id": "#a",
            "type": "boolean"
        },
        "second": {
            "$ref": "http://emily.json#a"
        }
    }
}
') <(printf '{"first": true}') 2>/dev/null | bowtie summary
                                                                                                                                              Bowtie                                                                                                                                              
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Schema                                                 ┃                                                                                                                                                                                                                                       ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ {                                                      │                                                                                                                                                                                                                                       │
│   "$id": "http://emily.json",                          │   Instance          JsonSchema.Net (dotnet)   jsonschema (go)   ajv (javascript)   hyperjump-jsv (javascript)   jschon (python)   jsonschema (python)   boon (rust)   jsonschema (rust)   vscode-json-language-service (typescript)   │
│   "$schema": "http://json-schema.org/draft-07/schema", │  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  │
│   "type": "object",                                    │   {"first": true}   error                     valid             error              valid                        error             valid                 valid         valid               invalid                                     │
│   "properties": {                                      │                                                                                                                                                                                                                                       │
│     "first": {                                         │                                                                                                                                                                                                                                       │
│       "$id": "#a",                                     │                                                                                                                                                                                                                                       │
│       "type": "boolean"                                │                                                                                                                                                                                                                                       │
│     },                                                 │                                                                                                                                                                                                                                       │
│     "second": {                                        │                                                                                                                                                                                                                                       │
│       "$ref": "http://emily.json#a"                    │                                                                                                                                                                                                                                       │
│     }                                                  │                                                                                                                                                                                                                                       │
│   }                                                    │                                                                                                                                                                                                                                       │
│ }                                                      │                                                                                                                                                                                                                                       │
└────────────────────────────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

(So most implementations do indeed have the correct behavior here).

But closing as it sounds like this indeed was moved to the right spot downstream -- obviously if anyone disagrees pipe up.