Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle allOf by merging schemas #405

Merged
merged 13 commits into from
Sep 23, 2023
Merged

handle allOf by merging schemas #405

merged 13 commits into from
Sep 23, 2023

Conversation

ahl
Copy link
Collaborator

@ahl ahl commented Sep 23, 2023

Before this PR, the handling of allOf was basically wrong. It worked in a small number of cases, but on the whole it was flawed in concept. Most of the time, it would result in a struct with all subschemas embedded with a #[serde(flatten)] directive. This was broken in many ways, but in particular because allOf constructs are often used to augment, narrow, and expand other types.

This PR instead "merges" the subschemas of an allOf construction. This results in many more types, but also (per our testing), types that compile and are usable which was often not the case previously.

This implements much of what is discussed in #176, but doesn't include the impl From that issue imagines to go from the "merged" type to the component type (i.e. the type that appeared in the allOf array).

Fixes #315 and #370


In addition, there are several cleanups: adding env_logger to cargo-typify, improved logs and docs, start of a schema validator for Values, etc.

@ahl ahl merged commit ffd99b7 into main Sep 23, 2023
4 checks passed
@ahl ahl deleted the merge-types branch September 23, 2023 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic during anyOf usage
1 participant