Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@api3/airnode-validator

Package Overview
Dependencies
Maintainers
2
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@api3/airnode-validator

Package for JSON specifications validation. Validation process can be configured with validator templates.

  • 0.2.2
  • npm
  • Socket score

Version published
Weekly downloads
295
decreased by-15.23%
Maintainers
2
Weekly downloads
 
Created
Source

@airnode/validator

Package for JSON specifications validation. Validation process can be configured with validator templates.

Usage

The validator can be run as a yarn script, by providing template of specification, and the path to the JSON file of specification that will be validated:

yarn run validate --template="[template]" --specs="[specsFile]"

Templates are case-insensitive, valid templates are: config, OIS, apiSpecifications/apiSpecs, endpoints and receipt:

yarn run validate --template="config" --specs="exampleSpecs/config.specs.json"

Validator will automatically validate the latest available version of provided template, in case a specific version should be used in validation, it can be appended to template argument:

yarn run validate --template="config@0.2.0" --specs="exampleSpecs/config.specs.json"

Custom templates can be used, by providing path to the validator template file in place of template:

yarn run validate --template="templates/0.2.0/config.json" --specs="exampleSpecs/config.specs.json"

Output

Above mentioned commands will return json in following format:

{
  valid: boolean,
  messages: { level: "error" | "warning", message: string }[]
}

valid is set to true in case there are no errors, however there can be still warnings in the messages.

Templates

Validator behavior can be configured with validator templates, which are regular json files using special keywords for specification validation. Usage of these keywords is described in the following chapters:

  • basics
  • regular expressions
  • type checking
  • catch
  • conditions
  • any
  • dynamic keys and values
  • optional parameters
  • nested templates

@airnode/convertor

Built-in validator extension capable of conversions between various specifications, conversions are configured using validator templates with conversion actions.

Usage

Convertor works the same way as validator and can be invoked with the convert command, for example:

yarn run convert --template="conversions/oas@3.0.0------ois@0.2.0.json" --specs="exampleSpecs/OAS.specs.json"

Conversions can be invoked without providing any template, specifying which format provided specification is in and to which format it should be converted into, is enough:

yarn run convert --from="OAS" --to="OIS" --specs="exampleSpecs/OAS.specs.json"

Specification formats are case-insensitive, currently available conversions are from OAS to OIS or from OIS to config. Version of the format can be provided as in validate command:

yarn run convert --from="OIS@pre-alpha" --to="config@pre-alpha" --specs="exampleSpecs/ois.specs.json"

Output

On top of validator output, convertor provides an output object, which contains the converted specification:

{
  valid: boolean,
  messages: { level: "error" | "warning", message: string }[],
  output: object
}

Alternatively command can be ran with argument --specs-only, which will return only the converted specification.

Templates

Convertor uses the same templates as validator. The resulting specification can be written into output object with actions.

Documentation

Source documentation markdown files are located in docs/src/ directory. All template related examples are located in test/fixtures/ and injected into markdown using markdown-snippet-injector by running yarn run docs. Generated markdown files can be found in docs/, test files using the same examples can be found in test/ directory.

FAQs

Package last updated on 03 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc