From d4decd4728ef086f04d5194aac70fd0785c6a8b9 Mon Sep 17 00:00:00 2001 From: Adam Leventhal Date: Mon, 22 Apr 2024 09:51:38 -0700 Subject: [PATCH] Mock code doesn't compile if path parameters are renamed (#782) --- progenitor-impl/src/httpmock.rs | 8 ++++++-- progenitor-impl/tests/output/src/buildomat_builder.rs | 4 ++-- .../tests/output/src/buildomat_builder_tagged.rs | 4 ++-- progenitor-impl/tests/output/src/buildomat_positional.rs | 2 +- sample_openapi/buildomat.json | 4 ++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/progenitor-impl/src/httpmock.rs b/progenitor-impl/src/httpmock.rs index 1d1f19e..4b0dbbc 100644 --- a/progenitor-impl/src/httpmock.rs +++ b/progenitor-impl/src/httpmock.rs @@ -161,7 +161,11 @@ impl Generator { // can specify a prescribed value for that parameter. let when_methods = method.params.iter().map( |OperationParameter { - name, typ, kind, .. + name, + typ, + kind, + api_name, + description: _, }| { let arg_type_name = match typ { OperationParameterType::Type(arg_type_id) => self @@ -187,7 +191,7 @@ impl Generator { let name_ident = format_ident!("{}", name); let handler = match kind { OperationParameterKind::Path => { - let re_fmt = method.path.as_wildcard_param(name); + let re_fmt = method.path.as_wildcard_param(api_name); quote! { let re = regex::Regex::new( &format!(#re_fmt, value.to_string()) diff --git a/progenitor-impl/tests/output/src/buildomat_builder.rs b/progenitor-impl/tests/output/src/buildomat_builder.rs index c42c730..047a105 100644 --- a/progenitor-impl/tests/output/src/buildomat_builder.rs +++ b/progenitor-impl/tests/output/src/buildomat_builder.rs @@ -2174,7 +2174,7 @@ impl Client { builder::ControlResume::new(self) } - ///Sends a `GET` request to `/v1/task/{task}` + ///Sends a `GET` request to `/v1/task/{Task}` /// ///```ignore /// let response = client.task_get() @@ -2478,7 +2478,7 @@ pub mod builder { self } - ///Sends a `GET` request to `/v1/task/{task}` + ///Sends a `GET` request to `/v1/task/{Task}` pub async fn send(self) -> Result, Error<()>> { let Self { client, task } = self; let task = task.map_err(Error::InvalidRequest)?; diff --git a/progenitor-impl/tests/output/src/buildomat_builder_tagged.rs b/progenitor-impl/tests/output/src/buildomat_builder_tagged.rs index 0759090..d1407ee 100644 --- a/progenitor-impl/tests/output/src/buildomat_builder_tagged.rs +++ b/progenitor-impl/tests/output/src/buildomat_builder_tagged.rs @@ -2174,7 +2174,7 @@ impl Client { builder::ControlResume::new(self) } - ///Sends a `GET` request to `/v1/task/{task}` + ///Sends a `GET` request to `/v1/task/{Task}` /// ///```ignore /// let response = client.task_get() @@ -2478,7 +2478,7 @@ pub mod builder { self } - ///Sends a `GET` request to `/v1/task/{task}` + ///Sends a `GET` request to `/v1/task/{Task}` pub async fn send(self) -> Result, Error<()>> { let Self { client, task } = self; let task = task.map_err(Error::InvalidRequest)?; diff --git a/progenitor-impl/tests/output/src/buildomat_positional.rs b/progenitor-impl/tests/output/src/buildomat_positional.rs index 55f2307..1e799a1 100644 --- a/progenitor-impl/tests/output/src/buildomat_positional.rs +++ b/progenitor-impl/tests/output/src/buildomat_positional.rs @@ -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>( &'a self, task: &'a str, diff --git a/sample_openapi/buildomat.json b/sample_openapi/buildomat.json index 0803561..e11fa42 100644 --- a/sample_openapi/buildomat.json +++ b/sample_openapi/buildomat.json @@ -34,13 +34,13 @@ } } }, - "/v1/task/{task}": { + "/v1/task/{Task}": { "get": { "operationId": "task_get", "parameters": [ { "in": "path", - "name": "task", + "name": "Task", "required": true, "schema": { "type": "string"