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
[Bugfix] Detect more schema type reference cycles. (#335)
[Bugfix] Detect more schema type reference cycles.
### Motivation
The newly introduced recursive type support had a slight optimization to minimize the number of boxed types, but it contained a bug that only surfaced on larger real-world documents. It's not really necessary, so removed it and the number of boxed types is still reasonable, plus it doesn't lead to non-compiling code anymore.
### Modifications
Removed an optimization that tried to further reduce the number of boxed types, because it actually missed some cycles and produced non-compiling code for some larger OpenAPI documents.
### Result
Code now compiles even for more complex cycles.
### Test Plan
Added more unit tests, plus tested on some real-world docs with cycles that failed before this change.
Reviewed by: glbrntt
Builds:
✔︎ pull request validation (5.10) - Build finished.
✔︎ pull request validation (5.8) - Build finished.
✔︎ pull request validation (5.9) - Build finished.
✔︎ pull request validation (compatibility test) - Build finished.
✔︎ pull request validation (docc test) - Build finished.
✔︎ pull request validation (integration test) - Build finished.
✔︎ pull request validation (nightly) - Build finished.
✔︎ pull request validation (soundness) - Build finished.
#335
Copy file name to clipboardExpand all lines: Sources/swift-openapi-generator/Documentation.docc/Development/Supporting-recursive-types.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,9 +118,7 @@ The algorithm outputs a list of type names that require boxing.
118
118
119
119
It iterates over the types defined in `#/components/schemas`, in the order defined in the OpenAPI document, and for each type walks all of its references.
120
120
121
-
Once it detects a reference cycle, it checks whether any of the types involved in the current cycle are already in the list, and if so, considers this cycle to already be addressed.
122
-
123
-
If no type in the current cycle is found in the list, it adds the first type in the cycle, in other words the one to which the last reference closed the cycle.
121
+
Once it detects a reference cycle, it adds the first type in the cycle, in other words the one to which the last reference closed the cycle.
0 commit comments