oxidecomputer / typify

compiler from JSON Schema into idiomatic Rust types
Apache License 2.0
401 stars 57 forks source link

Add setting for permissive pattern properties reducing to map #636

Closed novafacing closed 1 month ago

novafacing commented 1 month ago

I added a setting permissive_pattern_properties in both the library and CLI which allows setting objects with patternProperties as discussed in #635 to generate as maps (previously, they silently generated as empty structs).

This is a toggle instead of a default because it will result in a translated specification which accepts object keys which violate the pattern. I didn't explore adding a way to validate keys with deserialize_with but this may be desired as a future improvement to this.

BTW, tested the generated code after this change and it's able to parse the C++ tree-sitter grammar.json now!

novafacing commented 1 month ago

Closing this PR in favor of a proper implementation which does the pattern validation.