Skip to content

Commit 40b9d69

Browse files
hovinenBradford Hovinen
andauthored
Support deprecated API endpoints in reqwest-based Rust clients (#22131)
Previously, if an API endpoint was marked deprecated, this fact was not reflected in the generated Rust clients using the reqwest library. We want to know exactly when our client code is using a deprecated endpoint, so marking the corresponding functions with the `#[deprecatd]` attribute would be very helpful. Uses of the endpoint would then be picked up by linters so that we can react. This adds a line to the template which marks functions generated from deprecated endpoints with the `#[deprecated]` attribute. This does not touch any of the other client generators for Rust or any other language, since they are out of scope for our needs. Co-authored-by: Bradford Hovinen <[email protected]>
1 parent 323f978 commit 40b9d69

File tree

8 files changed

+10
-0
lines changed

8 files changed

+10
-0
lines changed

modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ pub enum {{{operationIdCamelCase}}}Error {
9999
{{#notes}}
100100
/// {{{.}}}
101101
{{/notes}}
102+
{{#isDeprecated}}
103+
#[deprecated]
104+
{{/isDeprecated}}
102105
{{#vendorExtensions.x-group-parameters}}
103106
pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: &configuration::Configuration{{#allParams}}{{#-first}}, {{!
104107
### Params

samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/pet_api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ pub async fn find_pets_by_status(configuration: &configuration::Configuration, p
359359
}
360360

361361
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
362+
#[deprecated]
362363
pub async fn find_pets_by_tags(configuration: &configuration::Configuration, params: FindPetsByTagsParams) -> Result<ResponseContent<FindPetsByTagsSuccess>, Error<FindPetsByTagsError>> {
363364

364365
let uri_str = format!("{}/pet/findByTags", configuration.base_path);

samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ pub async fn find_pets_by_status(configuration: &configuration::Configuration, p
365365
}
366366

367367
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
368+
#[deprecated]
368369
pub async fn find_pets_by_tags(configuration: &configuration::Configuration, params: FindPetsByTagsParams) -> Result<ResponseContent<FindPetsByTagsSuccess>, Error<FindPetsByTagsError>> {
369370

370371
let uri_str = format!("{}/pet/findByTags", configuration.base_path);

samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ pub async fn find_pets_by_status(configuration: &configuration::Configuration, p
359359
}
360360

361361
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
362+
#[deprecated]
362363
pub async fn find_pets_by_tags(configuration: &configuration::Configuration, params: FindPetsByTagsParams) -> Result<ResponseContent<FindPetsByTagsSuccess>, Error<FindPetsByTagsError>> {
363364

364365
let uri_str = format!("{}/pet/findByTags", configuration.base_path);

samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ pub async fn find_pets_by_status(configuration: &configuration::Configuration, p
359359
}
360360

361361
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
362+
#[deprecated]
362363
pub async fn find_pets_by_tags(configuration: &configuration::Configuration, params: FindPetsByTagsParams) -> Result<ResponseContent<FindPetsByTagsSuccess>, Error<FindPetsByTagsError>> {
363364

364365
let uri_str = format!("{}/pet/findByTags", configuration.base_path);

samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/pet_api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ pub fn find_pets_by_status(configuration: &configuration::Configuration, status:
263263
}
264264

265265
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
266+
#[deprecated]
266267
pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec<String>) -> Result<Vec<models::Pet>, Error<FindPetsByTagsError>> {
267268
// add a prefix to parameters to efficiently prevent name collisions
268269
let p_query_tags = tags;

samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/pet_api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ pub fn find_pets_by_status(configuration: &configuration::Configuration, status:
224224
}
225225

226226
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
227+
#[deprecated]
227228
pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec<String>) -> Result<Vec<models::FooPet>, Error<FindPetsByTagsError>> {
228229
// add a prefix to parameters to efficiently prevent name collisions
229230
let p_query_tags = tags;

samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ pub fn find_pets_by_status(configuration: &configuration::Configuration, status:
224224
}
225225

226226
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
227+
#[deprecated]
227228
pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec<String>) -> Result<Vec<models::Pet>, Error<FindPetsByTagsError>> {
228229
// add a prefix to parameters to efficiently prevent name collisions
229230
let p_query_tags = tags;

0 commit comments

Comments
 (0)