Emma Sajic created OLINGO-1611:
----------------------------------
Summary: Instance annotations on entity property are not present
in the response when serializing it using OdataSerializer.primitive()
Key: OLINGO-1611
URL: https://issues.apache.org/jira/browse/OLINGO-1611
Project: Olingo
Issue Type: Bug
Components: odata4-server
Affects Versions: (Java) V4 4.10.0
Reporter: Emma Sajic
Attachments: PrimitivePropertyWithInstanceAnnotation.patch
When the user requests a single Entity Property in JSON format from the Olingo
OData v4 service as specified in [10.13 Property
Value|https://docs.oasis-open.org/odata/odata/v4.01/os/part1-protocol/odata-v4.01-os-part1-protocol.html#_Toc31358923]
that request is handled by an implementation of
[PrimitiveValueProcessor.readPrimitiveValue|https://github.com/apache/olingo-odata4/blob/21ee56917f900a816b1dbae4d3683d5b84b00f67/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/PrimitiveValueProcessor.java]
In my implementation of readPrimitiveValue, when the user requests a single
Entity Property (which is not a raw value ($value) or a Edm.Stream) I am using
[OdataSerializer.primitive|https://github.com/apache/olingo-odata4/blob/21ee56917f900a816b1dbae4d3683d5b84b00f67/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java#L88-L96]
to serialize the Property into response content.
[Instance
annotations|https://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#sec_InstanceAnnotations]
on the Property are not being included in the JSON response from the service -
but I think they should be.
Example requests / responses showing the problem:
{code:java}
REQUEST ENTIRE ENTITY - FULL METADATA
curl --location 'http://localhost:8080/OData.svc/MyAddresses(1)' --header
'Accept: application/json;odata.metadata=full;charset=UTF-8'
Response Content-Type: application/json;odata.metadata=full;charset=UTF-8
{
"@odata.context": "$metadata#MyAddresses/$entity",
"@odata.type": "#com.sap.apm.MyAddress",
"@odata.id": "MyAddresses(AddressNo=1)",
"[email protected]": "#Int64",
"AddressNo": 1,
"[email protected]": "Mailing",
"AdrType": "M"
}
REQUEST ENTITY PROPERTY - FULL METADATA
curl --location 'http://localhost:8080/OData.svc/MyAddresses(1)/AdrType'
--header 'Accept: application/json;odata.metadata=full;charset=UTF-8'
Response Content-Type: application/json;odata.metadata=full;charset=UTF-8
ACTUAL RESPONSE SHOWING BUG
{
"@odata.context": "../$metadata#MyAddresses(1)/AdrType",
"value": "M"
}
EXPECTED RESPONSE - INSTANCE ANNOTATION INCLUDED
{
"@odata.context": "../$metadata#MyAddresses(1)/AdrType",
"[email protected]": "Mailing",
"value": "M"
}
REQUEST ENTIRE ENTITY - MINIMAL METADATA
curl --location 'http://localhost:8080/OData.svc/MyAddresses(1)'
Response Content-Type: application/json;odata.metadata=minimal;charset=UTF-8
{
"@odata.context": "$metadata#MyAddresses/$entity",
"AddressNo": 1,
"[email protected]": "Mailing",
"AdrType": "M"
}
REQUEST ENTITY PROPERTY - MINIMAL METADATA
curl --location 'http://localhost:8080/OData.svc/MyAddresses(1)/AdrType'
Response Content-Type: application/json;odata.metadata=minimal;charset=UTF-8
ACTUAL RESPONSE SHOWING BUG
{
"@odata.context": "../$metadata#MyAddresses(1)/AdrType",
"value": "M"
}
EXPECTED RESPONSE - INSTANCE ANNOTATION INCLUDED
{
"@odata.context": "../$metadata#MyAddresses(1)/AdrType",
"[email protected]": "Mailing",
"value": "M"
}{code}
I've attached a patch to [ODataSerializerTest in the 4.10.0 Olingo
release|https://github.com/apache/olingo-odata4/blob/7b8f05659e2654570ae9c09b2aa52238083ea02a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java#L1751]
which reproduces the problem.
[^PrimitivePropertyWithInstanceAnnotation.patch]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)