json-schema-validator icon indicating copy to clipboard operation
json-schema-validator copied to clipboard

"Unknown keyword then" / "else" warning

Open Gaff opened this issue 5 years ago • 3 comments

It seems that if I have "then" or "else" in my schema I get a warning when loading the schema:

15:30:49.523 [main] WARN  com.networknt.schema.JsonMetaSchema - Unknown keyword then - you should define your own Meta Schema. If the keyword is irrelevant for validation, just use a NonValidationKeyword

I think this is because ValidatorTypeCode.getNotFormatKeywords only includes if not else or then.

Gaff avatar Oct 13 '20 14:10 Gaff

Could simply fix this by listing "then" and "else" as keywords with the TrueValidator. Happy to do this if you think it would be helpful?

Gaff avatar Oct 13 '20 14:10 Gaff

@Gaff This would be a fantastic idea if it works. What we need to do is to add two more entries into the ValidatorTypeCode. I don't know if it works though as there would be multiple TrueValidator instances in the mapping.

stevehu avatar Oct 13 '20 20:10 stevehu

Some of the PRs fixed part of the issues by adding the keyword to the NonValidationKeyword here at

https://github.com/networknt/json-schema-validator/blob/master/src/main/java/com/networknt/schema/JsonMetaSchema.java#L172

I am wondering if we can add the else using the same way. Could you please try it out and submit a PR if it works?

stevehu avatar Dec 30 '20 14:12 stevehu

Hi, Just fyi, I'm still getting these warnings....

Unknown keyword then - you should define your own Meta Schema. If the keyword is irrelevant for validation, just use a NonValidationKeyword

Unknown keyword else - you should define your own Meta Schema. If the keyword is irrelevant for validation, just use a NonValidationKeyword

jenschiavone avatar Oct 08 '22 19:10 jenschiavone

I think this has been fixed for all versions.

stevehu avatar Apr 30 '23 17:04 stevehu