Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local file ref failure #110

Closed
ldemailly opened this issue Aug 28, 2023 · 4 comments
Closed

local file ref failure #110

ldemailly opened this issue Aug 28, 2023 · 4 comments

Comments

@ldemailly
Copy link

repro:

go install github.com/atombender/go-jsonschema/cmd/gojsonschema@latest

(btw consider fixing it so the github.com/omissis/go-jsonschema path works)

in ids.json

{
  "id": {
    "enum": [
       "a",
       "b"
    ]
  }
}

in schema.json

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Bug",
  "type": "array",
  "uniqueItems": true,
  "items": {
    "type": "object",
    "properties": {
      "idref": {
        "$ref": "file://./ids.json#/id"
      }
    }
  }
}

then

$ gojsonschema -p main schema.json 
go-jsonschema: Failed: could not generate type for field "idref": unsupported $ref format; must point to definition within file: "file://./ids.json#/id"
@samherrmann
Copy link

I'm not sure if file://./ids.json#/id is actually a valid reference. VSCode's validator also complains about that reference. But I can confirm that go-jsonschema also doesn't work with ./ids.json#/id and ids.json#/id while VSCode is happy with either of those.

@ldemailly
Copy link
Author

We use https://github.com/neilpa/yajsv/ which takes that syntax fine, happy to change to whichever works for that tool and would work (better) with go-jsonschema

@omissis
Copy link
Owner

omissis commented Oct 4, 2023

Hi! I have started the work here: #147
In the next few days I will also add @ldemailly 's example to the test suite and see to make it work.
Thanks!

@omissis
Copy link
Owner

omissis commented Nov 8, 2023

I merged the issue #147 , which should solve the problem. The feature will become available in the upcoming v0.15.0 release, in the meantime it can be tested by building from main. closing.

@omissis omissis closed this as completed Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants