From ba189e632305b6fba0a0c95da702fe76eeb924b5 Mon Sep 17 00:00:00 2001 From: bnaecker Date: Sat, 7 Jan 2023 18:05:33 -0800 Subject: [PATCH] Add docstrings to the generated Client (#295) - Add docstring to the `Client`, based on the OpenAPI title and description, if provided. - Add docstrings to the constructors and getters shared by all generated clients. - Update expectorate tests. - Small typo-fix in README. --- README.md | 4 ++-- progenitor-impl/src/lib.rs | 20 +++++++++++++++++++ .../tests/output/buildomat-builder-tagged.out | 14 +++++++++++++ .../tests/output/buildomat-builder.out | 14 +++++++++++++ .../tests/output/buildomat-positional.out | 14 +++++++++++++ .../tests/output/keeper-builder-tagged.out | 16 +++++++++++++++ .../tests/output/keeper-builder.out | 16 +++++++++++++++ .../tests/output/keeper-positional.out | 16 +++++++++++++++ .../tests/output/nexus-builder-tagged.out | 16 +++++++++++++++ .../tests/output/nexus-builder.out | 16 +++++++++++++++ .../tests/output/nexus-positional.out | 16 +++++++++++++++ .../output/param-overrides-builder-tagged.out | 16 +++++++++++++++ .../tests/output/param-overrides-builder.out | 16 +++++++++++++++ .../output/param-overrides-positional.out | 16 +++++++++++++++ .../output/propolis-server-builder-tagged.out | 16 +++++++++++++++ .../tests/output/propolis-server-builder.out | 16 +++++++++++++++ .../output/propolis-server-positional.out | 16 +++++++++++++++ .../output/test_default_params_builder.out | 14 +++++++++++++ .../output/test_default_params_positional.out | 14 +++++++++++++ .../tests/output/test_freeform_response.out | 14 +++++++++++++ .../tests/output/test_renamed_parameters.out | 14 +++++++++++++ 21 files changed, 312 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 80e70cf..3953251 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ You'll need to add the following to `Cargo.toml`: ```diff [dependencies] -+futures = 0.3 ++futures = "0.3" +progenitor = { git = "https://github.com/oxidecomputer/progenitor" } +reqwest = { version = "0.11", features = ["json", "stream"] } +serde = { version = "1.0", features = ["derive"] } @@ -115,7 +115,7 @@ You'll need to add add the following to `Cargo.toml`: ```diff [dependencies] -+futures = 0.3 ++futures = "0.3" +progenitor-client = { git = "https://github.com/oxidecomputer/progenitor" } +reqwest = { version = "0.11", features = ["json", "stream"] } +serde = { version = "1.0", features = ["derive"] } diff --git a/progenitor-impl/src/lib.rs b/progenitor-impl/src/lib.rs index 0442c4b..2bba830 100644 --- a/progenitor-impl/src/lib.rs +++ b/progenitor-impl/src/lib.rs @@ -255,6 +255,12 @@ impl Generator { } }); + let client_docstring = if let Some(description) = &spec.info.description + { + format!("Client for {}\n\n{}", spec.info.title, description) + } else { + format!("Client for {}", spec.info.title) + }; let file = quote! { // Re-export ResponseValue and Error since those are used by the // public interface of Client. @@ -275,6 +281,7 @@ impl Generator { } #[derive(Clone, Debug)] + #[doc = #client_docstring] pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, @@ -282,6 +289,11 @@ impl Generator { } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new( baseurl: &str, #inner_parameter @@ -295,6 +307,12 @@ impl Generator { Self::new_with_client(baseurl, client, #inner_value) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client( baseurl: &str, client: reqwest::Client, @@ -307,10 +325,12 @@ impl Generator { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/buildomat-builder-tagged.out b/progenitor-impl/tests/output/buildomat-builder-tagged.out index 17528d4..b6bd125 100644 --- a/progenitor-impl/tests/output/buildomat-builder-tagged.out +++ b/progenitor-impl/tests/output/buildomat-builder-tagged.out @@ -1268,12 +1268,18 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Buildomat pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -1284,6 +1290,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -1291,10 +1303,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/buildomat-builder.out b/progenitor-impl/tests/output/buildomat-builder.out index 89f981c..ab2990a 100644 --- a/progenitor-impl/tests/output/buildomat-builder.out +++ b/progenitor-impl/tests/output/buildomat-builder.out @@ -1268,12 +1268,18 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Buildomat pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -1284,6 +1290,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -1291,10 +1303,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/buildomat-positional.out b/progenitor-impl/tests/output/buildomat-positional.out index 29cddc6..7ceb9dd 100644 --- a/progenitor-impl/tests/output/buildomat-positional.out +++ b/progenitor-impl/tests/output/buildomat-positional.out @@ -137,12 +137,18 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Buildomat pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -153,6 +159,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -160,10 +172,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/keeper-builder-tagged.out b/progenitor-impl/tests/output/keeper-builder-tagged.out index fd664ec..f49d7eb 100644 --- a/progenitor-impl/tests/output/keeper-builder-tagged.out +++ b/progenitor-impl/tests/output/keeper-builder-tagged.out @@ -730,12 +730,20 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Keeper API +/// +///report execution of cron jobs through a mechanism other than mail pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -746,6 +754,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -753,10 +767,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/keeper-builder.out b/progenitor-impl/tests/output/keeper-builder.out index e797509..4f06901 100644 --- a/progenitor-impl/tests/output/keeper-builder.out +++ b/progenitor-impl/tests/output/keeper-builder.out @@ -730,12 +730,20 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Keeper API +/// +///report execution of cron jobs through a mechanism other than mail pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -746,6 +754,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -753,10 +767,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/keeper-positional.out b/progenitor-impl/tests/output/keeper-positional.out index 17b078e..fdeda5e 100644 --- a/progenitor-impl/tests/output/keeper-positional.out +++ b/progenitor-impl/tests/output/keeper-positional.out @@ -78,12 +78,20 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Keeper API +/// +///report execution of cron jobs through a mechanism other than mail pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -94,6 +102,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -101,10 +115,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/nexus-builder-tagged.out b/progenitor-impl/tests/output/nexus-builder-tagged.out index 5d98df9..fb94a67 100644 --- a/progenitor-impl/tests/output/nexus-builder-tagged.out +++ b/progenitor-impl/tests/output/nexus-builder-tagged.out @@ -11061,12 +11061,20 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Oxide Region API +/// +///API for interacting with the Oxide control plane pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -11077,6 +11085,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -11084,10 +11098,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/nexus-builder.out b/progenitor-impl/tests/output/nexus-builder.out index f668059..475abec 100644 --- a/progenitor-impl/tests/output/nexus-builder.out +++ b/progenitor-impl/tests/output/nexus-builder.out @@ -11105,12 +11105,20 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Oxide Region API +/// +///API for interacting with the Oxide control plane pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -11121,6 +11129,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -11128,10 +11142,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/nexus-positional.out b/progenitor-impl/tests/output/nexus-positional.out index 5ad6ad4..b5c1780 100644 --- a/progenitor-impl/tests/output/nexus-positional.out +++ b/progenitor-impl/tests/output/nexus-positional.out @@ -2956,12 +2956,20 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Oxide Region API +/// +///API for interacting with the Oxide control plane pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -2972,6 +2980,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -2979,10 +2993,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/param-overrides-builder-tagged.out b/progenitor-impl/tests/output/param-overrides-builder-tagged.out index c389c40..ff26b01 100644 --- a/progenitor-impl/tests/output/param-overrides-builder-tagged.out +++ b/progenitor-impl/tests/output/param-overrides-builder-tagged.out @@ -10,12 +10,20 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Parameter override test +/// +///Minimal API for testing parameter overrides pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -26,6 +34,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -33,10 +47,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/param-overrides-builder.out b/progenitor-impl/tests/output/param-overrides-builder.out index 1122fbf..1cf3918 100644 --- a/progenitor-impl/tests/output/param-overrides-builder.out +++ b/progenitor-impl/tests/output/param-overrides-builder.out @@ -10,12 +10,20 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Parameter override test +/// +///Minimal API for testing parameter overrides pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -26,6 +34,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -33,10 +47,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/param-overrides-positional.out b/progenitor-impl/tests/output/param-overrides-positional.out index 7f382e2..3153bdf 100644 --- a/progenitor-impl/tests/output/param-overrides-positional.out +++ b/progenitor-impl/tests/output/param-overrides-positional.out @@ -10,12 +10,20 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Parameter override test +/// +///Minimal API for testing parameter overrides pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -26,6 +34,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -33,10 +47,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/propolis-server-builder-tagged.out b/progenitor-impl/tests/output/propolis-server-builder-tagged.out index 2824d0a..9d05ced 100644 --- a/progenitor-impl/tests/output/propolis-server-builder-tagged.out +++ b/progenitor-impl/tests/output/propolis-server-builder-tagged.out @@ -1500,12 +1500,20 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Oxide Propolis Server API +/// +///API for interacting with the Propolis hypervisor frontend. pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -1516,6 +1524,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -1523,10 +1537,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/propolis-server-builder.out b/progenitor-impl/tests/output/propolis-server-builder.out index a840a39..0a29731 100644 --- a/progenitor-impl/tests/output/propolis-server-builder.out +++ b/progenitor-impl/tests/output/propolis-server-builder.out @@ -1506,12 +1506,20 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Oxide Propolis Server API +/// +///API for interacting with the Propolis hypervisor frontend. pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -1522,6 +1530,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -1529,10 +1543,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/propolis-server-positional.out b/progenitor-impl/tests/output/propolis-server-positional.out index 2936d81..fd3d382 100644 --- a/progenitor-impl/tests/output/propolis-server-positional.out +++ b/progenitor-impl/tests/output/propolis-server-positional.out @@ -340,12 +340,20 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for Oxide Propolis Server API +/// +///API for interacting with the Propolis hypervisor frontend. pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -356,6 +364,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -363,10 +377,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/test_default_params_builder.out b/progenitor-impl/tests/output/test_default_params_builder.out index 0f0a53b..8fee80d 100644 --- a/progenitor-impl/tests/output/test_default_params_builder.out +++ b/progenitor-impl/tests/output/test_default_params_builder.out @@ -190,12 +190,18 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for pagination-demo pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -206,6 +212,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -213,10 +225,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/test_default_params_positional.out b/progenitor-impl/tests/output/test_default_params_positional.out index e406afe..c0a06f8 100644 --- a/progenitor-impl/tests/output/test_default_params_positional.out +++ b/progenitor-impl/tests/output/test_default_params_positional.out @@ -43,12 +43,18 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for pagination-demo pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -59,6 +65,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -66,10 +78,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/test_freeform_response.out b/progenitor-impl/tests/output/test_freeform_response.out index 6241b64..6fb8a12 100644 --- a/progenitor-impl/tests/output/test_freeform_response.out +++ b/progenitor-impl/tests/output/test_freeform_response.out @@ -18,12 +18,18 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for pagination-demo pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -34,6 +40,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -41,10 +53,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client } diff --git a/progenitor-impl/tests/output/test_renamed_parameters.out b/progenitor-impl/tests/output/test_renamed_parameters.out index 33c3588..8aa0c60 100644 --- a/progenitor-impl/tests/output/test_renamed_parameters.out +++ b/progenitor-impl/tests/output/test_renamed_parameters.out @@ -18,12 +18,18 @@ pub mod types { } #[derive(Clone, Debug)] +///Client for pagination-demo pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, } impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new(baseurl: &str) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -34,6 +40,12 @@ impl Client { Self::new_with_client(baseurl, client) } + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { Self { baseurl: baseurl.to_string(), @@ -41,10 +53,12 @@ impl Client { } } + /// Return the base URL to which requests are made. pub fn baseurl(&self) -> &String { &self.baseurl } + /// Return the internal `reqwest::Client` used to make requests. pub fn client(&self) -> &reqwest::Client { &self.client }