# Fix Gemini schema conversion dropping anyOf and nullability \(\#57160\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/8dff89c8d145deea1149af91f6414b869c5c2ef6)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 8dff89c8d145deea1149af91f6414b869c5c2ef6

Requested commit: 8dff89c8d145deea1149af91f6414b869c5c2ef6

Commit: 8dff89c8d145deea1149af91f6414b869c5c2ef6

Tree: dbc2d905c02da94ec16f842d9bfbc31fb43b0db7

Author: Richard Feldman

Committer: GitHub

## Message

```
Fix Gemini schema conversion dropping anyOf and nullability (#57160)

Follow-up to #49292:

- **Bug fix in `push_any_of_constraint`**: when both an `anyOf` and a
non-empty `allOf` were already present at the same level, the existing
`anyOf` was silently dropped. Now it's always preserved.
- **Canonical OpenAPI nullability**: collapse `{nullable: true}`-only
entries out of `anyOf` onto the parent so `anyOf: [{type: "string"},
{type: "null"}]` becomes `{type: "string", nullable: true}` (the form
Gemini actually expects) instead of `anyOf: [{type: "string"},
{nullable: true}]`.
- **Compile-time path consistency**: route `ToJsonSchemaSubsetTransform`
through the same `convert_null_in_types_to_nullable` helper so
Rust-defined tools using `Option<T>` also keep nullability on Gemini,
instead of silently truncating to the non-null type.
- Drop an unnecessary clone in `push_any_of_constraint` and simplify
`convert_types_to_any_of_defs`.
- Add a small `obj()` test helper and a regression test for the `anyOf +
allOf + multi-type` case.

Release Notes:

- Fixed `Option<T>` tool parameters being sent to Gemini without their
nullability, and fixed tool schemas with `anyOf` + `allOf` losing
constraints during the OpenAPI 3.0 conversion

Co-authored-by: Daniel Strobusch <1438302+dastrobu@users.noreply.github.com>
```

## Parents

- [a0aa3e842f9ca65d7679a2aced0b2214dcf765c4](https://git.cafe/gitcafe/zed/commit/a0aa3e842f9ca65d7679a2aced0b2214dcf765c4?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/8dff89c8d145deea1149af91f6414b869c5c2ef6?format=markdown)
