Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/alfierichou/typeorm-schema-to-json-schema
- Owner: AlfieriChou
- License: mit
- Created: 2018-12-25T09:34:04.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-23T02:57:45.000Z (10 months ago)
- Last Synced: 2024-11-20T19:16:43.398Z (about 1 month ago)
- Language: JavaScript
- Size: 51.8 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
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