Skip to content
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

WebApi v7 doesn't support property Instance annotation without property value #2844

Closed
vasrinwork opened this issue Jun 20, 2024 · 0 comments · Fixed by #2845
Closed

WebApi v7 doesn't support property Instance annotation without property value #2844

vasrinwork opened this issue Jun 20, 2024 · 0 comments · Fixed by #2845

Comments

@vasrinwork
Copy link

vasrinwork commented Jun 20, 2024

WebApi v7 doesn't support property instance annotations when the property value is not present.

Assemblies affected

OData WebApi v7

Reproduce steps

Considering this payload, where references is an OpenComplexTypeObject. When this payload is passed, we expect the webapi library to identify the key "https://a/task@task.task" as a property instance annotation.
However, the v7 library is missing this feature and returns nothing for the property Instance Annotations.

{
    "details", new JObject
    {
        {
            "references", new JObject
            {
                {
                    "https://a/task@task.task", new JObject
                    {
                        { "@odata.type", "microsoft.taskServices.externalReference" },
                        { "alias", "abcd"},
                        { "type", "Other" },
                    }
                }
            }
        },
    }
}

Expected result

We expect the request to fail with a BadRequest like it did in v6.
(or)
When a prefer header is sent with the request,

request.Headers.Add("Prefer", "odata.include-annotations=*");

The InstanceAnnotations in the ODataResourceWrapper of the ODataResourceDeserializer, should populate the InstanceAnnotations for the property.

Actual result

ODataResourceWrapper.ResourceBase.Properties.InstanceAnnotations.Count = 0 for the property "references"
and the request passes with the response showing
"details": null

Additional detail

In WebApi lib v6, the ODataResourceDeserializer considered references as a complex property and threw an error like:
ODataJsonLightPropertyAndValueDeserializer_ComplexValuePropertyAnnotationWithoutProperty
However, in v7, references is considered as a resource. The deserializer is not sure how to map the annotation as the property value is missing.
I was informed that V8 has a fix for this. So, porting that to v7 would be a quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant