1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! Generate typed Rust traits from `OpenAPI` specifications.
//!
//! This crate exposes the [`axum`] and [`client`] attribute macros, which read
//! an `OpenAPI` specification file at compile time and generate inside the
//! annotated `mod`.
//!
//! # Examples
//!
//! ```rust
//! #[openapi_trait::axum("assets/testdata/petstore.openapi.yaml")]
//! pub mod petstore {}
//!
//! use petstore::PetstoreApi as _;
//!
//! #[derive(Clone)]
//! struct MyServer;
//!
//! #[derive(Clone)]
//! struct AppState;
//!
//! impl petstore::PetstoreApi<AppState> for MyServer {
//! type Error = std::convert::Infallible;
//!
//! async fn get_pet_by_id(
//! &self,
//! req: petstore::GetPetByIdRequest,
//! _state: axum::extract::State<AppState>,
//! _headers: axum::http::HeaderMap,
//! ) -> Result<petstore::GetPetByIdResponse, Self::Error> {
//! Ok(petstore::GetPetByIdResponse::Status200(petstore::Pet {
//! id: Some(req.pet_id),
//! name: "doggie".into(),
//! photo_urls: vec![],
//! category: None,
//! tags: None,
//! status: None,
//! }))
//! }
//! }
//!
//! let app: axum::Router = MyServer.router().with_state(AppState);
//! ```
//!
//! The generated trait names come from the annotated module name, so `mod petstore {}`
//! produces `petstore::PetstoreApi` and `petstore::PetstoreClient`.
//!
//! The `reqwest-client` feature is enabled by default. It adds [`ReqwestClient`],
//! [`ReqwestClientCore`], and the [`reqwest`] re-export used by the generated blanket
//! client implementation.
pub use openapi_trait as axum;
pub use openapi_trait as client;
/// Derive support for user-owned reqwest client carrier structs.
///
/// The derive looks for fields named `client` and `base_url` by default.
/// Override those conventions with `#[openapi_trait(client)]` and
/// `#[openapi_trait(base_url)]` on the corresponding fields.
pub use ReqwestClient;
/// Shared accessors used by generated reqwest client implementations.
pub use percent_encoding;
pub use reqwest;