@loopback/repository-json-schema
TypeScript icon, indicating that this package has built-in type declarations

8.0.0 • Public • Published

@loopback/repository-json-schema

Convert a TypeScript class/model to a JSON Schema for users, leveraging LoopBack4's decorators, metadata, and reflection system.

Overview

This package provides modules to easily convert LoopBack4 models that have been decorated with @model and @property to a matching JSON Schema Definition.

Installation

$ npm install --save @loopback/repository-json-schema

Basic use

import {getJsonSchema} from '@loopback/repository-json-schema';
import {model, property} from '@loopback/repository';

@model()
class MyModel {
  @property()
  name: string;
}

const jsonSchema = getJsonSchema(MyModel);

The value of jsonSchema will be:

{
  "title": "MyModel",
  "properties": {
    "name": {
      "type": "string"
    }
  }
}

Contributions

Tests

Run npm test from the root folder.

Contributors

See all contributors.

License

MIT

Package Sidebar

Install

npm i @loopback/repository-json-schema

Weekly Downloads

38,843

Version

8.0.0

License

MIT

Unpacked Size

80.2 kB

Total Files

19

Last publish

Collaborators

  • rfeng
  • bajtos
  • rmg
  • hacksparrow
  • dhmlau
  • jerry-apic
  • theprez
  • frbuceta
  • marioestradarosa
  • achrinza