Comments (23)
Problem is that in Node 12 Module Not Found error differs from Node 10. bagpipes relies on error message text. This can tepmorary be fixed in this file: node_modules/bagpipes/lib/fittingTypes/user.js file:
var split = err.message.split(path.sep);
should be
var split = err.message.split('\n')[0].split(path.sep);
from swagger-node.
Try this, tested on node version to date (12.13.1):
- Update your swagger-express-mw:
"swagger-express-mw": "^0.7.0"
- Add swagger_params_parser to swagger_controllers at config/default.yaml
...
pipe for all swagger-node controllers
swagger_controllers:
- onError: json_error_handler
- cors
- swagger_params_parser
...
-
Run npm install
-
Run swagger project start
I wish swagger-node will receive more timely update.
from swagger-node.
This is probably because you are running node v12.2.0! Try to downgrade your node to version 10, version 12 is not stable.
from swagger-node.
@gohmc - Thank you, your solution works splendidly with v12.16.1 and requires minimal configuration without touching the code.
from swagger-node.
I know how to fixed this issue.
Copy some files
from project/node_modules/swagger-node-runner/fittings
to project/api/fittings/swagger_router
,
from project/node_modules/bagpipes/lib/fittings
to project/api/fittings/swagger_router
Finally, start is OK.
I think I have make a wrong path with module.
from swagger-node.
Try this, tested on node version to date (12.13.1):
1. Update your swagger-express-mw:
"swagger-express-mw": "^0.7.0"
1. Add swagger_params_parser to swagger_controllers at config/default.yaml ...
pipe for all swagger-node controllers
swagger_controllers: - onError: json_error_handler - cors - swagger_params_parser ...
1. Run npm install 2. Run swagger project start
I wish swagger-node will receive more timely update.
Thanks for the fix @gohmc.
Note: this fix also works for me with node v15.1.0
from swagger-node.
Try this, tested on node version to date (12.13.1):
- Update your swagger-express-mw:
"swagger-express-mw": "^0.7.0"
- Add swagger_params_parser to swagger_controllers at config/default.yaml
...pipe for all swagger-node controllers
swagger_controllers: - onError: json_error_handler - cors - swagger_params_parser ...
- Run npm install
- Run swagger project start
I wish swagger-node will receive more timely update.
This fixes the error but routes are not working properly.
For eg. 1) - GET /path/{id}
2) - POST /path/xyz
while making call to POST /path/xyz, it's throwing error method POST is not defined for /path/{id}
It's treating xyz as some id
from swagger-node.
- onError: json_error_handler
- cors
- swagger_params_parser
Thank you! It`s works for me
from swagger-node.
Is this the best approach to fix the issue? This seems like a new problem with Swagger. Please help with the right approach. Thanks.
from swagger-node.
I also had same problems. Tried the file copying from fittings-directory. This didn't work for me.
I downgraded node to 10.16.0 (and npm 6.9.0) and all was solved....
from swagger-node.
@deventorum Node v10.16.0
is work for me. Thank you!
from swagger-node.
I have the exact same issue as the OP. Node v12 is becoming LTS in one month; I'd generally assume I should be able to follow the instructions in the README and have a working 'getting started' project. This doesn't appear to be the case at the moment.
from swagger-node.
I have the exact same issue too. I was trying to upgrade to node v12.
Error initializing middleware
Error: Cannot find module '/Users/nodejs/services/account/api/fittings/swagger_router'
Require stack:
- /Users/nodejs/services/account/node_modules/bagpipes/lib/fittingTypes/user.js
- /Users/nodejs/services/account/node_modules/bagpipes/lib/bagpipes.js
- /Users/nodejs/services/account/node_modules/bagpipes/lib/index.js
- /Users/nodejs/services/account/node_modules/swagger-node-runner/index.js
- /Users/nodejs/services/account/node_modules/swagger-express-mw/lib/index.js
- /Users/nodejs/services/account/node_modules/cm-util/app-start.js
- /Users/nodejs/services/account/node_modules/cm-util/index.js
- /Users/nodejs/services/account/app.js
from swagger-node.
Happens to me as well on node 12
from swagger-node.
Same issue
env: node 12.13.1 npm 6.12.1
from swagger-node.
I also had to move to node 12 and since I felt this lib is no longer maintained nor supported I decided to shift to swagger-ui-express
. the above solution could have saved me serveral hours of debugging.
from swagger-node.
try to install swagger-router with command
$npm install --save swagger-router
it's work for me
from swagger-node.
This is probably because you are running node v12.2.0! Try to downgrade your node to version 10, version 12 is not stable.
This worked for me as well, downgraded to v10.15.0
.
from swagger-node.
Try this, tested on node version to date (12.13.1):
- Update your swagger-express-mw:
"swagger-express-mw": "^0.7.0"
- Add swagger_params_parser to swagger_controllers at config/default.yaml
...pipe for all swagger-node controllers
swagger_controllers: - onError: json_error_handler - cors - swagger_params_parser ...
- Run npm install
- Run swagger project start
I wish swagger-node will receive more timely update.
I did the same but the issue wasnt resolved, its showing this error
`Error initializing middleware
Error: Cannot find module 'D:\swagggggger\hello\api\fittings\swagger_router'
Require stack:
- D:\swagggggger\hello\node_modules\bagpipes\lib\fittingTypes\user.js
- D:\swagggggger\hello\node_modules\bagpipes\lib\bagpipes.js
- D:\swagggggger\hello\node_modules\bagpipes\lib\index.js
- D:\swagggggger\hello\node_modules\swagger-node-runner\index.js
- D:\swagggggger\hello\node_modules\swagger-express-mw\lib\index.js
- D:\swagggggger\hello\app.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1080:15)
at Function.Module._load (internal/modules/cjs/loader.js:923:27)
at Module.require (internal/modules/cjs/loader.js:1140:19)
at require (internal/modules/cjs/helpers.js:75:18)
at createFitting (D:\swagggggger\hello\node_modules\bagpipes\lib\fittingTypes\user.js:18:20)
at Bagpipes.newFitting (D:\swagggggger\hello\node_modules\bagpipes\lib\bagpipes.js:158:17)
at Bagpipes.createFitting (D:\swagggggger\hello\node_modules\bagpipes\lib\bagpipes.js:147:22)
at Bagpipes.createPipe (D:\swagggggger\hello\node_modules\bagpipes\lib\bagpipes.js:111:19)
at Bagpipes.getPipe (D:\swagggggger\hello\node_modules\bagpipes\lib\bagpipes.js:50:38)
at D:\swagggggger\hello\node_modules\bagpipes\lib\bagpipes.js:34:10`
how should I sort it out? @gohmc
from swagger-node.
I solved the problem downgrading my Node version to 10.23.0
from swagger-node.
Wow this project is absolutely unmaintained. I experienced the same issue as all of the above.
Even the code that is auto-generated for the hello world controller is stale.
req.param('name') is the valid way to pull parameters from the request object now.
Now req.swagger.params.name.value
from swagger-node.
I think I've figured out a way around this error with the following changes to the fittingsDir:
fittingsDirs: [ node_modules/swagger-node-runner/fittings ]
Then I had to remove this line under "swagger_controllers" to get it work, or else I get an error complaining about "onError" not being a fitting.
- onError: json_error_handler
I don't think, in my case, that I really need the json_error_handler. But tbh, I'm not 100% sure what it does. Does anyone know?
from swagger-node.
Try this, tested on node version to date (12.13.1):
- Update your swagger-express-mw:
"swagger-express-mw": "^0.7.0"
- Add swagger_params_parser to swagger_controllers at config/default.yaml
...pipe for all swagger-node controllers
swagger_controllers: - onError: json_error_handler - cors - swagger_params_parser ...
- Run npm install
- Run swagger project start
I wish swagger-node will receive more timely update.
Thanks alot, it's works for me.
I had the same issue with env:
Node -v: 16.16.0
npm -v: 8.11.0
from swagger-node.
Related Issues (20)
- Is there a way to hide an API in swagger UI ? Something like `hidden: true` in API definitions in swagger json file for nodejs application
- INVALID_TYPE on Date format field
- e.replace is not a function
- bug & Error: Response validation failed: failed schema validation HOT 2
- lodash version causing node vulnerability audit HOT 1
- swagger project edit cannot get / HOT 13
- I facing Issue in Swagger api ? HOT 1
- Question: is `swagger-node-express` out of date? HOT 2
- Question: swagger-node-express has dependency vulnerability with outdated lodash version HOT 1
- Getting stack trace in swagger validation response
- Invalid request body validation for properties defined with capital letters
- Is this project deprecated? HOT 4
- Current version using old version of mocha that has a critical vulnerability HOT 1
- Uploading files mongodb using gridfs using swagger-tools, swagger-ui-express, multer-gridfs-storage, multer
- is the swagger-ui automatically included ?
- Is swagger-node deprecated? HOT 1
- help me to solve this issue
- 361 HOT 1
- Is there any possibility to upload auto generated swagger docs to the swagger.io
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swagger-node.