oapi-codegen
oapi-codegen copied to clipboard
feat: allow round trip middleware per operation
Reference implementation to cater to the use-cases I described in #150
Notes
Fixes https://github.com/deepmap/oapi-codegen/issues/150
This is exactly the use case I have, so I would love to see a complete example in your pseudo-su /golang-service-template repo
@StevenACoffman I haven't forgotten about this, you make a good point about examples... I might actually add some more tests cases to this PR that would also help somewhat in capturing examples.
I have a few open PRs for oapi-codegen
that may or may not get merged. I was trying to avoid it because I'm lazy but I might merge them all into my forked repo and add a branch to pseudo-su /golang-service-template
with examples.
My preference was to get things merged (where possible) before spending too much time messing about with a temporary fork.
@deepmap-marcinr This one is ready too!
@pseudo-su Hmmm, I think your rebase you need to regenerate because now there's some test failures.
I need to fix some things and add those example/tests I mentioned, working on it now
Ok @StevenACoffman three main things changed and this should be good now.
- joinMiddleware had an issue when passing an empty list of middleware to join (picked up by the new tests from master 🎉 ).
- I've added tests in
internal/test/client/client_test.go
that have scenarios whereWithSharedRoundTripMiddleware
andWithRoundTripMiddleware
are used with a mock "interceptor". - I fixed the spec in
internal/test/client/client.yaml
because the responses were missing thecontent
field inbetween the status code and the content-type
EG it was this
responses:
200:
application/json:
instead of
responses:
200:
content:
application/json:
Thanks, yes, this works for us in our client. Nice improvement! @deepmap-marcinr Ready for you!
What is the status of this PR? Is there any other way to set custom behavior?
@StevenACoffman @pseudo-su
@oapi-codegen any reason why this wasn't approved/merged (aside from the current merge conflicts)?