Page Contents

LoopBack 3 JSON Schemas

This repository contains JSONSchemas for the LoopBack framework. Loopback uses lots of complex json files for configuration, by linking these files to a json schema you can get “intellisense” style type-ahead and some schema validation (detection of illegal properties or types).

:warning: These schemas do not capture every feature & setting. They are for hints & discovery while coding. Consult docs for best results :+1:.

:information_source: These schemas target loopback version 3.

Using the schemas

:point_right: The VS Code Plugin is the easiest way to use these schemas while writing LoopBack applications! :point_left:

Method 2. Point json files to schemas

Using an IDE that supports JSONSchemas (I recommend VS Code), point to a schema thus: common/models/customer.json

{
  "$schema" : "https://raw.githubusercontent.com/Sequoia/loopback-json-schemas/master/dist/loopback-model-definition.json"
}

:warning: Your editor or IDE must support $refs for JSONSchema! Not all do..

If you use a different tool than VSCode and it works with JSONSchema (and $refs!), please send a PR so I can list it here. These tools are worth trying!

Method 3. Map schemas to file by file paths (VS Code)

:information_source: If you’re using VSCode you may as well use method 1

Edit your jsconfig.json in VS Code to map schemas to file paths in your project:


    {
      "fileMatch": "/common/models/*.json",
      "url": "https://raw.githubusercontent.com/Sequoia/loopback-json-schemas/master/dist/loopback-model-definition.json"
    },
    {

This will automatically link schemas to paths so you don’t have to use Method 2. Read more.

Currently Implemented Schemas

Schemas in this repository cover the following files:

  1. model-config.json
  2. datasources.json
  3. config.json
  4. */models/[Model].json
  5. middleware.json

Contributing

See CONTRIBUTING.md