Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alfierichou/typeorm-schema-to-json-schema

Typeorm entitySchema to json schema.
https://github.com/alfierichou/typeorm-schema-to-json-schema

Last synced: 15 days ago
JSON representation

Typeorm entitySchema to json schema.

Awesome Lists containing this project

README

        

# typeorm-schema-to-json-schema

[![NPM version][npm-image]][npm-url]
[![license][license-image]][license-url]

[![standard][standard-image]][standard-url]

Typeorm entitySchema to json schema.

## Install

```shell
npm install typeorm-schema-to-json-schema
```

## Get started

* Cat model

```javascript
const { EntitySchema } = require('typeorm')

const Cat = new EntitySchema({
name: 'cats',
columns: {
id: {
type: Number,
primary: true,
generated: true
},
name: {
type: String
}
}
})

module.exports = Cat
```

* convert model

```javascript
const convert = require('typeorm-schema-to-json-schema')
const Cat = require('./cat')

const schema = convert(Cat)
console.log(schema)

// {
// type: 'object',
// properties: {
// id: { type: 'number', primary: true, generated: true },
// name: { type: 'string' }
// }
// }
```

[npm-image]: https://badge.fury.io/js/typeorm-schema-to-json-schema.svg
[npm-url]: https://npmjs.org/package/typeorm-schema-to-json-schema
[license-image]: https://img.shields.io/badge/License-MIT-yellow.svg
[license-url]: https://opensource.org/licenses/MIT
[standard-image]:
https://cdn.rawgit.com/standard/standard/master/badge.svg
[standard-url]:
https://github.com/standard/standard