Skip to content

$ref error 'https://smart-data-models.github.io/data-models/common-schema.json' #2

@pealbow

Description

@pealbow

Hello.

When I import a copying Fiware's JSON schema from a JSON file, an error will occur.
Are you planning to update the Github URL in ModelParser.js?

Error

Error: Actualy the only the refs supported are GSMA, Location and PhysicalObject commons
    at Schema.allOf.map (C:\Develop\nodejs\fiware\node_modules\ngsi-parser\lib\ModelParser.js:257:28)
    at Array.map (<anonymous>)
    at NGSI.prepareModel (C:\Develop\nodejs\fiware\node_modules\ngsi-parser\lib\ModelParser.js:248:25)
    at NGSI.verifyModel (C:\Develop\nodejs\fiware\node_modules\ngsi-parser\lib\ModelParser.js:294:36)
    at NGSI.verifyModel (C:\Develop\nodejs\fiware\node_modules\ngsi-parser\lib\ModelParser.js:380:31)
    at Object.<anonymous> (C:\Develop\nodejs\fiware\ngsiDataModelTest.js:21:19)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)

Use JSON Data
https://github.com/smart-data-models/dataModel.Weather/blob/master/WeatherObserved/schema.json

verifyTest.js


// Data Model
const mySchemaImported = require('./dataModels/AirQualityObserved.json');
ngsi.setModel({
    testSchema : mySchemaImported
    // testSchema : 'https://github.com/smart-data-models/dataModel.Environment/blob/master/AirQualityObserved/schema.json'
});

let test = { 
    // id :'Alert1',
    type:'AirQualityObserved',
    // location : "45.001, 45.001" 
    dateObserved : new Date()  
};

let errors = ngsi.verifyModel('testSchema', test);
// console.log(errors);
if (errors.length === 0 ){
    console.log("The entity it's OK")
}else {
    errors.map(console.log)
}```


AirQualityObserved.json
```{
    "$schema": "http://json-schema.org/schema#",
    "id": "https://smart-data-models.github.io/dataModel.Environment/AirQualityObserved/schema.json",
    "title": "GSMA / FIWARE - Air quality observed schema",
    "description": "An observation of air quality conditions at a certain place and time.",
    "type": "object",
    "allOf": [
      {
        "$ref": "https://smart-data-models.github.io/data-models/common-schema.json#/definitions/GSMA-Commons"
      },
      {
        "$ref": "https://smart-data-models.github.io/data-models/common-schema.json#/definitions/Location-Commons"
      },
      {
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "AirQualityObserved"
            ],
            "description": "NGSI Entity type"
          },
          "dateObserved": {
            "type": "string"
          },
          "airQualityIndex": {
            "type": "number",
            "minimum": 0
          },
          "airQualityLevel": {
            "type": "string",
            "minLength": 2
          },
          "reliability": {
            "type": "number",
            "minimum": 0,
            "maximum": 1.0
          }
        }
      }
    ],
    "required": [
      "id",
      "type",
      "dateObserved",
      "location"
    ]
  }```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions