Skip to content

Commit

Permalink
Renames JsonSchema6 to JsonSchema7
Browse files Browse the repository at this point in the history
  • Loading branch information
bravo-kernel committed Aug 17, 2019
1 parent 96f249b commit e35b38b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -2,9 +2,8 @@

Convert Sequelize models into any of the following JSON Schema variants:

- JSON Schema v6
- Swagger/OpenAPI v2
- Swagger/OpenAPI v3
- JSON Schema v7
- OpenAPI v3

> PR a new strategy if your variant is missing.
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js
@@ -1,9 +1,9 @@
const SchemaManager = require('./schema-manager');
const JsonSchema6Strategy = require('./strategies/json-schema-v6');
const JsonSchema7Strategy = require('./strategies/json-schema-v7');
const OpenApi3Strategy = require('./strategies/openapi-v3');

module.exports = {
SchemaManager,
JsonSchema6Strategy,
JsonSchema7Strategy,
OpenApi3Strategy,
};
Expand Up @@ -3,20 +3,20 @@
const StrategyInterface = require('../strategy-interface');

/**
* Strategy class responsible for converting Sequelize models into "JSON Schema v6" schemas.
* Strategy class responsible for converting Sequelize models into "JSON Schema v7" schemas.
*
* @augments StrategyInterface
*/
class JsonSchema6Strategy extends StrategyInterface {
class JsonSchema7Strategy extends StrategyInterface {
/**
* Returns the full URI to the online JSON Schema v6 schema (validation) file.
* Returns the full URI to the online JSON Schema v7 schema (validation) file.
*
* @example https://json-schema.org/draft-06/schema#
* @example https://json-schema.org/draft-07/schema#
*
* @returns {string}
*/
getSchemaUri() {
return 'https://json-schema.org/draft-06/schema#';
return 'https://json-schema.org/draft-07/schema#';
}

/**
Expand Down Expand Up @@ -64,4 +64,4 @@ class JsonSchema6Strategy extends StrategyInterface {
}
}

module.exports = JsonSchema6Strategy;
module.exports = JsonSchema7Strategy;
10 changes: 5 additions & 5 deletions test-the-strategy-pattern.js
Expand Up @@ -26,20 +26,20 @@ const userModel = sequelize.import("./test/models/user.js").build();
// ============================================================================
// Test the SchemaManager and strategies
// ============================================================================
const { SchemaManager, JsonSchema6Strategy, OpenApi3Strategy } = require('./lib');
const { SchemaManager, JsonSchema7Strategy, OpenApi3Strategy } = require('./lib');

// Initialize the SchemaManager with non-strategy-specific options
const schemaManager = new SchemaManager({
baseUri: 'https://api.example.com',
});

// ----------------------------------
// Generate JSON Schema v6 schema
// Generate JSON Schema v7 schema
// ----------------------------------
const json6strategy = new JsonSchema6Strategy();
let userSchema = schemaManager.generate(userModel, json6strategy);
const json7strategy = new JsonSchema7Strategy();
let userSchema = schemaManager.generate(userModel, json7strategy);

console.log('JSON Schema v6:')
console.log('JSON Schema v7:')
console.log(userSchema);
console.log(JSON.stringify(userSchema, null, 2));

Expand Down

0 comments on commit e35b38b

Please sign in to comment.