fix: Proper handling of clashing types case#109
fix: Proper handling of clashing types case#109candiduslynx wants to merge 8 commits intoinvopop:mainfrom
Conversation
Closes #14027 Blocked by: * cloudquery/codegen#39 * invopop/jsonschema#109 – merged to `cloudquery/jsonschema@cqmain` * invopop/jsonschema#110 – merged to `cloudquery/jsonschema@cqmain` I propose reviewing the annotations along with tests, as the JSON schemas generated are just too long to grasp visually.
09ed1ca to
54cbbaf
Compare
e987e0a to
f11a450
Compare
22c1413 to
d62ac43
Compare
d62ac43 to
ca3c866
Compare
| return false | ||
| } | ||
|
|
||
| return a.AssignableTo(b) && b.AssignableTo(a) |
There was a problem hiding this comment.
this is required for shadowing case, see TestShadowedClashingTypes
|
@samlown I hope you're doing well in these uneasy days. I've implemented the changes in #109 & #110 & tested them via a fork at The results of using the updated code along with Could you please give an estimate when these PRs (#109 & #110) could be merged? It'll be far easier to pin an upstream version instead of maintaining a fork for these 2 changes. |
Closes cloudquery#14027 Blocked by: * cloudquery/codegen#39 * invopop/jsonschema#109 – merged to `cloudquery/jsonschema@cqmain` * invopop/jsonschema#110 – merged to `cloudquery/jsonschema@cqmain` I propose reviewing the annotations along with tests, as the JSON schemas generated are just too long to grasp visually.
|
Hi @samlown! |
|
@samlown I'm closing this PR for 2 reasons:
If you'll be available for review & merging please tag me here & I'll reopen from my own fork. |
Instead of #107
This PR aims to properly reference situations when different types (either shadowed ones or originating different packages, but having the same name) are referenced incorrectly (specifically, only the 1st entry is properly handled, other encounters of the same type name blindly reference the 1st definition, even if the types aren't the same).
To achieve this, the following changes were made:
_typefield was added tojsonschema.Schemastructjsonschema.Schema.Definitionsmap, originalreflect.Typevalue is stored in_typefieldnameoriginally suggested (either inferred from type name, or fromjsonschema.Reflector.Namerresult), the code will try to locate a proper entry by adding-idx(e.g.,-1,-2, etc.) suffix to thenamevalue