fix: preserve schema metadata for nullable anyOf - #2917
Open
mikemikimike wants to merge 2 commits into
Open
Conversation
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
Fixes #1992.
Schema.from_json_schema()dropped the parent schema'sdescriptionandtitlewhen unwrapping a two-part nullable
any_ofschema. This caused schema metadatato be lost for callers using this JSON Schema form.
Changes
descriptionandtitlewhen a nullableany_ofschema is unwrappedinto its non-null type schema.
paths.
Compatibility
This is an internal conversion fix. It does not change the public API surface or
the existing handling of
type,nullable, ordefault.Tests
.venv\\Scripts\\python.exe -m pytest google/genai/tests/types/test_schema_from_json_schema.py -q—10 passed..venv\\Scripts\\python.exe -m pytest google/genai/tests/types -q—181 passed, 6 skipped, 3 warnings..venv\\Scripts\\python.exe -m mypy google/genai/— success for 35 source files..venv\\Scripts\\pyink.exe --pyink --pyink-indentation 2 --line-length 80 --skip-string-normalization --target-version py310 --check --diff google/genai/types.py google/genai/tests/types/test_schema_from_json_schema.py— both files unchanged..venv\\Scripts\\python.exe -m compileall -q google/genai— passed.git diff --check— passed.Not run
google/genai/tests/imports/test_no_optional_imports.pywas invoked but skipped because it only runs on GitHub Actions.Remote verification
googleapis/python-genai:mainfrommikemikimike/python-genai:fix/1992-preserve-schema-metadata.85e9f0391a9d9a5e616c5d4c4abfb25e6e61c781matches the locally verified commit.check-changes, CLA, and conventional-commit checks pass. The zizmor jobs are skipped, and the current merge state is blocked by repository-side conditions or review requirements.