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

Support $refs with implicit url base #5

Open
tyilo opened this issue Aug 6, 2021 · 5 comments
Open

Support $refs with implicit url base #5

tyilo opened this issue Aug 6, 2021 · 5 comments

Comments

@tyilo
Copy link

tyilo commented Aug 6, 2021

When loading the following schema I get a warning:

Aug 06, 2021 12:31:26 PM net.jimblackler.jsonschemafriend.Schema <init>
WARNING: No match for #/$defs/reference
{
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "$id": "urn:defs-test",
  "title": "TEST",
  "type": "object",
  "properties": {
    "testReference": {
      "$ref": "#/$defs/reference",
    }
  },
  "$defs": {
    "reference": {
      "type": "string"
    }
  }
}
@tyilo
Copy link
Author

tyilo commented Aug 6, 2021

Hmm, actually the problem seems to be that #/$defs/reference is not mapped to urn:defs-test#/$defs/reference

@tyilo tyilo changed the title Support $defs Support $refs with implicit url base Aug 6, 2021
@jimblackler
Copy link
Owner

Thanks for the report and apologies for the delay investigating. There's been a problem with the scheme 'urn'. It seems it doesn't play nice with the constructor for java.net.URI, which I use throughout. I pushed enough to fix the precise issue above (thanks for the test case) but will need to do more digging to make sure it works throughout.

jimblackler pushed a commit that referenced this issue Sep 25, 2021
@olegshtch
Copy link
Contributor

When I use urn: with $dynamicRef/$dynamicAnchor I get same error.

@jimblackler
Copy link
Owner

Sorry to read that; could you confirm that you are using 0.11.2.

If you are, could you paste an example of a failed case here? You can check it in advance on https://tryjsonschematypes.appspot.com/#validate

@olegshtch
Copy link
Contributor

I got java.lang.IllegalStateException: java.net.URISyntaxException: Expected scheme-specific part at index 4: urn:

for

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"$id": "urn:java:common.proto.Message",
	"title": "Message itself",
	"type": "object",
	"properties": {
		"head": {
			"type": "object"
		},
		"body": {
			"$dynamicRef": "#body"
		}
	},
	"required": ["head", "body"],
	"additionalProperties": false,
	"$defs": {
	    "body": {
	        "$dynamicAnchor": "body",
	        "type": "object"
	    }
	}
}

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