-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Handle enum-like oneOf
s
#3385
Comments
@cgardens
Related #3961 |
Agreed. @jamakase would it be possible for us to move forward with "Possible Solution 2" in such a way that is backwards compatible with what we have now? basically I agree with Sherif's proposal on sequencing. Want to make sure the UI work is done in such a way that it is possible. |
@sherifnada do you think there is any sort of static checking we could do at build time? i agree with the convention you want to go for. wondering how we will make this obvious to new engineers and contributors. maybe we just document it? 🤷♀️ |
we can:
|
Tell us about the problem you're trying to solve
For some connector configurations occasionally we have cases where based on a configuration choice a user may (or may not need to enter more information.
e.g. if a user if choosing between file_source type in the file source, they might choose between public web, local fs, and gcp. In the public web and local fs case, simply selecting public web or local fs is enough. No extra info is required in the gcp case the user must also provide a service account.
We use a bit of a hack right now to model this:
The issue is that with oneOf we can't have multiple "types" that match the same pattern. So public web and local fs can't just be empty objects. The way we handle this is by adding a
storage
field to each object in the oneOf and then having the field be an enum with one value. This passes validation because the enums do not overlap, so different objects cannot get mistaken as each other. When interacting with the object that matches this schema, we are okay because thestorage
field is essentially an enum.The downside of this hack is that in the UI a user is presented with a dropdown for the
storage
field that has only one item in it. It implies there's a choice being made here, but there is none, so it is just confusing.Describe the solution you’d like
Describe the alternative you’ve considered or used
Possible Solution 1
We could have the UI recognize when the enum for a field has only one value. In those cases it could make sure that the dropdown for that value is not editable.
Possible Solution 2
We could stop using the enum hack for this and instead use the jsonschema constants (keyword
const
). The UI would know not to displayconst
fields and would by default set the value for that field to the value of theconst
.Possible Solution ?
┆Issue is synchronized with this Asana task by Unito
The text was updated successfully, but these errors were encountered: