mathisonian / mathisonian/swaggerize
Does swaggerize still work?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 31
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
When using sequelize-cli, the said cli tool will create a folder structure for you with a `models/index.js`.
This index.js will then load all of the models in the `models` folder.
Now I tried to add ```var Swaggerize = require('swaggerize') to the project.
``` js
'use strict';
var fs = require('fs');
var path = require('path');
var Sequelize = require('sequelize');
var Swaggerize = require('swaggerize');
var basename = path.basename(module.filename);
var env = process.env.NODE_ENV || 'development';
var config = require(__dirname + '/../config/config.json')[env];
var db = {};
if (config.use_env_variable) {
var sequelize = new Sequelize(process.env[config.use_env_variable]);
} else {
var sequelize = new Sequelize(config.database, config.username, config.password, config);
}
fs
.readdirSync(__dirname)
.filter(function(file) {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
})
.forEach(function(file) {
var model = sequelize['import'](path.join(__dirname, file));
db[model.name] = model;
});
Object.keys(db).forEach(function(modelName) {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});
db.sequelize = sequelize;
db.Sequelize = Sequelize;
console.log(Swaggerize.generate(db,{}));
module.exports = db;
```
But when executing, I get this error:
``` log
module.js:341
throw err;
^
Error: Cannot find module 'jsv'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at /home/zwarag/Project/_/ideadb/backend/node_modules/swaggerize/lib/utils.js:13:21
at Object. (/home/zwarag/Project/_/ideadb/backend/node_modules/swaggerize/lib/utils.js:295:2)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at module.exports (/home/zwarag/Project/_/ideadb/backend/node_modules/swaggerize/lib/swaggerize.js:5:16)
at /home/zwarag/Project/_/ideadb/backend/node_modules/swaggerize/index.js:4:42
at Object. (/home/zwarag/Project/_/ideadb/backend/node_modules/swaggerize/index.js:5:2)
at Module._compile (module.js:413:34)
```
I'm positive that the module jsv is installed.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the require failure from models/index.js and inspect the loading path through node_modules/swaggerize/index.js, swaggerize.js, and lib/utils.js. Check why the reported jsv dependency is not resolvable in this setup; done means Swaggerize.generate(db,{}) runs without the missing-module error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100