-
Notifications
You must be signed in to change notification settings - Fork 192
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
feat: two-way type references #684
Changes from 3 commits
d253a1d
c5daa46
5d77aed
8f35b37
6119e97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1541,10 +1541,12 @@ export class Type implements IType { | |
// Track the "parent" reference for this type from the property reference | ||
propType.parentTypes.add(this.name) | ||
if ( | ||
propType.instanceOf('ArrayType') && | ||
propType.elementType?.instanceOf('EnumType') | ||
propType.instanceOf('ArrayType') || | ||
propType.instanceOf('HashType') | ||
) { | ||
propType.elementType.parentTypes.add(propType.name) | ||
propType.elementType?.parentTypes.add(propType.name) | ||
propType.elementType?.parentTypes.add(this.name) | ||
Comment on lines
+1547
to
+1548
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we want both I don't know which of these two lines puts in Caveat: not super up to speed on the actual details/usage of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good point and would only require some additional validation in sdkModels.ts. I'm unsure whether we should do that or not though, I'll have to defer to @jkaster There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't answer completely. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess my more basic question is what what is a "type" in the context here.
If that's correct (i.e. type/parentTypes is mean to represent a collection of IType) then what is an On the other hand, maybe types/parentTypes is not a loose reference to IType but rather meant to be the union of IType and IType[]? But, as you say it's primarily for APIX which promptly discards the IType[] type by calling Or maybe I'm just up too early and my brain isn't on :-) happy to hash out in person later There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I thought that might be the question. They must be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not doing a good job expressing my question/concern: it's not about the implementation of the typescript type or javascript runtime implementation of I'm thinking of an ERD - a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I see
Housing those under the same property feels like saying "one of my parents is named Tom, and I have another parent whose name is 'Tom's kids'" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree it gets muddy. What do you suggest instead? We definitely need to link child types of a collection to the user of said collection. For visual representation in APIX, this works. Can we create a ticket to work out this design and address it in another PR, because I've already thought about this and haven't come up with anything clearly better yet, and for the purpose of APIX type ref navigation this works. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't totally understand what this means w/out seeing concrete code but I'll take your word for it: carry on :-) |
||
propType.parentTypes.add(this.name) | ||
} | ||
this.types.add(propType.name) | ||
const customType = propType.customType | ||
|
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.
maybe add a test for "parent of hash types" since your fix in sdkModels is
(or conversely remove the
|| HashType
condition)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.
We have no complex hash types in the model right now, so we need to create a sample spec for that.
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 didn't add a test for this because unfortunately we do not have any typed
HashType
in the spec. All parameters of typeIDictionary
expect a scalar property value. I added the check because I expect it to work when we do, but perhaps I should remove it so that when we do need it, we'll remember to add a testThere 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.
we've modified
test/openApiRef.json
in the past to add spec schema that we don't already have in Looker: 1b64e1b#diff-90f6053ccc4c15adb9cbbba6833dbfb5a6206c6fb3793fe206f10f71230b73faR29331So yeah, I'd say either remove the check (perhaps adding a TODO) or add the test
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.
added the test