eclipse-basyx / basyx-java-server-sdk

MIT License
60 stars 47 forks source link

[BUG] SubmodelElementRepository: Integer Value For Property Can't Be Used For Patching #403

Open geso02 opened 3 months ago

geso02 commented 3 months ago

Describe the bug

My submodel repository contains a submodel with one property. I now try to patch the property using the value-only representation. The property representation could be a number, string or boolean value according to the OpenApi-Definition. The property value is of type integer, so I expect that I could post an integer value, but only posting a string value works.

To Reproduce Steps to reproduce the behavior:

  1. Set up a submodel repository.
  2. Post the submodel:
    curl -X POST http://localhost:8081/submodels -H "Content-Type: application/json" -v -d '{
    "modelType": "Submodel",
    "kind": "Instance",
    "id": "http://sm.twinficient.de/TechnicalData/heater-definition/Optima_Plus_40",
    "idShort": "TechnicalData-heater-definition/Optima_Plus_40",
    "submodelElements": [{
            "modelType": "Property",
            "value": "12",
            "valueType": "xs:integer",
            "idShort": "prop"
        }
    ]
    }'
  3. Perform a patch:
    curl -X PATCH http://localhost:8081/submodels/aHR0cDovL3NtLnR3aW5maWNpZW50LmRlL1RlY2huaWNhbERhdGEvaGVhdGVyLWRlZmluaXRpb24vT3B0aW1hX1BsdXNfNDA=/submodel-elements/prop/\$value \
    -H "Content-Type: application/json" \
    -d '18'
  4. Status Code is 500, so check out the error on server-side:
    org.eclipse.digitaltwin.basyx.deserialization.exception.SubmodelElementValueDeserializationException: The provided SubmodelElementValue JSON is not as defined in the Dot AAS Part 2
    at org.eclipse.digitaltwin.basyx.deserialization.factory.SubmodelElementValueDeserializationFactory.create(SubmodelElementValueDeserializationFactory.java:99) ~[basyx.submodelservice-core-2.0.0-milestone-03.1.jar!/:2.0.0-milestone-03.1]
    at org.eclipse.digitaltwin.basyx.deserialization.SubmodelElementValueJsonDeserializer.deserialize(SubmodelElementValueJsonDeserializer.java:56) ~[basyx.submodelservice-core-2.0.0-milestone-03.1.jar!/:2.0.0-milestone-03.1]
    at org.eclipse.digitaltwin.basyx.deserialization.SubmodelElementValueJsonDeserializer.deserialize(SubmodelElementValueJsonDeserializer.java:46) ~[basyx.submodelservice-core-2.0.0-milestone-03.1.jar!/:2.0.0-milestone-03.1]
    at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342) ~[jackson-databind-2.17.2.jar!/:2.17.2]

    Expected behavior

Should work for integer as it does for string (Jackson deserialization problem)

BaSyx (please complete the following information):

System (please complete the following information):

aaronzi commented 3 months ago

Thank you for reporting this. This seems like a duplicate of #384 but we will check this again to verify