Mock code doesn't compile if path parameters are renamed (#782)

This commit is contained in:
Adam Leventhal 2024-04-22 09:51:38 -07:00 committed by GitHub
parent 3a76093e7b
commit d4decd4728
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 9 deletions

View File

@ -161,7 +161,11 @@ impl Generator {
// can specify a prescribed value for that parameter. // can specify a prescribed value for that parameter.
let when_methods = method.params.iter().map( let when_methods = method.params.iter().map(
|OperationParameter { |OperationParameter {
name, typ, kind, .. name,
typ,
kind,
api_name,
description: _,
}| { }| {
let arg_type_name = match typ { let arg_type_name = match typ {
OperationParameterType::Type(arg_type_id) => self OperationParameterType::Type(arg_type_id) => self
@ -187,7 +191,7 @@ impl Generator {
let name_ident = format_ident!("{}", name); let name_ident = format_ident!("{}", name);
let handler = match kind { let handler = match kind {
OperationParameterKind::Path => { OperationParameterKind::Path => {
let re_fmt = method.path.as_wildcard_param(name); let re_fmt = method.path.as_wildcard_param(api_name);
quote! { quote! {
let re = regex::Regex::new( let re = regex::Regex::new(
&format!(#re_fmt, value.to_string()) &format!(#re_fmt, value.to_string())

View File

@ -2174,7 +2174,7 @@ impl Client {
builder::ControlResume::new(self) builder::ControlResume::new(self)
} }
///Sends a `GET` request to `/v1/task/{task}` ///Sends a `GET` request to `/v1/task/{Task}`
/// ///
///```ignore ///```ignore
/// let response = client.task_get() /// let response = client.task_get()
@ -2478,7 +2478,7 @@ pub mod builder {
self self
} }
///Sends a `GET` request to `/v1/task/{task}` ///Sends a `GET` request to `/v1/task/{Task}`
pub async fn send(self) -> Result<ResponseValue<types::Task>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<types::Task>, Error<()>> {
let Self { client, task } = self; let Self { client, task } = self;
let task = task.map_err(Error::InvalidRequest)?; let task = task.map_err(Error::InvalidRequest)?;

View File

@ -2174,7 +2174,7 @@ impl Client {
builder::ControlResume::new(self) builder::ControlResume::new(self)
} }
///Sends a `GET` request to `/v1/task/{task}` ///Sends a `GET` request to `/v1/task/{Task}`
/// ///
///```ignore ///```ignore
/// let response = client.task_get() /// let response = client.task_get()
@ -2478,7 +2478,7 @@ pub mod builder {
self self
} }
///Sends a `GET` request to `/v1/task/{task}` ///Sends a `GET` request to `/v1/task/{Task}`
pub async fn send(self) -> Result<ResponseValue<types::Task>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<types::Task>, Error<()>> {
let Self { client, task } = self; let Self { client, task } = self;
let task = task.map_err(Error::InvalidRequest)?; let task = task.map_err(Error::InvalidRequest)?;

View File

@ -858,7 +858,7 @@ impl Client {
} }
} }
///Sends a `GET` request to `/v1/task/{task}` ///Sends a `GET` request to `/v1/task/{Task}`
pub async fn task_get<'a>( pub async fn task_get<'a>(
&'a self, &'a self,
task: &'a str, task: &'a str,

View File

@ -34,13 +34,13 @@
} }
} }
}, },
"/v1/task/{task}": { "/v1/task/{Task}": {
"get": { "get": {
"operationId": "task_get", "operationId": "task_get",
"parameters": [ "parameters": [
{ {
"in": "path", "in": "path",
"name": "task", "name": "Task",
"required": true, "required": true,
"schema": { "schema": {
"type": "string" "type": "string"