microsoft / microsoft/kiota

Enhance polymorphic deserialization to handle multi-level inheritance

Open
#2,432 6 comments 2 reactions 0 assignees View on GitHub
enhancement generator Needs: Triage :mag:
Dominant language
C#
Stars
3.8k
Forks
333
Avg merge
16h 29m
Merged PRs (30d)
116

Description

Currently the deserializer cannot instantiate types that are not direct descendants of the declared return type. Instead it will default to the base type.

This was a performance compromise because in Microsoft Graph all types derive from a base type "entity" and if any operation returned an entity it would be expensive to search the entire tree of types looking for the correct type.

One solution to consider in the future is to create a global mapping table that is aware that Graph has globally unique discriminators so that it can reduce the duplication of mapping tables. We would then move the type mappings for the types into request builders and property deserializers.

Contributor guide

Open the contributing guide

Research direction

Start by locating the deserializer and its type-mapping logic, then review how request builders and property deserializers currently define mappings. Compare the behavior for direct and multi-level descendants, and define completion as correctly instantiating multi-level types without an impractical search across the entire type tree.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.