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

Example from specification fails with NPE #12

Open
olegshtch opened this issue Oct 14, 2021 · 4 comments
Open

Example from specification fails with NPE #12

olegshtch opened this issue Oct 14, 2021 · 4 comments

Comments

@olegshtch
Copy link
Contributor

olegshtch commented Oct 14, 2021

I've prepared test suite based on https://json-schema.org/draft/2020-12/json-schema-core.html#recursive-example in json-schema-org/JSON-Schema-Test-Suite#521

Currently it fails with NullPointerException:

java.lang.NullPointerException
	at net.jimblackler.jsonschemafriend.Validator.validate(Validator.java:95)
	at net.jimblackler.jsonschemafriend.Validator.validate(Validator.java:179)
	at net.jimblackler.jsonschemafriend.Validator.validate(Validator.java:76)
	at net.jimblackler.jsonschemafriend.Validator.validate(Validator.java:412)
	at net.jimblackler.jsonschemafriend.Validator.validate(Validator.java:76)
	at net.jimblackler.jsonschemafriend.Validator.validate(Validator.java:505)
	at net.jimblackler.jsonschemafriend.Validator.validate(Validator.java:156)
	at net.jimblackler.jsonschemafriend.Validator.validate(Validator.java:71)
	at net.jimblackler.jsonschemafriend.SuiteTest.lambda$scan$1(SuiteTest.java:100)
@jimblackler
Copy link
Owner

jimblackler commented Oct 14, 2021

I tested it this way and it worked:

{
  "$defs": {
    "tree": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://example.com/tree",
      "$dynamicAnchor": "node",
      "type": "object",
      "properties": {
        "data": true,
        "children": {
          "type": "array",
          "items": {
            "$dynamicRef": "#node"
          }
        }
      }
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/strict-tree",
  "$dynamicAnchor": "node",
  "$ref": "tree",
  "unevaluatedProperties": false
}
{
    "children": [ { "daat": 1 } ]
}

But I will attempt to patch your test locally and see what happens.

@olegshtch
Copy link
Contributor Author

Maybe it doesn't work because tree schema in other file.

@jimblackler
Copy link
Owner

Step one is to not NPE if $dynamicAnchor doesn't resolve, which is obviously bad. c2d871f

It doesn't fix your test case though so I'll look more into that.

@jimblackler
Copy link
Owner

OK the issue is the port spec in the URL http://localhost:1234/strict-tree.json. The library was mishandling those. e5d884a contains fixes for this specific test case (although it's possible there are more).

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

2 participants