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
{{ message }}
This repository has been archived by the owner on May 5, 2023. It is now read-only.
This issue highlights the pain our customers have to go through while using the SDK against polymorphic models.
Multiple things need to be done to solve this problem.
The discriminator property should be an Enum that provides intellisense for all the possible values one can provide for.
The documentation/description of the discriminator property needs to document all the possible values. This ensures a decent experience for customers using JS.
We should provide create() methods for all our model interfaces. Customers can use this to create models that satisfy the interface definition. This create method will not expose the discriminator property as it knows the value that should be provided for that property. This is a generic solution that can be applied to all the model types.
I'd like to try using a tagged union for the parameter type and seeing if that helps the tooling experience at all.
In vscode, if you declare types like so:
interfaceFoo{kind: "foo";foo: number;}interfaceBar{kind: "bar";bar: string;}functionsomeFunc(arg: Foo|Bar){}someFunc({kind: "foo",// as soon as you fill out the "kind", you get intellisense for the polymorphic propertiesfoo: 42})
This issue highlights the pain our customers have to go through while using the SDK against polymorphic models.
Multiple things need to be done to solve this problem.
Enum
that provides intellisense for all the possible values one can provide for.create()
methods for all our model interfaces. Customers can use this to create models that satisfy the interface definition. This create method will not expose the discriminator property as it knows the value that should be provided for that property.This is a generic solution that can be applied to all the model types.
Creating a separate interface FooParams with all the properties duplicated from Foo would not make sense.
The text was updated successfully, but these errors were encountered: