Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue] JSON Schema Validation tool #478

Open
LahariMIBS opened this issue Dec 6, 2023 · 1 comment
Open

[Issue] JSON Schema Validation tool #478

LahariMIBS opened this issue Dec 6, 2023 · 1 comment
Assignees

Comments

@LahariMIBS
Copy link
Collaborator

Issue 1:

Validation tool is not validating the ‘datatype’ and ‘unit’ keys in the JSON-Schema.

The JSON-Schema must accommodate two different type related keys, one is ‘datatype’ that is inherited from ECLASS for XSD types, and one is ‘type’ for UI usage that might contain types like ‘string’, ‘array’, 'number', etc. The JSON-Schema must also accommodate ‘unit’ key for some properties to use in UI.

Hence, we need to include ‘datatype’ and ‘unit’ in validation process.

Example JSON-Schema:

{ 

  "$schema": "http://json-schema.org/schema#", 

  "$id": "https://industry-fusion.org/eclass%230173-1%2301-AKJ975%23017", 

  "title": "Plasma Cutter POC", 

  "description": "Plasma Cutter template for IFF", 

  "type": "object", 

  "properties": { 

    "eclass:0173-1#02-AAH841#003": { 

      "type": "number", 

      "datatype": "xsd:double", 

      "title": "max. center cut", 

      "description": "maximum spacial expansion of the centre cut", 

      "unit": "mm" 

    } 

    } 

} 

Issue 2:

Validation tool is validating unknown fields.

Expected:

Field doesn’t exist in the schema.

Actual:

The data is getting validated successfully.

Example JSON-Schema:

{ 

  "$schema": "http://json-schema.org/schema#", 

  "$id": "https://industry-fusion.org/eclass%230173-1%2301-AKJ975%23017", 

  "title": "Plasma Cutter POC", 

  "description": "Plasma Cutter template for IFF", 

  "type": "object", 

  "properties": { 

    "machine_state": { 

        "type": "string", 

        "title": "Machine Status", 

        "description": "Current status of the machine (Online_Idle, Run, Online_Error, Online_Maintenance,   Setup, Testing)", 

        "readOnly": false 

    }, 

    "eclass:0173-1#02-AAH841#003": { 

      "type": "number", 

      "datatype": "xs:double", 

      "title": "max. center cut", 

      "description": "maximum spacial expansion of the centre cut", 

      "unit": "mm" 

    } 

} 

Example JSON-LD Data:

{ 

    "@context": "https://industryfusion.github.io/contexts/v0.1/context.jsonld", 

    "id": "urn:iff:abc123", 

    "type": "eclass:0173-1#01-AKJ975#017", 

    "machine_state": "Testing",  

    "unknown_field": 12457,  ##invalid field 

    "eclass:0173-1#02-AAH841#003": 25 

} 
@wagmarcel
Copy link
Member

first part: @LahariMIBS this can be solved by adding both field names to the addedKeywords array in validate.js. Please create a PR for it, in the PR please add the example in the examples directory and add one example to tests/validation directory for script tests.
second part: This needs a little bit more considerations. JSON-LD is also adding fields which must be ignored by the schema (e.g the "@context" field in your example. When we validate that strict, we can run into other problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants