fix(yaml_model): robust anyOf/oneOf handling in schema comments#732
Open
scottstanie wants to merge 1 commit into
Open
fix(yaml_model): robust anyOf/oneOf handling in schema comments#732scottstanie wants to merge 1 commit into
scottstanie wants to merge 1 commit into
Conversation
The YAML comment generator read `d["type"]` for every entry under a schema's `anyOf`, which raises KeyError when an entry has no `type` key (e.g. a `$ref` to a nested model, or a discriminated union). It also ignored `oneOf` entirely. Handle both `anyOf` and `oneOf`, and fall back gracefully for entries without a `type` key instead of crashing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
YamlModel's comment generator crashes on some valid config schemas.anyOf, it readd["type"], which raisesKeyErrorwhen an entry has notypekey -- e.g. a$refto a nested model,or a discriminated union member.
oneOfentirely (produced by discriminated unions).Change
anyOfandoneOf.typekey instead of raising.This lets
to_yaml()run on configs that use nested-model unions / discriminatedunions.
🤖 Generated with Claude Code