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

Warning when validating a schema #79

Closed
rhwood opened this issue Apr 3, 2018 · 14 comments
Closed

Warning when validating a schema #79

rhwood opened this issue Apr 3, 2018 · 14 comments

Comments

@rhwood
Copy link
Contributor

rhwood commented Apr 3, 2018

I am using this library to validate a service's JSON outputs and one of the outputs are the JSON schema (against which everything is validated) themselves.

When validating the schema, I get this warning:

WARN  - Unknown keyword exclusiveMinimum - you should define your own Meta Schema. If the keyword is irrelevant for validation, just use a NonValidationKeyword [main] com.networknt.schema.JsonMetaSchema.newValidator()

The only place I see exclusiveMinimum is in the JSON Schema (Draft 4) itself. What is the best way to avoid this warning, since I am not using it anywhere in my own schemas?

@stevehu
Copy link
Contributor

stevehu commented Apr 4, 2018

@rhwood That warning message can be ignored. We are loading the JSON schema draft v4 for validation and that particular keyword is not supported yet. We are planning to refactor the library to support both v4 and v6 in the near future and this issue will be resolved at the same time. Let's keep this open until it is resolved. Thanks for bringing it up.

@alisrael
Copy link

Has this been resolved yet?

@stevehu
Copy link
Contributor

stevehu commented Feb 11, 2019

@alisrael I just mark the issue with help wanted and hope someone from the community can pick it up and get it resolved. Thanks for bringing it up.

@markgitset
Copy link

markgitset commented Oct 14, 2020

Can the warning be suppressed? (I suppose I could maybe just configure my logger to only show errors from this library, but then I wouldn't see other warnings...)

@stevehu
Copy link
Contributor

stevehu commented Oct 14, 2020

If exclusiveMinimum is the keyword in draft 4 only, we can map this keyword to TrueValidator for v6, v7 and 2019-09. Let's wait for the test result on this issue and make the same change if it works.

#333

@stevehu
Copy link
Contributor

stevehu commented Dec 30, 2020

Since this issue was raised, we have added a lot more NonValidationKeyword to each version of specifications. Here is an example. https://github.com/networknt/json-schema-validator/blob/master/src/main/java/com/networknt/schema/JsonMetaSchema.java#L172

I am wondering if you guys could try it again and add your warned keyword to the list. Just be sure that don't add anything that is a validation keyword but not implemented yet. Thanks.

@bomzheg
Copy link

bomzheg commented Nov 30, 2021

still not fixed?

2021-11-30 18:09:38.189 [main] WARN com.networknt.schema.JsonMetaSchema - Unknown keyword $defs - you should define your own Meta Schema. If the keyword is irrelevant for validation, just use a NonValidationKeyword
2021-11-30 18:09:39.192 [main] WARN com.networknt.schema.JsonMetaSchema - Could not load validator maxLength

@stevehu
Copy link
Contributor

stevehu commented Dec 2, 2021

@bomzheg I think people are fixing the issue in a particular version they are using. That is why you might still see this. Which version are you using?

@ionutalex88
Copy link
Contributor

@stevehu could we have the "else" keyword also added to the NonValidationKeywork list for V2019, or V2020, just like it was done for "then" in https://github.com/networknt/json-schema-validator/pull/418/files ?
Currently there is no version on which none of the "if", "then", "else" keywords trigger the warning message.

@stevehu
Copy link
Contributor

stevehu commented Jul 16, 2022

@ionutalex88 Yes. I think we can do it safely. Would you like to open a PR?

@ionutalex88
Copy link
Contributor

@ionutalex88 Yes. I think we can do it safely. Would you like to open a PR?

@stevehu I could do that. Should I be added to the contributors list?

@stevehu
Copy link
Contributor

stevehu commented Jul 18, 2022

@ionutalex88 I have sent you an invite to grant you the write permission. Please create a branch for your PR. Thanks.

@tomasbjerre
Copy link

I would expect there to be some way to, given SchemaValidatorsConfig or JsonSchema, add a keyword.

I have a custom keyword in my schema that I use in a JsonSchemaWalkListener:

   @Override
   public WalkFlow onWalkStart(WalkEvent walkEvent)
   {
      JsonNode schemaNode = walkEvent.getSchemaNode();
      JsonNode kindNode = schemaNode.get("MY_CUSTOM_KEYWORD");
      do stuff with kindNode....

It works totally fine (great job with this library!) but I keep getting this warn-logging.

@fdutton
Copy link
Contributor

fdutton commented May 23, 2023

@stevehu resolved the original issue regarding exclusiveMinimum with a commit on 2019-11-14.
@ionutalex88 added then and else in #592
@sh883193@dal.ca Added $defs in #539

@tomasbjerre We have many open requests to support custom keywords. Please add your requirements to one of those or open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants