Repository navigation
Conversation
springdoc emits each subtype as a required list next to an allOf of the parent schema and the subtype's own fields. After $ref resolution the queryPointInTimeMetrics comparison schema therefore lists required fields that are not in that object's properties, which Gemini/Vertex AI reject. Fold plain object allOf branches into one object (union of properties and required) while resolving. Branches with other keywords, or that define a property differently, are left as they are. Fixes cortexapps#13
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.
Fixes #13.
springdoc emits each subtype as
{"required": [...], "allOf": [<parent>, {<own fields>}]}. Afterresolve_refsinlines the parent, thecomparisonschema ofqueryPointInTimeMetricsends up withrequired: [alias, name, ordinal, windowSize]on an object that has nopropertiesof its own, which is what Gemini/Vertex AI rejects in the issue.This merges a plain allOf of object schemas into the schema that holds it while resolving: properties and required are unioned, so the constraints are the same, just on one object. It only does this when every branch is a plain object (type/properties/required/description/title/discriminator) and the branches agree on any property they both define (apart from description/title); otherwise the allOf is left alone. The base class's discriminator is dropped from the merged subtype, since there is no oneOf left for it to apply to.
Against the bundled swagger.json,
queryPointInTimeMetricsis the only MCP tool whose input schema changes. I built the server withcreate_mcp_server()and checked the schemas fromtools/list: before,comparison.anyOf[0]is{allOf, required, type}with the required names only inside the allOf; after, it is one object withrequired: [alias, name, ordinal, type, windowSize]and all of those inproperties, and no tool input schema has a required name missing from its own properties. I haven't run it against Gemini itself.Tests: added a test for the springdoc subtype shape and one for conflicting branches staying as allOf, and updated
test_resolve_polymorphic_refs, which asserted the old allOf shape.pytest(40 passed),ruff check,black --checkon the resolver, and mypy on the resolver are clean.