admin-shell-io / aas-test-engines

Official test tooling for the Asset Administration Shell
https://certification.admin-shell-io.com
Apache License 2.0
5 stars 2 forks source link

Validation of the simplest and minimal AAS is wrong #6

Closed lenaxus closed 3 months ago

lenaxus commented 5 months ago

Expected Behavior

I want to check my AASes to prove if they are Metamodel Version 3 confirm. I have choosen the variant to check json data directly. I had troubles when checking my AASes because it said all the time they are invalid. So I started with the simplest and minimal example. I created a new empty AAS in the AASX Package Explorer and exported the JSON of it. I expected that this AAS would be valid.

Actual Behavior

Unfortunately the result of the checked AAS is that is invalid:

Check JSON
   Does not match all sub-schemas
      Reference #/$defs/Environment is invalid
         Property assetAdministrationShells is invalid
            item 0 is invalid

Steps to Reproduce the Problem

I used this script to check the AAS with the JSON directly in the python script:

from aas_test_engines import file

aas = {
    'assetAdministrationShells': [
      {
          "id": "https://example.com/ids/aas/0532_3101_1042_1688",
          "assetInformation": {
            "assetKind": "Instance"
          },
          "submodels": [],
          "modelType": "AssetAdministrationShell"
      }
    ]
}
result = file.check_json_data(aas)
result.dump()
lenaxus commented 5 months ago

Update: I invested more time to find the problem. I checked this minimal AAS and it was valid. This has brought me further in the validation.

The json of this minimal AAS is the following:

{
  "assetAdministrationShells": [
    {
      "assetInformation": {
        "assetKind": "NotApplicable",
        "globalAssetId": "something_eea66fa1"
      },
      "id": "something_142922d6",
      "modelType": "AssetAdministrationShell"
    }
  ]
}

I have two open questions about this validation:

  1. If I delete the assetInformation.globalAssetId which is declared as optional in the v3 Metamodell specification the AAS gets invalid. Why is this the case when it is optional?
  2. If I add to the upper AAS the following: "submodels": [] it becomes invalid. Why is an empty array for submodels invalid?
otto-ifak commented 5 months ago

Thanks you for updating this. Concerning your points:

  1. I must have a look at the spec, first.
  2. According to https://github.com/admin-shell-io/aas-specs/blob/f4662a61cb7cdb180a779da38b409e7ead749628/schemas/json/aas.json#L582 there must be at least one element in this array
otto-ifak commented 5 months ago

Hi @lenaxus, we updated the underlying JSON schema library, so that you get much more information now:

Check JSON
   Does not match all sub-schemas
      Reference #/$defs/Environment is invalid
         Property assetAdministrationShells is invalid
            item 0 is invalid
               Reference #/$defs/AssetAdministrationShell is invalid
                  Does not match all sub-schemas
                     Property assetInformation is invalid
                        Reference #/$defs/AssetInformation is invalid
                           Does not match all sub-schemas
                              Reference #/$defs/Constraint_AASd-131 is invalid
                                 Does not match exactly one sub-schema
                                    Does not match all sub-schemas
                                       Property specificAssetIds is missing
                                    Does not match all sub-schemas
                                       Property globalAssetId is missing
                     Property submodels is invalid
                        Array is shorter than 1

The problem is that your AAS violates constraint AASd-131: The globalAssetId or at least one specificAssetId shall be defined for AssetInformation.

otto-ifak commented 4 months ago

@lenaxus Are you still having problems? Otherwise I would close this issue?