Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The swagger-validator has hard dependency on BodyHandler to parse the body to object into attachement #18

Closed
stevehu opened this issue Sep 18, 2017 · 1 comment

Comments

@stevehu
Copy link
Contributor

stevehu commented Sep 18, 2017

In order to do schema validation for request body against swagger specification body definition, we have body validator in swagger-validator module. However, it depends on the BodyHandler to parse the body stream into map/list and put the Java object into an exchange attachment. This will require that BodyHandler must be existed in the request/response chain before RequestValidator. In the light-proxy imeplementation, we cannot consume the body it should be proxied downstream to the backend. Once BodyHandler is disabled, the RequestValidator output and error message that complain the body is missing for post etc. This needs to be resolved to break this kind of hard dependency. What if somebody miss the BodyHandler in their request chain?

The solution is to check if body attachment exists in the exchange or not to decide if body validator is called or not. It means that Body validation is skipped silently if BodyHandler is not working. In order to remind developer the behaviour, an warning log message will be write to the log.

@stevehu
Copy link
Contributor Author

stevehu commented Sep 18, 2017

The following warning will be shown in the log as warning.

Body object doesn't exist in exchange attachment. Most likely the BodyHandler is not in the request chain before RequestValidator or reqeust misses application/json content type header

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant