eclipse-esmf / esmf-sdk

Load Aspect Models and their artifacts as Java code; share components to realize SAMM as code
https://eclipse-esmf.github.io/esmf-developer-guide/index.html
Mozilla Public License 2.0
25 stars 12 forks source link

[BUG] Example JSON generated with SAMM CLI does not validate against generated JSON Schema #372

Closed bs-jokri closed 1 year ago

bs-jokri commented 1 year ago

Describe the bug the generated example json and schema for model https://github.com/eclipse-tractusx/sldt-semantic-models/blob/main/io.catenax.fleet.claim_data/1.0.0/ClaimData.ttl

to be found here https://github.com/eclipse-tractusx/sldt-semantic-models/tree/main/io.catenax.fleet.claim_data/1.0.0/gen

did not validate against the published generated schema.

Where Artifacts generated with BAMM-cLI 2.1.3

bs-jokri commented 1 year ago

I did some further investigations also with same-cli-2.2.2.jar

What I did:

  1. checkout slat-semantic-models repository for example models

    git clone https://github.com/eclipse-tractusx/sldt-semantic-models.git
  2. Run schema generator for PCF model v4.0.0

    java -jar samm-cli-2.2.2.jar aspect io.catenax.pcf/4.0.0/Pcf.ttl to schema
  3. Run json example generator for PCF model v4.0.0

    java -jar samm-cli-2.2.2.jar aspect io.catenax.pcf/4.0.0/Pcf.ttl to json
  4. Validate example output, eg with https://jsonschemalint.com/#!/version/draft-04/markup/json

Received several validation errors

Field Error Value
.precedingPfIds should be array { "id": "3893bb5d-da16-4dc1-9185-11d97476c254" }
.version should be >= 1 0
.companyIds should be array { "companyId": "urn:uuid:51131FB5-42A2-4267-A402-0ECFEFAD1619" }
.productIds should be array { "productId": "urn:gtin:4712345060507" }
.pcf.productOrSectorSpecificRules[0].productOrSectorSpecificRules should be array { "ruleName": "urn:tfs-initiative.com:PCR:The Product Carbon Footprint Guideline for the Chemical Industry:version:v2.0" }

Observations

atextor commented 1 year ago

Note that the JSON generation was fixed in regards to wrong structures for sets (leading to the should be array validation messages) and for example values that use the rdf:langString datatype. However, for the PCF 4.0.0 model, JSON Schema validation will still fail due to an error in the model:

bamm:exampleValue "0"^^xsd:positiveInteger.

0 is not a valid value in for xsd:positiveInteger.

Similarly, JSON Schema validation will fail for ClaimData.ttl, because the example value provided for :vehicleCatenaXId:

bamm:exampleValue "580d3adf-1981-44a0-a214" .

does not actually correspond to the regular expression that is used in the :CatenaXIdTrait.

Improved validation of values for samm:exampleValue will be adressed in #384.