basyx-python-sdk icon indicating copy to clipboard operation
basyx-python-sdk copied to clipboard

server: implementation of modifier `?level=core` is incorrect

Open hpoeche opened this issue 2 months ago • 0 comments

Current Situation

The server maps ?level=core to the SDK's AASToJsonEncoder.stripped flag (is_stripped_request() in server/app/interfaces/base.py). However, the "stripped" encoder does not implement Level=Core as specified by IDTA-01002.

Concretely, stripped=True (sdk/basyx/aas/adapter/json/json_serialization.py):

  • Omits submodelElements (Submodel), value (SubmodelElementCollection/SubmodelElementList), statements (Entity), annotations (AnnotatedRelationshipElement) at the requested resource itself (depth 0), e.g. in _submodel_to_json: https://github.com/eclipse-basyx/basyx-python-sdk/blob/5754d62e09f7cfdc993205534d06240e5746a076/sdk/basyx/aas/adapter/json/json_serialization.py#L409-L410

  • Also removes extensions, embeddedDataSpecifications, qualifiers unconditionally, at every depth.

  • Is applied uniformly regardless of the requested resource's type.

Example: GET /submodels/{id}?level=core today returns the Submodel with no submodelElements at all.

Expected Behavior

The API spec defines children of an element as follows:

Children in this sense are SubmodelElements which are contained at the ‘submodelElements’ field of Submodels, the ‘value’ field of SubmodelElementCollections or SubmodelElementLists, the ‘statements’ field of Entities, or the ‘annotations’ field of AnnotatedRelationshipElements.

The serialization with modifier ?level=core is then defined as:

Only elements of a requested hierarchy level as well as direct children are returned. By this, a client can iterate the hierarchy step by step.

Additionally, this table defines a list of objects that support the level modifier. For all other requests a 400 Bad Request should be responded (currently it is simply ignored).

We should correct the endpoints to correctly respond to this serialization modifier in order to be compliant with the spec. Test must be written and/or adapted to the corrected behavior.

hpoeche avatar Oct 01 '26 08:10 hpoeche