# mofe-sequelize-json-schema

> Use your Sequelize models in JSON Schemas or Swagger

Latest version **1.2.2** (published 2017-05-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install mofe-sequelize-json-schema
pnpm add mofe-sequelize-json-schema
yarn add mofe-sequelize-json-schema
bun add mofe-sequelize-json-schema
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2017-05-04 |
| First published | 2017-05-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 34 |
| Author | Mike Chaliy |
| Maintainers | mofe |
| Keywords | sequelize, json, json-schema, swagger |

## Links

- npm: https://www.npmjs.com/package/mofe-sequelize-json-schema
- Repository: https://github.com/chaliy/sequelize-json-schema
- Homepage: https://github.com/chaliy/sequelize-json-schema#readme
- Issues: https://github.com/chaliy/sequelize-json-schema/issues
- npm.io page: https://npm.io/package/mofe-sequelize-json-schema

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.2.2 (latest) — 2017-05-04

## README

# sequelize-json-schema

[![NPM Version](https://img.shields.io/npm/v/sequelize-json-schema.svg)](https://npmjs.org/package/sequelize-json-schema)
[![CircleCI](https://circleci.com/gh/chaliy/sequelize-json-schema.svg?style=svg)](https://circleci.com/gh/chaliy/sequelize-json-schema)

Use your Sequelize models in JSON Schemas or Swagger

Main use case for this code is to generate models for hand crafted swagger.json.

## Installation

This is a [Node.js](https://nodejs.org/en/) module available through the
[npm registry](https://www.npmjs.com/). Installation is done using the
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):

```bash
$ npm install sequelize-json-schema
```


## Example

```
let Simple = sequelize.define('simple', {
  title: Sequelize.STRING,
  description: Sequelize.TEXT
});

let def = definition(Simple);

console.log(def);
```

And result will be:

```
{
  type: 'object',
  properties: {
    id: {
      type: 'integer',
      format: 'int32'
    },
    title: { type: 'string' },
    description: { type: 'string' },
    createdAt: {
      type: 'string',
      format: 'date-time'
    },
    updatedAt: {
      type: 'string',
      format: 'date-time'
    }
  }
}
```

## Using with Swagger

This tool generates `definitions` part of the Swagger Manifest. So if you have Swagger definition for your API just extend `definitions` with JSON generated by this tool.

```
{
  "swagger": "2.0",
  "info": {
    "title": "API",
    "version": "1.0.0"
  },
  "paths": {
    "simple": {
      "get": {      
        "parameters": [ ],
        "responses": {
          "200": { "$ref": "#/definitions/simple" }
        }
      }
    }
  },
  "definitions": {
    "simple": {
      type: 'object',
      properties: {
        id: {
          type: 'integer',
          format: 'int32'
        },
        title: { type: 'string' },
        description: { type: 'string' },
        createdAt: {
          type: 'string',
          format: 'date-time'
        },
        updatedAt: {
          type: 'string',
          format: 'date-time'
        }
      }
    }
  }
}
```

## LICENSE

[MIT License](http://en.wikipedia.org/wiki/MIT_License)

---
_Source: https://npm.io/package/mofe-sequelize-json-schema · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
