Fix recursive tool input schema by hoisting $defs to root#6035
Conversation
Signed-off-by: jewoodev <jewoos15@naver.com>
|
Hi @danielvolovik96 and @jeanchristophecascade — apologies for going ahead without a check-in first. The issue had been quiet for ~18 days and I drafted this to keep it moving, but I want to be explicit: if either of you would prefer to lead the implementation, I'm happy to close this PR, hand the branch over, or co-author — just say the word. Same goes if maintainers prefer a different approach. The diff covers the transitive |
|
Thanks for addressing this issue @jewoodev ! |
Add hoistDefsToRoot into JsonSchemaUtils so both JsonSchemaGenerator and McpJsonSchemaGenerator share the implementation. Handles equal-definition reuse, name collisions with suffix renaming, peer-ref rewriting, and correct $defs-before-properties ordering. Add tests for both generators. Signed-off-by: jewoodev <jewoos15@naver.com> Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com> Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com>
|
Rebased, clean the code and duplications, squashed and merged at 0f9c2a5 |
…jects#6035) Add hoistDefsToRoot into JsonSchemaUtils so both JsonSchemaGenerator and McpJsonSchemaGenerator share the implementation. Handles equal-definition reuse, name collisions with suffix renaming, peer-ref rewriting, and correct $defs-before-properties ordering. Add tests for both generators. Signed-off-by: jewoodev <jewoos15@naver.com> Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com> Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com> Signed-off-by: R3gardless <pidaoh@g.skku.edu>
|
Many thanks to both of you 😊 |
|
Thank you @tzolov for the careful review, cleanup, and merge. I really appreciate the refinements you made to the implementation. I learned from them and will keep that direction in mind for future contributions. |
…jects#6035) Add hoistDefsToRoot into JsonSchemaUtils so both JsonSchemaGenerator and McpJsonSchemaGenerator share the implementation. Handles equal-definition reuse, name collisions with suffix renaming, peer-ref rewriting, and correct $defs-before-properties ordering. Add tests for both generators. Signed-off-by: jewoodev <jewoos15@naver.com> Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com> Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com> Signed-off-by: psilberk <psilberkasten@gmail.com>
Summary
Fixes #5888.
Why: Spring AI currently inlines parameter schemas under
properties.<param>, but their generated$refs still point to root-level$defs.Fix: Move each parameter schema's
$defsto the wrapper schema root before inlining the parameter. Reuse structurally equal definitions; rename conflicting simple names and rewrite refs within the hoisted schema.Tests
Added regression coverage in both generators for:
Scope
This PR covers the transitive
$defsfailure reported in #5888 for bothJsonSchemaGeneratorandMcpJsonSchemaGenerator. Direct self-recursive$ref: "#"handling is outside this PR.