oxidecomputer / typify

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

improvements to schema merge logic #575

Closed ahl closed 4 months ago

ahl commented 4 months ago

This fixes a couple of bugs. The first (#573) is pretty simple: when we merge schemas that contain both subschemas and other stuff, we drop all metadata; we should preserve the outer schema metadata for title and description in particular.

The next is that convert_schema_object calls merge_with_subschemas and expects it not to fail... but it can fail! In particular it will fail if the result of the merged schema is unsatisfiable (i.e. there is no value that would validate against the schema). In such a situation we now handle the error and produce a "never" schema (enum with no variants).

Closes #573, #572