-
Notifications
You must be signed in to change notification settings - Fork 222
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
adds support for type discriminator during deserialization #1174
Conversation
521e342
to
a31206c
Compare
This comment was marked as outdated.
This comment was marked as outdated.
44aeb12
to
d828141
Compare
Can you elaborate on |
@nikithauc I'm still working with @darrelmiller to understand how much this is a requirement. But the gist of it is that interfaces for models would be in a sub namespace like so
Of course the infrastructure I'm laying out would leave that as a choice for each language (whether or not we have interfaces in this language and where they are placed). |
From conversation with Vincent, decision is that we put interfaces and classes all in the same models folders. |
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
e7e2ef5
to
52f73e9
Compare
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
@andrueastman this is ready for review, thanks for your help during the design time I'm aiming to merge this this in by Friday so we can start testing that in Go/Dotnet/TS previews as the newer conversion lib releases. |
TS does not append an |
If we fix the problem with circular dependency, will we still need the new CreateDiscriminator classes right? |
Co-authored-by: Jason Johnston <jasonjoh@users.noreply.github.com>
This PR still adds most of the infrastructure needed for that change, the only missing piece would be to create the interfaces into a different namespace/package. (which I reverted after my convo with Darrel)
They are functions but yes, this part would still be needed after models classes inheritance is broken up and interfaces are introduced (like Go). |
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.
👍🏼 On the reorganization of the CodeDOM
Otherwise just a few comments from me.
Kudos, SonarCloud Quality Gate passed! |
Summary
fixes #648
What I thought would be a rather short PR ended up being much larger than anticipated. The background story is that because of the type system in Go, I add to introduce interfaces generation support in Kiota CodeDOM. Which led to a whole bunch of refactoring so we don't have to duplicate things like import statements, refiners logic, writing methods prototypes etc...
Because of the TypeScript limitations on static methods, I also had to introduce global functions and do a bunch of refactoring.
This PR is adding new capabilities to the Kiota engine, which is overall a good thing for Kiota to support additional scenarios and languages. Apologies to the reviewers, this is going to be large.
To illustrate what this does, let's take the example of /groups/id/members which returns a collection of directory objects. User, Service Principal, Group and many other types derive from directory object. Before this change, everything was deserialized to a directory object, and the additional properties available on derived types (like userPrincipalName for user) would end up in the additional data manager.
After that change, and once the conversion lib releases, the SDK will use the newly introduced factories for each model types to read in the odata.type (contains values like
#microsoft.graph.user
) property and instantiate the derived type when possible. Making pattern matching possible in the client code and access to derived types properties easier.Generation diff
microsoft/kiota-samples#513
using this description (see outlook item)
microsoftgraph/msgraph-sdk-powershell#1060
Global todo
CSharp todo
Go todo
Java todo
TypeScript todo