@oada/formats

4.1.0 • Public • Published

@OADA/formats

This package is a library for using OADA/formats with JavaScript/TypeScript. It is mainly an Ajv instance pre-packaged with the OADA schemas.

Installation

yarn add @oada/formats

Usage

This TypeScript/JavaScript library exports an async function that resolves to an Ajv instance which is loaded with all the schemas from this project.

import loadAllFormats from '@oada/formats';

const obj = {
  /* Properties and stuff here */
};

const formats = await loadAllFormats();

// Check that obj matches the format for and OADA bookmarks document
formats.validate('https://formats.openag.io/oada/bookmarks.schema', obj);

In addition to being loaded with all the OADA formats, the returned Ajv instance is also augmented to be able to resolve content types to the relevant schema.

// Returns the schema for an OADA Bookmarks document
const { schema } = formats.getSchema('applications/vnd.oada.bookmarks.1+json');

Versions

Current Tags

Version History

Package Sidebar

Install

npm i @oada/formats

Weekly Downloads

5

Version

4.1.0

License

MIT

Unpacked Size

35.8 kB

Total Files

33

Last publish

Collaborators

  • sanoel
  • serviopalacios
  • aultac
  • awlayton
  • oadao
  • tarakawa
  • cyrusbowman
  • abalmos