keleshev / schema

Schema validation just got Pythonic
MIT License
2.87k stars 214 forks source link

JSON Schema: Add description next to $ref #230

Closed dblanchette closed 4 years ago

dblanchette commented 4 years ago

Starting with draft-04, the JSON schema specification allows having other attributes next to $ref. This is useful for us when using descriptions, because we may want to use a different description depending on where the sub schema is used.

Descriptions from Literal used as keys were already added to the value it references. With this change, descriptions will be added alongside the $ref node if the value is another schema and that schema has as_reference set to True.

For an example, look at test_json_schema_definitions_and_literals.

skorokithakis commented 4 years ago

This looks good, thanks!