-
Notifications
You must be signed in to change notification settings - Fork 24
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
Question / feature proposal: Using the validator with httptest.ResponseRecorder
#40
Comments
I guess I could pass in a |
Hi Jamie, I'm not quite sure what you mean, would you be able to help me understand? I'd be happy to help add in support to allow you get this working, I just need more help understanding the use case. |
http.HandlerFunc
httptest.ResponseRecorder
Hey, thank you! That'll teach me from raising an issue on mobile 😅 I'd originally phrased the question correctly, then second-guessed myself, and amended it. I've amended the description to note that I'm actually trying to use this with |
I can't see why not, I used the |
Still learning how to use libopenapi for testing but this example seems to work: Specific snippet: // 7. Validate!
valid, validationErrs := docValidator.ValidateHttpRequestResponse(request, recorder.Result()) |
I'm looking at adding libopenapi to https://gitlab.com/jamietanna/httptest-openapi, a library I've got for writing (unit) tests with Go's
net/http
handlers by validating the response matches an OpenAPI spec.I've looked at using this library to give me full OpenAPI 3.0 and 3.1 support, instead of Kin's OpenAPI 3.0 only, but noticed that I couldn't use it right away.
In the test code i.e. https://gitlab.com/jamietanna/httptest-openapi/-/blob/v0.3.0/openapi3/validator.go?ref_type=tags#L95 we only have access to a
httptest.ResponseRecorder
whereas the library expects anhttp.Response
.Would it be of interest to add support for providing a
httptest.ResponseRecorder
or should I instead look at how to convert between the two types?The text was updated successfully, but these errors were encountered: