Package Exports
- @alt3/sequelize-to-json-schemas
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@alt3/sequelize-to-json-schemas) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sequelize-to-json-schemas
Convert Sequelize models into various JSON Schema variants (using the Strategy Pattern).
Supported Schemas
- JSON Schema v7
- OpenAPI v3
More welcome, examples found here
Installation
npm install @alt3/sequelize-to-json-schemas@"<1.0.0" --save
Example
const {
SchemaManager,
JsonSchema7Strategy,
OpenApi3Strategy,
} = require('sequelize-to-json-schemas');
const schemaManager = new SchemaManager();
// generate a JSON Schema Draft-07 model schema
let schema = schemaManager.generate(userModel, new JsonSchema7Strategy());
// and/or the OpenAPI 3.0 equivalent
schema = schemaManager.generate(userModel, new OpenApi3Strategy());
Additional Information
- understandable code
- compatible with Sequelize v4 and v5
- generates valid schemas (test suite using ajv and Swagger Parser validators)
Strategy Pattern
This library uses the Strategy Pattern to achieve the following:
- create rock-solid core functionality only once
- simplify support for new/upcoming schema variants
License
This project is released under MIT LICENSE.
Contributing
Please refer to the guidelines for contributing.