OData / OData/AspNetCoreOData

Enable dynamic complex property without @odata.type

Open
#885 0 comments 0 reactions 1 assignee View on GitHub

@xuzhg is already working on this.

Since Apr 11, 2023.

feature investigating
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

Assemblies affected
Which assemblies and versions are known to be affected e.g. ASP.NET Core OData 8.x

Reproduce steps

Consider the following json request payload, the type of 'condition' is an open type, and it accepts dynamic properties.

where, StringEqualsIgnoreCase is dynamic complex type property

{
   "condition": {
         "StringEqualsIgnoreCase": {
               "awsTag":[
                         "finance",
                          "hr",
                         "legal"
                    ]
                },
                "key1": "value1",
                 "key2": [
                   "value2",
                   "value3"
                ],
                "key3": "value4"
       }
}

The above payload can't pass deserialization because there's no type for
a) StringEqualsIgnoreCase
b) awsTag
C) key2

We have to let customer provide types as below, then it can work.

{
  "condition": {
    "StringEqualsIgnoreCase": {
        "@odata.type":"microsoft.graph.awsCondition",
        "awsTag@odata.type":"Collection(Edm.String)",
        "awsTag":[
            "finance",
            "hr",
            "legal"
        ]
      },
      "key1": "value1",
      "key2@odata.type": "Collection(Edm.String)",
      "key2": [
          "value2",
          "value3"
      ],
      "key3": "value4"
    }
}

Expected behavior
Actually, we don't need customers to provide the types since they are dynamic properties.

Additional context
We can deserialize 'StringEqualsIgnoreCase' as an instance of 'ODataObject', where 'ODataObject' can be defined as:

public class ODataObject: Dictionary<string, object>
{}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.