make the OpenAPI info.version field accessible through the generated client (#400)

This commit is contained in:
Adam Leventhal 2023-03-29 23:02:17 -07:00 committed by GitHub
parent 94db6ff74f
commit 4eb8cd6c21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 256 additions and 45 deletions

View File

@ -289,12 +289,25 @@ impl Generator {
} }
}); });
let client_docstring = if let Some(description) = &spec.info.description let client_docstring = {
{ let mut s = format!("Client for {}", spec.info.title);
format!("Client for {}\n\n{}", spec.info.title, description)
} else { if let Some(ss) = &spec.info.description {
format!("Client for {}", spec.info.title) s.push_str("\n\n");
s.push_str(ss);
}
if let Some(ss) = &spec.info.terms_of_service {
s.push_str("\n\n");
s.push_str(ss);
}
s.push_str(&format!("\n\nVersion: {}", &spec.info.version));
s
}; };
let version_str = &spec.info.version;
let file = quote! { let file = quote! {
// Re-export ResponseValue and Error since those are used by the // Re-export ResponseValue and Error since those are used by the
// public interface of Client. // public interface of Client.
@ -359,16 +372,24 @@ impl Generator {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
#version_str
}
#maybe_inner #maybe_inner
} }

View File

@ -1577,6 +1577,8 @@ pub mod types {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
///Client for Buildomat ///Client for Buildomat
///
///Version: 1.0
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -1611,15 +1613,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"1.0"
}
} }
impl Client { impl Client {

View File

@ -1577,6 +1577,8 @@ pub mod types {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
///Client for Buildomat ///Client for Buildomat
///
///Version: 1.0
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -1611,15 +1613,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"1.0"
}
} }
impl Client { impl Client {

View File

@ -252,6 +252,8 @@ pub mod types {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
///Client for Buildomat ///Client for Buildomat
///
///Version: 1.0
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -286,15 +288,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"1.0"
}
} }
impl Client { impl Client {

View File

@ -902,6 +902,8 @@ pub mod types {
///Client for Keeper API ///Client for Keeper API
/// ///
///report execution of cron jobs through a mechanism other than mail ///report execution of cron jobs through a mechanism other than mail
///
///Version: 1.0
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -936,15 +938,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"1.0"
}
} }
impl Client { impl Client {

View File

@ -902,6 +902,8 @@ pub mod types {
///Client for Keeper API ///Client for Keeper API
/// ///
///report execution of cron jobs through a mechanism other than mail ///report execution of cron jobs through a mechanism other than mail
///
///Version: 1.0
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -936,15 +938,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"1.0"
}
} }
impl Client { impl Client {

View File

@ -141,6 +141,8 @@ pub mod types {
///Client for Keeper API ///Client for Keeper API
/// ///
///report execution of cron jobs through a mechanism other than mail ///report execution of cron jobs through a mechanism other than mail
///
///Version: 1.0
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -175,15 +177,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"1.0"
}
} }
impl Client { impl Client {

View File

@ -17034,6 +17034,8 @@ pub mod types {
///Client for Oxide Region API ///Client for Oxide Region API
/// ///
///API for interacting with the Oxide control plane ///API for interacting with the Oxide control plane
///
///Version: 0.0.1
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -17068,15 +17070,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"0.0.1"
}
} }
pub trait ClientDisksExt { pub trait ClientDisksExt {

View File

@ -17090,6 +17090,8 @@ pub mod types {
///Client for Oxide Region API ///Client for Oxide Region API
/// ///
///API for interacting with the Oxide control plane ///API for interacting with the Oxide control plane
///
///Version: 0.0.1
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -17124,15 +17126,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"0.0.1"
}
} }
impl Client { impl Client {

View File

@ -5862,6 +5862,8 @@ pub mod types {
///Client for Oxide Region API ///Client for Oxide Region API
/// ///
///API for interacting with the Oxide control plane ///API for interacting with the Oxide control plane
///
///Version: 0.0.1
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -5896,15 +5898,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"0.0.1"
}
} }
impl Client { impl Client {

View File

@ -13,6 +13,8 @@ pub mod types {
///Client for Parameter override test ///Client for Parameter override test
/// ///
///Minimal API for testing parameter overrides ///Minimal API for testing parameter overrides
///
///Version: v1
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -47,15 +49,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"v1"
}
} }
impl Client { impl Client {

View File

@ -13,6 +13,8 @@ pub mod types {
///Client for Parameter override test ///Client for Parameter override test
/// ///
///Minimal API for testing parameter overrides ///Minimal API for testing parameter overrides
///
///Version: v1
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -47,15 +49,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"v1"
}
} }
impl Client { impl Client {

View File

@ -13,6 +13,8 @@ pub mod types {
///Client for Parameter override test ///Client for Parameter override test
/// ///
///Minimal API for testing parameter overrides ///Minimal API for testing parameter overrides
///
///Version: v1
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -47,15 +49,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"v1"
}
} }
impl Client { impl Client {

View File

@ -1955,6 +1955,8 @@ pub mod types {
///Client for Oxide Propolis Server API ///Client for Oxide Propolis Server API
/// ///
///API for interacting with the Propolis hypervisor frontend. ///API for interacting with the Propolis hypervisor frontend.
///
///Version: 0.0.1
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -1989,15 +1991,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"0.0.1"
}
} }
impl Client { impl Client {

View File

@ -1961,6 +1961,8 @@ pub mod types {
///Client for Oxide Propolis Server API ///Client for Oxide Propolis Server API
/// ///
///API for interacting with the Propolis hypervisor frontend. ///API for interacting with the Propolis hypervisor frontend.
///
///Version: 0.0.1
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -1995,15 +1997,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"0.0.1"
}
} }
impl Client { impl Client {

View File

@ -608,6 +608,8 @@ pub mod types {
///Client for Oxide Propolis Server API ///Client for Oxide Propolis Server API
/// ///
///API for interacting with the Propolis hypervisor frontend. ///API for interacting with the Propolis hypervisor frontend.
///
///Version: 0.0.1
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -642,15 +644,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"0.0.1"
}
} }
impl Client { impl Client {

View File

@ -226,6 +226,8 @@ pub mod types {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
///Client for pagination-demo ///Client for pagination-demo
///
///Version: 9000
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -260,15 +262,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"9000"
}
} }
impl Client { impl Client {

View File

@ -56,6 +56,8 @@ pub mod types {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
///Client for pagination-demo ///Client for pagination-demo
///
///Version: 9000
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -90,15 +92,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"9000"
}
} }
impl Client { impl Client {

View File

@ -25,6 +25,8 @@ pub mod types {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
///Client for pagination-demo ///Client for pagination-demo
///
///Version: 9000
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -59,15 +61,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"9000"
}
} }
impl Client { impl Client {

View File

@ -25,6 +25,8 @@ pub mod types {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
///Client for pagination-demo ///Client for pagination-demo
///
///Version: 9000
pub struct Client { pub struct Client {
pub(crate) baseurl: String, pub(crate) baseurl: String,
pub(crate) client: reqwest::Client, pub(crate) client: reqwest::Client,
@ -59,15 +61,23 @@ impl Client {
} }
} }
/// Return the base URL to which requests are made. /// Get the base URL to which requests are made.
pub fn baseurl(&self) -> &String { pub fn baseurl(&self) -> &String {
&self.baseurl &self.baseurl
} }
/// Return the internal `reqwest::Client` used to make requests. /// Get the internal `reqwest::Client` used to make requests.
pub fn client(&self) -> &reqwest::Client { pub fn client(&self) -> &reqwest::Client {
&self.client &self.client
} }
/// Get the version of this API.
///
/// This string is pulled directly from the source OpenAPI
/// document and may be in any format the API selects.
pub fn api_version(&self) -> &'static str {
"9000"
}
} }
impl Client { impl Client {