Open ahl opened 1 year ago
Oh wow, I completely forgot about this issue because I was wrapping up some other work. Now, that I have more time, I am getting back into this project(s).
The original files are in ATD format and the JSON schema is generated from them. So, some of the issues might have been from the conversion.
Again, thanks. This was very enlightening.
Howdy; the initial failure you encountered with typify happens due to this construction:
Note that there's a property of the
join-content
object calledadditionalProperties
whose schema isfalse
. This effectively says "there's an optional field calledadditionalProperties
whose type has no valid value". Typify could render this as something like the never (!
) type, but it doesn't.After that, the schema contains many constructions like this:
And typify doesn't handle those currently (0.0.12).
It could, for example, ignore those constraints as the hand-written structs do here:
https://github.com/parsiya/yaml-wrangling-with-rust/blob/main/07-artisanal-structs/src/semgrep_rules.rs#L95-L109
Typify could simply ignore the constraints as well, however the guiding principle for typify is to represent types as precisely as possible; in this case we'd like to emit something like:
Indeed, it's a bit strange that this wasn't modeled as a
oneOf
, but JSON schema invites all kinds of strange constructions... which makes code generation hard!