npm

Need private packages and team management tools?Check out npm Orgs. »

jsonapi-typescript

0.1.3 • Public • Published

JSONAPI-typescript

Build Status Version

TypeScript type information for compile-time validation of JSON:API documents. Supports TS 2.3 and above.

How to use this

  1. Install this package
npm install --save-dev jsonapi-typescript
  1. Import this module
import * as JSONAPI from 'jsonapi-typescript';
  1. check to see if json types are validated correctly
import * as JSONAPI from 'jsonapi-typescript';
 
// ✅ This should be OK
let doc: JSONAPI.Document = {
  data: {
    type: 'articles',
    id: '1'
  }
};
 
// ⛔️ This should NOT be OK ("result" is not a valid JSON:API top-level key)
let doc: JSONAPI.Document = {
  result: "Success!"
};
 
// ⛔️ This should NOT be OK ( empty Array is not a valid JSON:API document )
let doc: JSONAPI.Document = [];

Copyright

© 2017 Mike North, All Rights Reserved.

install

npm i jsonapi-typescript

Downloadsweekly downloads

1,216

version

0.1.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability