When deliberately making invalid requests (POST to PUT only endpoint) I receive a full error stack dump on the client side, looking at the debug log, the flow never makes it to pipeworks (and the tidy json_error_handler).
My project is based off the express swagger-node skeleton but I'm trying to upgrade to swagger-express-mw 0.7.0.
Valid requests the express router seems to be passed through and pipes handles everything correctly.
DEBUG=* log on invalid request:
express:router dispatching POST /postOnly +2s
express:router query : /postOnly +0ms
express:router expressInit : /postOnly +1ms
express:router middleware : /postOnly +0ms
finalhandler default 405 +1ms
Error: Path [/postOnly] defined in Swagger, but POST operation is not.
at middleware
at Layer.handle [as handle_request]
at trim_prefix
at /lib/router/index.js:280:7
at Function.process_params
at next
at expressInit
at Layer.handle [as handle_request]
at trim_prefix
at
at Function.process_params
at next
at query
at Layer.handle [as handle_request]
at trim_prefix
at
at Function.process_params
at next
at Function.handle
at EventEmitter.handle
at Server.app
at emitTwo (events.js:106:13)
at Server.emit (events.js:191:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:546:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
My software versions:
"dependencies": {
"express": "^4.12.3",
"swagger-express-mw": "^0.7.0"
}
config file:
# swagger configuration file
# values in the swagger hash are system configuration for swagger-node
swagger:
fittingsDirs: [ api/fittings ]
defaultPipe: null
swaggerControllerPipe: swagger_controllers # defines the standard processing pipe for controllers
# values defined in the bagpipes key are the bagpipes pipes and fittings definitions
# (see https://github.com/apigee-127/bagpipes)
bagpipes:
_router:
name: swagger_router
mockMode: true
mockControllersDirs: [ api/mocks ]
controllersDirs: [ api/controllers ]
_swagger_validate:
name: swagger_validator
validateResponse: false
_json_error_handler: # <= Add this definition
name: json_error_handler
handle500Errors: true
# pipe for all swagger-node controllers
swagger_controllers:
- onError: _json_error_handler
- cors
- swagger_params_parser
- swagger_security
- _swagger_validate
- express_compatibility
- _router
# pipe to serve swagger (endpoint is in swagger.yaml)
swagger_raw:
name: swagger_raw
# any other values in this file are just loaded into the config for application access...
Yes, this should only return the 405 and not a stack. Also, yes, it should probably be sent to error handler instead of being handled directly. Thanks.
When deliberately making invalid requests (POST to PUT only endpoint) I receive a full error stack dump on the client side, looking at the debug log, the flow never makes it to pipeworks (and the tidy json_error_handler).
My project is based off the express swagger-node skeleton but I'm trying to upgrade to swagger-express-mw 0.7.0.
Valid requests the express router seems to be passed through and pipes handles everything correctly.
DEBUG=* log on invalid request:
My software versions: "dependencies": { "express": "^4.12.3", "swagger-express-mw": "^0.7.0" }
config file:
Thanks for any help!