How to write ResetableResponseServletWrapper to validate response .
Hi ,
I wasn't validate response like , so I want to extract the actual response so that I can pass this value to swagger api to validate this response.I want to implement class like ResettableRequestServletWrapper to extract response body.
Can you please post some sample? I have tried but it is not working.
Thanks in advance.
Comments (10)
-
-
FYI - Issue
#58is an open ticket for adding the sort of functionality you're talking about -
Thanks for your reply,James. Do you have any idea like when issue
#58fix will be implemented to validate response as well? Thanks in Advance. -
I dont have any plans to address it any time soon unfortunately.
If you wanted to do an implementation and raise a PR I'd happily review it. Otherwise if you comment on the ticket what your use case is and vote for it it will help me triage where I spend effort in the future.
Cheers.
-
Thanks for your reply.I want to implement response validation along with request validation. ResetableRequestServletWrapper class already provided swagger api. i'm looking ResetableResponseServletWrapper so that i can pass in Filter class like this.
filterChain.doFilter(resetableRequestServletWrapper, resetableResponseServletWrapper) Im using ContentCachingResponseWrapper but validation error response is not sent to swagger Ui.
-
Account Deactivated I have temporary implementation that directly in my project, cause of s-r-v seems to be closed for extending.
You may look solution here: https://github.com/malinink/easy-tests/tree/dev/src/main/java/easytests/swagger
In a couple of weeks I could create a PR if there are any concerned people
-
Thank you so much, malinink. It worked for me. Harinath.
-
GM malinink, Above temporary response validation implementation is committed along with any of the recent PRs? so that i can download latest jars and test it.
-
Hi.
I'm the contributor of the Spring MVC adapter. Perhaps I should address
#58soon and contribute a solution for the SRV.@jfnavin If someone has issues with the Spring MVC adapter you can address me.
Kind regards Sven
-
- changed status to resolved
Resolved in the fix for
#58- Available in v1.4.7 - Log in to comment
Hi,
I haven't looked too deeply at the Spring MVC stuff, but I would probably start by looking into using a
HandlerInterceptor
and implementing thepostHandle
method to validate the HTTP response (similar to what thecom.atlassian.oai.validator.springmvc.SwaggerValidationInterceptor
does for the request).There are examples on how the interceptor is wired up in https://bitbucket.org/atlassian/swagger-request-validator/src/master/swagger-request-validator-springmvc/src/test/java/com/atlassian/oai/validator/springmvc/example/
Hope that helps.