I'm a little perplexed. I cannot seem to find the documentation regarding swagger error handling. I have searched in all the usual places for answers to my questions without delving into the code, combed through the docs, and searched for keywords. All I found were seemingly outdated solutions. Perhaps I missed something.
My problem is - when I get a validation error it comes as an ugly JSON response with my request buffer attached. How do developers opt out, or modify this error object?
I am using a project generated with swagger project create, with express.
I also want to be able to generate a valid swagger error from within a controller, as we used to be able to do with swagger-express. Something like
throw swagger.errors.notFound('pet');
https://github.com/swagger-api/swagger-node/tree/2.0.x
Where has this functionality gone?
If that fails, I want to handle errors in the express way - with error handling middleware - but this doesn't seem to work.. I want to choose what I surface to API consumers.
And the final thing, is that the swagger error responses are coming back clipped. Example:
{"message":"Response validation failed: failed schema validation","code":"SCHE
Am I please able to have some help in resolving these issues?
Many thanks,
Wilfred
EDIT: I have raised an issue on swagger-node-runner regarding two of the above:
apigee-127/swagger-node-runner#48
If I can still find some guidance on returning swagger generated errors from controllers that would be a big help.
I'm a little perplexed. I cannot seem to find the documentation regarding swagger error handling. I have searched in all the usual places for answers to my questions without delving into the code, combed through the docs, and searched for keywords. All I found were seemingly outdated solutions. Perhaps I missed something.
My problem is - when I get a validation error it comes as an ugly JSON response with my request buffer attached. How do developers opt out, or modify this error object?
I am using a project generated with
swagger project create, withexpress.I also want to be able to generate a valid swagger error from within a controller, as we used to be able to do with
swagger-express. Something likehttps://github.com/swagger-api/swagger-node/tree/2.0.x
Where has this functionality gone?
If that fails, I want to handle errors in the express way - with error handling middleware - but this doesn't seem to work.. I want to choose what I surface to API consumers.
And the final thing, is that the swagger error responses are coming back clipped. Example:
Am I please able to have some help in resolving these issues?
Many thanks,
Wilfred
EDIT: I have raised an issue on
swagger-node-runnerregarding two of the above:apigee-127/swagger-node-runner#48
If I can still find some guidance on returning swagger generated errors from controllers that would be a big help.