-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenAPI 3.1: visitors after the dereference visitor don't get mutated elements #3520
Comments
The root issue is that we're mutating parent and subsequent visitors have no idea about this change. This is a regression introduced by integrating ApiDOM Dereference Architecture 2.0. We have couple of options how to resolve this:
Decision: we will go for option 4. It requires the least amount of effort to fix the issue, it requires minimal repeated traversal of the same nodes and is aligned of how ApiDOM traversal was original design to be performed. |
…ting them in OpenAPI 3.1 Refs #3520
I've researched standardized approach to the problem we currently have - it's called
Babel is using automatic requeueing as it has an abstraction facilitated via Our traversal mechanism is more generic and not bound to particular structure (it handles parser CSTs, ASTs and ApiDOM). It was originally build as immutable, but for dereferencing we needed to utilize mutations. Every time the mutation is introduced that significantly modifies the ApiDOM tree (e.g. replacing current node), we need to manually dispatch For solving this issue we technically didn't need complex requeuing mechanism. ApiDOM traversal natively supported immutable current node replacement. In swagger-api/apidom#4120 we added support for mutable current node replacement - this is all that we currently need. Upstream ApiDOM issue swagger-api/apidom#4120 |
…for OpenAPI 3.1.0 (#3521) Refs #3520 --------- Co-authored-by: Vladimir Gorej <[email protected]>
Addressed in 2eb34c9 |
Content & configuration
Swagger/OpenAPI definition:
Describe the bug you're encountering
The
allOf
properties are not merged into the parent schema if the schema was referenced. The dereferenced schema in the response will still have theallOf
keyword:while the schema itself will be merged:
The issue here is that the parent elements get mutated by the
DereferenceVisitor
:swagger-js/src/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js
Lines 776 to 780 in fa77bfd
and the subsequent visitors do not see this change.
We get the correct result if instead of merging the
AllOfVisitor
with theDereferenceVisitor
and visiting here:swagger-js/src/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js
Lines 107 to 118 in fa77bfd
we did a second merge and visit with only the
AllOfVisitor
on the dereferenced element:because we get updated elements.
Expected behavior
The updated elements need to be passed to the visitors after dereferencing, as this issue will affect all of them.
The text was updated successfully, but these errors were encountered: