schemars doesn't properly handle definitions that aren't at the top-level (there's no proper field), however, unsupported data like those are still stored as pure JSON values inside the extensions field.
This PR uses this field to properly handle nested definitions, by manually deserializing the JSON value obtained on-the-fly to a JSON schema. This requires sprinkling some Cow instead of pure references to make rustc happy while still borrowing data as much as possible (avoiding useless clones).
Interestingly, this approach can be extended for other JSON schema keywords that aren't currently supported by schemars.
schemars doesn't properly handle definitions that aren't at the top-level (there's no proper field), however, unsupported data like those are still stored as pure JSON values inside the
extensions
field.This PR uses this field to properly handle nested definitions, by manually deserializing the JSON value obtained on-the-fly to a JSON schema. This requires sprinkling some
Cow
instead of pure references to make rustc happy while still borrowing data as much as possible (avoiding useless clones).Interestingly, this approach can be extended for other JSON schema keywords that aren't currently supported by schemars.