@startupjs/babel-plugin-ts-interface-to-json-schema
It is convert typescript interface to JSON-Schema and add that JSON to ORM model as static field.
Last updated a day ago by yska .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @startupjs/babel-plugin-ts-interface-to-json-schema 
SYNC missed versions from official npm registry.

@startupjs/babel-plugin-ts-interface-to-json-schema

Transforms typescript interface to JSON-schema and add schema as static field to ORM model.

TS interface to json-schema

For compilation interface to schema I used typescript-json-schema For add specific things of json-schema you should use API

Example

import { BaseModel } from 'startupjs/orm'

interface IEventModel {
  name: string
  /**
   * @default [1.23, 65.21, -123.40, 0, 1000000.0001]
   */
  amount: number[]
}

export default class EventModel extends BaseModel {
  methodOne() {
    return 1
  }
  methodTwo() {
    return 2
  }
}

↓ ↓ ↓ ↓ ↓ ↓

import { BaseModel } from 'startupjs/orm'

interface IEventModel {
  name: string
  /**
   * @default [1.23, 65.21, -123.40, 0, 1000000.0001]
   */

  amount: number[]
}

export default class EventModel extends BaseModel {
  static schema = {
    type: 'object',
    properties: {
      name: {
        type: 'string'
      },
      amount: {
        default: [1.23, 65.21, -123.4, 0, 1000000.0001],
        type: 'array',
        items: {
          type: 'number'
        }
      }
    },
    $schema: 'http://json-schema.org/draft-07/schema#'
  }

  methodOne() {
    return 1
  }

  methodTwo() {
    return 2
  }
}

Licence

MIT

Current Tags

  • 0.23.45                                ...           latest (a day ago)

3 Versions

  • 0.23.45                                ...           a day ago
  • 0.23.44                                ...           a day ago
  • 0.23.26                                ...           2 months ago
Downloads
Today 0
This Week 20
This Month 0
Last Day 20
Last Week 0
Last Month 20
Dependencies (6)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |