When I make a request for a listed path in my swagger file, i.e. POST /countries, but this path only allow GET requests,
I can see the 405 status code in the response, but if I try to format that response I see an error:
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:530:11)
at ServerResponse.header (/Users/huortiz/dev/huortiz/scripts/node_modules/express/lib/response.js:771:10)
at ServerResponse.json (/Users/huortiz/dev/huortiz/scripts/node_modules/express/lib/response.js:264:10)
at /Users/huortiz/dev/huortiz/scripts/index.js:16:7
at Layer.handle [as handle_request] (/Users/huortiz/dev/huortiz/scripts/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/huortiz/dev/huortiz/scripts/node_modules/express/lib/router/index.js:317:13)
at /Users/huortiz/dev/huortiz/scripts/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/Users/huortiz/dev/huortiz/scripts/node_modules/express/lib/router/index.js:335:12)
at next (/Users/huortiz/dev/huortiz/scripts/node_modules/express/lib/router/index.js:275:10)
at /Users/huortiz/dev/huortiz/scripts/node_modules/swaggerize-express/lib/expressroutes.js:67:5
When I make a request for a listed path in my swagger file, i.e. POST /countries, but this path only allow GET requests, I can see the 405 status code in the response, but if I try to format that response I see an error:
Gist with an example to reproduce the bug
The current behavior does not allow manipulate the response when swaggerize express return a 405 status code.