Repository navigation
Conversation
resolve_refs copied a polymorphic parent's fields into every subtype, even inside that parent's own oneOf/anyOf, where they already apply. Drop the copy there; a subtype reached any other way keeps it. Co-Authored-By: Claude Fable 5.2 <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.
TL;DR:
resolve_refsinlines every$ref, and for the parent/subtype cycles springdoc emits it copies the parent's fields into every subtype, even when the subtype sits in that parent's ownoneOf/anyOf, where those fields already apply. This drops the copy in that position only. Against the current Cortex API spec,createOrUpdateWorkflow's definition goes from 13,967 to 10,327 tokens (−26%) and the whole tool listing from 63,950 to 59,151 (−7.5%), and the schemas accept and reject the same inputs.Linear: COR2-1443
Detail, written by Claude
Problem
A polymorphic type reaches the resolver as a cycle: the parent lists its subtypes in
oneOf, and each subtype isallOf: [{$ref: parent}, {own fields}]. #14 cut that cycle by re-expanding the parent once, without its subtypes, inside each subtype.That is right when a subtype is referenced on its own. Inside the parent's list it is repetition: the workflow action parent carries a 17-value
typeenum, so the enum appears 18 times in one tool definition, and the 12 user-input field types repeat their parent the same way.Change
When a subtype is expanded as a direct member of a schema's
oneOf/anyOf, theallOfentry that refers back to that same schema is left out. If that was the only entry,allOfgoes too.Everything else is unchanged:
allOfentries, including a second parent, are kept.Numbers
Tokens are tiktoken
o200k_baseover the compact JSON oftools/list, built with this repo's route mapper and customizer.createOrUpdateWorkflowcreatePluginupdatePluginpatchPluginrunWorkflowNo other tool's definition changes. None of the 28 tools built from the
swagger.jsonbundled in this repo changes either, because it has no polymorphic request bodies.Why the schemas are equivalent
The parent's own keywords still apply to the schema that holds the list, so a branch that restated them added no constraint. Two checks back that up:
oneOf/anyOf/discriminator.Two limits on that claim, neither present in the spec today:
unevaluatedProperties: falsewould start rejecting the parent's properties, since they are no longer evaluated inside the branch.Not verified
propertiesandrequiredbeside the list, which is standard JSON Schema but worth knowing for clients that flattenanyOf.pytest42 passed,ruff check src testsclean).Left out
Each affected branch now has a one-entry
allOfthat could be merged into the branch for a further saving. That needs a key-merge rule, so it is not in this PR.🤖 Generated with Claude Code