You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to parse schema definition with anyOf/allOf within one another #868
I believe the problem has to do with the deferred way in which model schemas are resolved.
The parser processes the schemas section in two passes. In the first pass, it creates an object (like ModelProperty) corresponding to each schema, and builds an index of their names, but doesn't fully try to fill in the details as it goes— since those may depend on references to other schemas that it hasn't seen yet. In the second pass, it revisits the things that it hasn't filled in yet (in the current implementation, it only does this for object types, i.e. ModelProperty).
What's happening here, I think, is that the logic for building a union type (anyOf) incorrectly expects that everything can be resolved in the first pass. When it looks at the types in the anyOf list, it expects them to all be in their fully-filled-in state, but they're not.
The reason it works for an equivalent schema in paths is that the parser doesn't try to process anything in paths until it has already done both passes on schemas.
Activity
eli-bl commentedon Sep 19, 2024
I believe the problem has to do with the deferred way in which model schemas are resolved.
The parser processes the
schemassection in two passes. In the first pass, it creates an object (like ModelProperty) corresponding to each schema, and builds an index of their names, but doesn't fully try to fill in the details as it goes— since those may depend on references to other schemas that it hasn't seen yet. In the second pass, it revisits the things that it hasn't filled in yet (in the current implementation, it only does this for object types, i.e. ModelProperty).What's happening here, I think, is that the logic for building a union type (anyOf) incorrectly expects that everything can be resolved in the first pass. When it looks at the types in the anyOf list, it expects them to all be in their fully-filled-in state, but they're not.
The reason it works for an equivalent schema in
pathsis that the parser doesn't try to process anything inpathsuntil it has already done both passes onschemas.