Repository navigation
Keep referenced body fields when a request body schema adds sibling properties - #5440
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1220d5e4e7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| has_ref_with_properties = "$ref" in body_schema and isinstance( | ||
| body_schema.get("properties"), dict | ||
| ) |
There was a problem hiding this comment.
Convert references inside sibling properties
When a sibling property itself references another component, _replace_ref_with_defs() converts the top-level $ref and skips traversing its sibling properties; this new branch then promotes that untouched #/components/schemas/Child pointer while the emitted schema contains definitions only under $defs. The default dereference middleware cannot resolve that pointer and returns the schema unchanged, so OpenAPI 3.1 tools using nested sibling references advertise a dangling input-schema reference. Normalize the sibling property schemas before removing the top-level $ref.
AGENTS.md reference: AGENTS.md:L184-L186
Useful? React with 👍 / 👎.
| # Handle allOf at the top level by merging all schemas. A $ref that | ||
| # sits beside its own properties is merged the same way, with the | ||
| # sibling properties taking precedence over the referenced ones. |
There was a problem hiding this comment.
Preserve conjunction for overlapping referenced properties
In OpenAPI 3.1, keywords adjacent to $ref apply in addition to the referenced schema; they do not override it. For example, a referenced name: string plus sibling name: integer is unsatisfiable, but this merge advertises name as an integer and sends a value the upstream schema must reject. Preserve both constraints, such as by composing colliding property schemas, rather than assigning precedence to the sibling.
AGENTS.md reference: AGENTS.md:L180-L182
Useful? React with 👍 / 👎.
…to overlapping fields Co-authored-by: Claude <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 97f6dc7294
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # Remove the allOf since we've merged it | ||
| # Remove the allOf and $ref since we've merged them | ||
| body_schema.pop("allOf", None) | ||
| body_schema.pop("$ref", None) |
There was a problem hiding this comment.
Preserve discriminators from referenced body schemas
When an OpenAPI 3.1 request body adds sibling properties to a $ref whose target carries a discriminator, this merge copies only the target's properties and required fields before removing the reference. Consequently, _flatten_discriminator_subtypes() never sees the referenced discriminator, so mapped subtype fields such as meowVolume disappear from the MCP tool schema and cannot be forwarded by the request director. Carry the referenced discriminator into body_schema, or flatten the resolved target before dropping the reference.
AGENTS.md reference: AGENTS.md:L184-L186
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 66f9358b31
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # Remove the allOf since we've merged it | ||
| # Remove the allOf and $ref since we've merged them | ||
| body_schema.pop("allOf", None) | ||
| body_schema.pop("$ref", None) |
There was a problem hiding this comment.
Keep
$ref when allOf was not fully merged
When an OpenAPI 3.1 request body contains both a top-level $ref and allOf, and the referenced schema has no object properties—for example, a referenced string refined with minLength—has_all_of enters this block, but the merger copies only properties and required. Removing both $ref and allOf then leaves the whole-body argument without the referenced type or constraints, whereas the previous code retained the $ref; only discard the reference after the complete referenced schema has been preserved.
AGENTS.md reference: AGENTS.md:L184-L186
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 380df5e1da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| and schema.get("type", "object") == "object" | ||
| and "enum" not in schema | ||
| and "const" not in schema |
There was a problem hiding this comment.
Preserve composed constraints before dropping the reference
Although the earlier primitive/allOf case is now guarded, this helper still classifies a referenced type: object containing oneOf or anyOf as losslessly mergeable. For a body such as $ref: Base plus sibling properties, where Base requires variant-specific fields through oneOf, the merge copies only top-level properties/required and then removes the reference; the variant fields are absent from both the tool schema and parameter map, so no conforming payload can be forwarded. Treat unmerged composition keywords as non-mergeable or preserve/flatten their complete constraints before removing $ref.
AGENTS.md reference: AGENTS.md:L184-L186
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0af5694cb5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| merged_props.update(sub_schema["properties"]) | ||
| for prop_name, prop_schema in sub_schema.get("properties", {}).items(): | ||
| if ( | ||
| not has_all_of |
There was a problem hiding this comment.
Preserve overlap conjunction when
allOf is present
When a $ref body also has any top-level allOf, this condition disables composition for every overlapping property, including overlaps between the referenced schema and sibling properties. For example, a referenced name: string plus sibling name: integer and an annotation-only allOf: [{"description": "..."}] emits only the integer schema instead of the unsatisfiable conjunction, so the tool accepts a request the upstream schema rejects. Fresh evidence in this revision is the new not has_all_of guard, which bypasses the earlier overlap fix whenever this otherwise unrelated keyword is present; compose differing property schemas regardless of whether the body also contains allOf.
AGENTS.md reference: AGENTS.md:L180-L182
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Declining this one. It needs a body that combines a top-level $ref, sibling properties that contradict the referenced schema, and an allOf on the same object. The allOf path keeps its existing last-wins property merging, which an existing test documents. Overlaps between the referenced schema and sibling properties are composed whenever no allOf is present, which covers the realistic case.
A request body schema written as a
$refwith siblingproperties(valid in OpenAPI 3.1) now exposes the referenced schema's properties andrequiredfields together with the sibling properties, and sends all of them in the request body. When both define the same property name, the two schemas are combined withallOf. The merge applies only when the referenced schema is a plain object it can represent fully (including a discriminator with its mapped subtypes); any other target keeps the$refand is exposed as a singlebodyargument. Bodies that are a plain$refare unchanged.