wolverdude / GenSON

GenSON is a powerful, user-friendly JSON Schema generator built in Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

final "required" should not be present

xgodon opened this issue · comments

the draft-07 does not accept the final "required" in
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "hi": { "type": [ "integer", "string" ] } }, "required": [ "hi" ] }

validators :
https://www.jsonschemavalidator.net/
https://jsonschemalint.com/#/version/draft-07/markup/json

i asked the json-schema team to confirm

I don't see what the issue is. That schema validates under Drafts 4, 6, and 7 (provided the value of "$schema" is changed accordingly).

i couldn't validate this schemas on 3 validators under draft 7.
so that means that either

  • the validator is not correctly implemented
  • the generator is not correctly implemented

or 3rd possibility i don't understand something

I think you may be using the validators incorrectly. The test suite for GenSON includes validation for every schema generated, so if it were generating invalid schemas, the tests would fail.

Here's a screenshot of me using https://jsonschemalint.com/#/version/draft-07/markup/json to validate the same schema you posted:

validation screen shot

Hopefully that helps!

yeah i get that, but with the first validator, and the python lib i use (https://github.com/Julian/jsonschema), it doesn't validate.
is their implementation not ok?

That is precisely the same library we use to validate schemas in testing. You can see how we use it here. Just replace Draft4Validator with Draft6Validator or Draft7Validator depending on what kind of schema you want to validate.

thanks

I'm assuming you figured it out. Use builder.to_schema(), not builder.to_json() which produces a JSON string, and a string is not a valid schema.

You found me out :D