Cannot read security of undefined
See original GitHub issueHi,
Im trying to make it work, but Im getting this error
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'security' of undefined
starter-node-documentation | at /usr/app/node_modules/express-openapi-validator/dist/middlewares/openapi.security.js:16:47
starter-node-documentation | at Layer.handle [as handle_request] (/usr/app/node_modules/express/lib/router/layer.js:95:5)
starter-node-documentation | at trim_prefix (/usr/app/node_modules/express/lib/router/index.js:317:13)
starter-node-documentation | at /usr/app/node_modules/express/lib/router/index.js:284:7
starter-node-documentation | at Function.process_params (/usr/app/node_modules/express/lib/router/index.js:335:12)
starter-node-documentation | at next (/usr/app/node_modules/express/lib/router/index.js:275:10)
starter-node-documentation | at /usr/app/node_modules/express-openapi-validator/dist/middlewares/openapi.multipart.js:37:13
starter-node-documentation | at Layer.handle [as handle_request] (/usr/app/node_modules/express/lib/router/layer.js:95:5)
starter-node-documentation | at trim_prefix (/usr/app/node_modules/express/lib/router/index.js:317:13)
starter-node-documentation | at /usr/app/node_modules/express/lib/router/index.js:284:7
Im using node, docker, express etc.
Here is my code:
// some code above
const documentation = require('./components/documentation')
// some code below
new OpenApiValidator({
apiSpec: documentation,
validateResponses: true
}).install(app)
documentation is JSON object. According to error, which is pointing on row 16, it looks like problem is here:
const securities = req.openapi.schema.security || context.apiDoc.security;
I tried to add security[] to my documentation, but it doesnt work, so I assume problem is req.openapi.schema.scurity. To makes it clear, my app has 2 backends, one is for app, which is used by FE (there are all routes like get/post/…), second one is for OpenAPI documentation (we are using swagger-ui-express, nothing for production, thats why validator is here) which is using first one, where are all routes.
My questions is: its something with validator or where validator is using (BE for OpenAPI - no production)
Thank you 😃
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (8 by maintainers)
Yes this should be helpful for users 😃 thank you
Thats absolutely ok 😃 I appreciate your effort 😃 thank you very much