Open sergeysova opened 4 years ago
Just a note, you can bypass whole extractor/handler subsystem with https://github.com/actix/actix-web/blob/master/src/web.rs#L271
and WebService is just wrapper for Service
https://github.com/actix/actix-web/blob/master/src/service.rs#L424
you can use any T
as service, it just needs to implement
Service<Config = (), Request = ServiceRequest, Response = ServiceResponse, Error = Error>
https://t.me/rustlang_ru/285259 https://teleg.one/rustlang_ru/285259 (Russian)
Translated: made a sufficient version of the code generator for actix_swagger. Generates this: https://github.com/sergeysova/actix-swagger/blob/master/cargo-swagg/out.rs.
In principle, it's enough to write applications, I have about this kind of communication. But there is no execution of the contract of request handlers here. There is no obligation to correctly process the request body in the handler. I could not find a way to do it through
actix_web::dev::Factory
.Here is a discussion issue: https://github.com/actix/actix-web/pull/1339.
By actix-swagger: I will now write a conversion of yaml structures to the code generator format. Most likely there will be a HashMap/BTreeMap bundle to correctly resolve links. The first implementation will be very stupid and will be able to work only with links in requestBody, params and so on. There will also be no support for importing from files.
What do you need help with?
Project goals: To input the openapi3 specification, to get the generated code at the output that does not need to be corrected by hand. At the same time, you may commit it into the repo and watch changes in the guitar after manual re-generation. You can take it to a separate crate, re-generate it into ci and deploy the crate of the new version. Update it in the project when it is convenient.
How to use:
actix_swagger::Response
is used as theactix_web::Response
analogue with explicit response types to verify that the request handler implements the contract.We have to figure this out:
how to get the request handler to execute the contract on the request body, query, and headers.
I was thinking of making my analogue actix_web::dev::Factory, the so-called BoundFactory. Which would prescribe the implementation for Fn. BoundFactory is a trait that requires a function to have several mandatory parameters for specific types.
In this way, handlers could have the first arguments of clear types, such as request_body: request_bodies::Example, query: session_create::Query, and the rest of the arguments would be derived types, so you can pull out the necessary things, such as actix_web::web::Data.
But I'm relying on the privacy of Handler - https://github.com/actix/actix-web/pull/1339.
I did not understand how to implement BoundFactory or even achieve the goal through Handle trait (https://github.com/actix/actix-web/pull/1275).
I'd be so grateful for any help.