npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fiware-model-validator

v0.5.1

Published

A simple validator for FIWARE Data Models

Downloads

2

Readme

FIWARE Data Model validator

FIWARE Data Model validator is an utility to help the management of NGSI DataModels. Its code leverage on the AJV JSON Schema Validator.

The FIWARE Data Model validator perform the following checks for each Data Model:

  • validity of JSON Schema
  • validity of JSON Examples
  • support of JSON Examples in Orion Context Broker
  • adherence of Data Model name to FIWARE Data Models guidelines
  • existence of Doc folder
  • existence of JSON Schema
  • existence of one or more JSON examples
  • existence of README file

Install the validator

To install the validator on your machine, you need nodejs 7.0.0+. Instructions on how to install nodejs are available here.

Once nodejs installed in your system, you can install the validator with the following command:

npm install -g fiware-model-validator

Using the validator

To use the validator, execute it from the root of the DataModel repository:

validate -p DataModel -w ignore -i [common-schema.json,geometry-schema.json]

Command line available options are:

  • -i, --dmv:importSchemas. Additional schemas that will be included during validation. Default imported schemas are: common-schema.json, geometry-schema.json [array]
  • -w, --dmv:warnings. How to handle FIWARE Data Models checks warnings.
    • true (default) - print warnings, but does not fail.
    • ignore - do nothing and do not print warnings.
    • fail - print warnings, and fails.
  • -p, --dmv:path. The path of FIWARE Data Model(s) to be validated (if recursion enabled, it will be the starting point of recursion)
  • -c, --dmv:contextBroker. Enable example testing with Orion Context Broker
  • -u, --dmv:contextBrokerUrl. Orion Context Broker URL for Example testing
  • -v, --version. Print the validator version
  • -h, --help. Print the help message

If you want to execute validate outside the root directory and you want to import the common schemas, you have to import them using the correct path.

If you experience un expected behaviours, you can check the process using the debug functionality, e.g.:

DEBUG=* validate -p .

Default configuration

For a more fine grained configuration you can create a config.json file. An example is provided in the repository.

Options available are:

  • dmv:importSchemas: the list of schemas to be imported as support to validation. Default value: ['common-schema.json','geometry-schema.json']
  • dmv:warnings: how to handle FIWARE Data Models checks warnings.
    • true (default) - print warnings, but does not fail.
    • ignore - do nothing and do not print warnings.
    • fail - print warnings, and fails.
  • dmv:warningChecks: The list of checks that should be executed:
    • schemaExist: existence of JSON Schema
    • docExist: existence of Documentation
    • docFolderExist: existence of Doc folder
    • exampleExist: existence of one or more JSON examples
    • modelNameValid: adherence of Data Model name to FIWARE Data Models guidelines
    • readmeExist: existence of README file
  • dmv:recursiveScan: enable or disable the recursive scanning of directory. Default value: true
  • dmv:validateExamples: enable or disable the validation of JSON Examples. Default value: true
  • dmv:loadModelCommonSchemas: automatically include any file named *-schema.json in data path.
  • dmv:ignoreFolders: The list of folder names that should be ignored. Default value: ['harvest','auxiliary','img']
  • dmv:docFolders: The list of folder names that are expected to contain Documentation: Default value: ['doc']
  • dmv:contextBroker: Enable JSON example testing with Orion Context Broker. Default value: false
  • dmv:contextBrokerUrl: The URL for the Orion Context Broker for JSON example testing. Default value: http://localhost:1026/v2
  • ajv:missingRefs: handling of missing referenced schemas. See ajv for more details. Option values:
    • true (default) - if the reference cannot be resolved during compilation the exception is thrown. The thrown error has properties missingRef (with hash fragment) and missingSchema (without it). Both properties are resolved relative to the current base id (usually schema id, unless it was substituted).
    • ignore - to log error during compilation and always pass validation.
    • fail - to log error and successfully compile schema but fail validation if this rule is checked.
  • ajv:extendRefs: validation of other keywords when $ref is present in the schema. See ajv for more details. Option values:
    • ignore - when $ref is used other keywords are ignored (as per JSON Reference standard). A warning will be logged during the schema compilation.
    • fail (default) - if other validation keywords are used together with $ref the exception will be thrown when the schema is compiled. This option is recommended to make sure schema has no keywords that are ignored, which can be confusing.
    • true - validate all keywords in the schemas with $ref (the default behaviour in versions before ajv 5.0.0).
  • ajv:allErrors: when true check all rules collecting all errors, when false return after the first error. See ajv for more details. Default value: true

Compiling the validator

Should you want to change the code of the validator, to install your modified version, you simply need to compile it with the following command:

npm install -g