Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alfierichou/sequelize-to-json-schema
Sequelize model generate to json schema.
https://github.com/alfierichou/sequelize-to-json-schema
jsonschema sequelize swagger
Last synced: about 1 month ago
JSON representation
Sequelize model generate to json schema.
- Host: GitHub
- URL: https://github.com/alfierichou/sequelize-to-json-schema
- Owner: AlfieriChou
- License: mit
- Created: 2019-05-22T01:27:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-31T05:49:51.000Z (2 months ago)
- Last Synced: 2024-11-26T19:36:37.375Z (about 1 month ago)
- Topics: jsonschema, sequelize, swagger
- Language: JavaScript
- Size: 108 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sequelize-to-json-schema
[![standard][standard-image]][standard-url]
[![Package Quality][quality-image]][quality-url]
[![Build Status][travis-image]][travis-url]
[![codecov][codecov-image]][codecov-url]
[![Dependency Status][daviddm-image]][daviddm-url]
[![license][license-image]][license-url]Sequelize model generate to json schema.
## get started
* install
```bash
npm install sequelize-model-to-json-schema --save
```## how to use
* transform
* demo
```javascript
const s2json = require('sequelize-model-to-json-schema')
const Project = sequelize.define('Project', {
title: { type: Sequelize.STRING, comment: 'title' },
bigint: { type: Sequelize.BIGINT, comment: 'test bigint' },
number: { type: Sequelize.DOUBLE, comment: 'test double' },
number_decimal: { type: Sequelize.DECIMAL, comment: 'test decimal' },
uuid: { type: Sequelize.UUID, comment: 'test uuid' },
description: { type: Sequelize.TEXT, comment: 'description' }
})
const transformModel = s2json.transform(Project)
```* exclude
```javascript
const s2json = require('sequelize-model-to-json-schema')
const Project = sequelize.define('Project', {
title: { type: Sequelize.STRING, comment: 'title' },
description: { type: Sequelize.TEXT, comment: 'description' }
})
const transformModel = s2json.transform(Project, {
exclude: ['title']
})
```* convert
* string
```javascript
const convertStr = {
test: {
type: Sequelize.STRING,
comment: 'test field'
}
}
const convertJson = s2json.convert(convertStr)
```* object
```javascript
const convertObj = {
test: {
type: Sequelize.JSON(),
keys: {
test: {
type: Sequelize.STRING,
comment: 'test field'
}
}
}
}
const convertJson = s2json.convert(convertObj)
```* array
```javascript
const convertArr = {
test: {
type: Sequelize.ARRAY(),
items: {
test: {
type: Sequelize.STRING,
comment: 'test field'
}
}
}
}
const convertJson = s2json.convert(convertArr)
```[quality-image]: http://npm.packagequality.com/shield/sequelize-model-to-json-schema.svg
[quality-url]: http://packagequality.com/#?package=sequelize-model-to-json-schema
[travis-image]: https://travis-ci.org/AlfieriChou/sequelize-to-json-schema.svg?branch=master
[travis-url]: https://travis-ci.org/AlfieriChou/sequelize-to-json-schema
[codecov-image]: https://codecov.io/gh/AlfieriChou/sequelize-to-json-schema/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/AlfieriChou/sequelize-to-json-schema
[daviddm-image]: https://david-dm.org/AlfieriChou/sequelize-to-json-schema.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/AlfieriChou/sequelize-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