Skip to content

Commit

Permalink
Prepare for first npm release
Browse files Browse the repository at this point in the history
  • Loading branch information
bravo-kernel committed Aug 22, 2019
1 parent 527ba51 commit 7539121
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions README.md
@@ -1,27 +1,38 @@
# sequelize-to-json-schemas

Convert Sequelize models into various JSON Schema variants like:
Convert Sequelize models into various JSON Schema variants. Uses the Strategy Pattern.

## Available Strategies

- JSON Schema v7
- OpenAPI v3

> More strategies welcome, [examples found here](https://github.com/alt3/sequelize-to-json-schemas/tree/master/lib/strategies)
## Installation

```bash
npm install @alt3/sequelize-to-json-schemas
```

## Example

```javascript
const { SchemaManager, JsonSchema7Strategy, OpenApi3Strategy } = require('./lib');
const { SchemaManager, JsonSchema7Strategy, OpenApi3Strategy } = require('sequelize-to-json-schema');
const schemaManager = new SchemaManager();

// generate a JSON Schema Draft-07 schema
// generate a JSON Schema Draft-07 model schema
let schema = SchemaManager.generate(userModel, new JsonSchema7Strategy());

// and the OpenAPI 3.0 equivalent
schema = SchemaManager.generate(sequelizeModel, new OpenApi3Strategy());
// and/or the OpenAPI 3.0 equivalent
schema = SchemaManager.generate(userModel, new OpenApi3Strategy());
```

## Notes:
## Additional Information

- not published on npm yet (soon)
- more strategies welcome, [examples found here](https://github.com/alt3/sequelize-to-json-schemas/tree/master/lib/strategies)
- understandable code
- compatible with Sequelize v4 and v5
- generates valid schemas (test suite using [ajv](https://github.com/epoberezkin/ajv) and [Swagger Parser](https://github.com/APIDevTools/swagger-parser) validators)

## License

Expand Down

0 comments on commit 7539121

Please sign in to comment.