🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

sequelize-json-schema

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sequelize-json-schema

Use your Sequelize models in JSON Schemas or Swagger

1.0.1
Source
npm
Version published
Weekly downloads
1K
-30.28%
Maintainers
1
Weekly downloads
 
Created
Source

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.

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

Keywords

sequelize

FAQs

Package last updated on 29 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts