-
Notifications
You must be signed in to change notification settings - Fork 43
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
WIP: Detect recursive type unrolling #2134
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2134 +/- ##
==========================================
+ Coverage 60.64% 62.52% +1.88%
==========================================
Files 350 355 +5
Lines 45793 38677 -7116
==========================================
- Hits 27770 24183 -3587
+ Misses 16491 12909 -3582
- Partials 1532 1585 +53 ☔ View full report in Codecov by Sentry. |
// | ||
// Suppose ancestor(T1, T2) if T2 describes a sub-property of T1. | ||
// | ||
// Suppose T1 <= T2 if T1 has the subset of properties of T2 with types that are themselves Tx <= Ty. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work really well for the AWS WAFv2 example at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really exited about this. I'd love to see what the diff looks like for a couple of our smaller providers (does it detect recursion, and if so do we agree).
return "", false | ||
} | ||
cleanRef := strings.TrimPrefix(rawRef, "#/types/") | ||
return tokens.Type(cleanRef), true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason not to validate here?
return tokens.Type(cleanRef), true | |
typ, err := tokens.ParseTypeToken(cleanRef) | |
contract.AssertNoErrorf(err, "invalid schema") | |
return typ, true |
return best | ||
} | ||
|
||
func findGenericTypeReferences(x any) (typeRefs, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like this could be implemented via type_visitor.go
and it would be much easer to reason about.
No description provided.