I have swagger/openapi v3.0.3 specification, and I need to generate server stubs in Actix or Axum? What would be the best way to do it. I've been struggling to use currently available generator from official openapi generators, which generates server stubs in hyper, but I find it extremely difficult to add async middlewares to it. Please guide me.
Honestly any other framework will do, but tide, hyper, warp are not some I want to work with,
And from there, the answer! Reproduced below for future reference:
once you've got the hyper interface, you can wrap it in axum via the tower service trait.
Tower::Service is a generic middleware layer for literally anything that has a request and a response. Axum is built on Tower.
One use for it is that in AWS lambda an HTTP request/response is represented as a hunk of JSON. So using Tower you can hook Axum up to this JSON representation of an http request Axum can process and can reply in the JSON representation of the response. Axum doesn't need to know the difference, and it's not even sending something over a local network socket. Conversion happens in memory and largely at compile time.
Similarly, you can just do the same thing with other web servers. You can just use a tower service to wrap a hyper server in Axum.
tower and it's extensible abstractions to the rescue yet again.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.