Skip to content

Commit 2f03c70

Browse files
authored
[rust] Add tests for path parameters (#20325)
* add tests for path parameter in rust client * add tests and update samples
1 parent 3a09ebb commit 2f03c70

File tree

31 files changed

+71
-71
lines changed

31 files changed

+71
-71
lines changed

modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,15 +566,15 @@ paths:
566566
description: User not found
567567
security:
568568
- api_key: []
569-
'/fake/user/{username}':
569+
'/fake/user/{user-name}':
570570
get:
571571
tags:
572572
- fake
573573
summary: To test nullable required parameters
574574
description: ''
575575
operationId: test_nullable_required_param
576576
parameters:
577-
- name: username
577+
- name: user-name
578578
in: path
579579
description: The name that needs to be fetched. Use user1 for testing.
580580
required: true

samples/client/petstore/rust/hyper/petstore/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ All URIs are relative to *http://petstore.swagger.io/v2*
2626

2727
Class | Method | HTTP request | Description
2828
------------ | ------------- | ------------- | -------------
29-
*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **Get** /fake/user/{username} | To test nullable required parameters
29+
*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **Get** /fake/user/{user_name} | To test nullable required parameters
3030
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **Post** /pet | Add a new pet to the store
3131
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **Delete** /pet/{petId} | Deletes a pet
3232
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **Get** /pet/findByStatus | Finds Pets by status

samples/client/petstore/rust/hyper/petstore/docs/FakeApi.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ All URIs are relative to *http://petstore.swagger.io/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **Get** /fake/user/{username} | To test nullable required parameters
7+
[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **Get** /fake/user/{user_name} | To test nullable required parameters
88

99

1010

1111
## test_nullable_required_param
1212

13-
> test_nullable_required_param(username, dummy_required_nullable_param, uppercase)
13+
> test_nullable_required_param(user_name, dummy_required_nullable_param, uppercase)
1414
To test nullable required parameters
1515

1616

@@ -20,7 +20,7 @@ To test nullable required parameters
2020

2121
Name | Type | Description | Required | Notes
2222
------------- | ------------- | ------------- | ------------- | -------------
23-
**username** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] |
23+
**user_name** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] |
2424
**dummy_required_nullable_param** | Option<**String**> | To test nullable required parameters | [required] |
2525
**uppercase** | Option<**String**> | To test parameter names in upper case | |
2626

samples/client/petstore/rust/hyper/petstore/src/apis/fake_api.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ impl<C: Connect> FakeApiClient<C>
3737
}
3838

3939
pub trait FakeApi: Send + Sync {
40-
fn test_nullable_required_param(&self, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
40+
fn test_nullable_required_param(&self, user_name: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
4141
}
4242

4343
impl<C: Connect>FakeApi for FakeApiClient<C>
4444
where C: Clone + std::marker::Send + Sync {
4545
#[allow(unused_mut)]
46-
fn test_nullable_required_param(&self, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
47-
let mut req = __internal_request::Request::new(hyper::Method::GET, "/fake/user/{username}".to_string())
46+
fn test_nullable_required_param(&self, user_name: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
47+
let mut req = __internal_request::Request::new(hyper::Method::GET, "/fake/user/{user_name}".to_string())
4848
;
49-
req = req.with_path_param("username".to_string(), username.to_string());
49+
req = req.with_path_param("user_name".to_string(), user_name.to_string());
5050
match dummy_required_nullable_param {
5151
Some(param_value) => { req = req.with_header_param("dummy_required_nullable_param".to_string(), param_value.to_string()); },
5252
None => { req = req.with_header_param("dummy_required_nullable_param".to_string(), "".to_string()); },

samples/client/petstore/rust/hyper0x/petstore/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ All URIs are relative to *http://petstore.swagger.io/v2*
2626

2727
Class | Method | HTTP request | Description
2828
------------ | ------------- | ------------- | -------------
29-
*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{username} | To test nullable required parameters
29+
*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{user_name} | To test nullable required parameters
3030
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
3131
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
3232
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status

samples/client/petstore/rust/hyper0x/petstore/docs/FakeApi.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ All URIs are relative to *http://petstore.swagger.io/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{username} | To test nullable required parameters
7+
[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{user_name} | To test nullable required parameters
88

99

1010

1111
## test_nullable_required_param
1212

13-
> test_nullable_required_param(username, dummy_required_nullable_param, uppercase)
13+
> test_nullable_required_param(user_name, dummy_required_nullable_param, uppercase)
1414
To test nullable required parameters
1515

1616

@@ -20,7 +20,7 @@ To test nullable required parameters
2020

2121
Name | Type | Description | Required | Notes
2222
------------- | ------------- | ------------- | ------------- | -------------
23-
**username** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] |
23+
**user_name** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] |
2424
**dummy_required_nullable_param** | Option<**String**> | To test nullable required parameters | [required] |
2525
**uppercase** | Option<**String**> | To test parameter names in upper case | |
2626

samples/client/petstore/rust/hyper0x/petstore/src/apis/fake_api.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ impl<C: hyper::client::connect::Connect> FakeApiClient<C>
3636
}
3737

3838
pub trait FakeApi {
39-
fn test_nullable_required_param(&self, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
39+
fn test_nullable_required_param(&self, user_name: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
4040
}
4141

4242
impl<C: hyper::client::connect::Connect>FakeApi for FakeApiClient<C>
4343
where C: Clone + std::marker::Send + Sync {
4444
#[allow(unused_mut)]
45-
fn test_nullable_required_param(&self, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
46-
let mut req = __internal_request::Request::new(hyper::Method::GET, "/fake/user/{username}".to_string())
45+
fn test_nullable_required_param(&self, user_name: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
46+
let mut req = __internal_request::Request::new(hyper::Method::GET, "/fake/user/{user_name}".to_string())
4747
;
48-
req = req.with_path_param("username".to_string(), username.to_string());
48+
req = req.with_path_param("user_name".to_string(), user_name.to_string());
4949
match dummy_required_nullable_param {
5050
Some(param_value) => { req = req.with_header_param("dummy_required_nullable_param".to_string(), param_value.to_string()); },
5151
None => { req = req.with_header_param("dummy_required_nullable_param".to_string(), "".to_string()); },

samples/client/petstore/rust/reqwest-trait/petstore/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ All URIs are relative to *http://petstore.swagger.io/v2*
2626

2727
Class | Method | HTTP request | Description
2828
------------ | ------------- | ------------- | -------------
29-
*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{username} | To test nullable required parameters
29+
*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{user_name} | To test nullable required parameters
3030
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
3131
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
3232
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status

samples/client/petstore/rust/reqwest-trait/petstore/docs/FakeApi.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ All URIs are relative to *http://petstore.swagger.io/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{username} | To test nullable required parameters
7+
[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{user_name} | To test nullable required parameters
88

99

1010

1111
## test_nullable_required_param
1212

13-
> test_nullable_required_param(username, dummy_required_nullable_param, uppercase)
13+
> test_nullable_required_param(user_name, dummy_required_nullable_param, uppercase)
1414
To test nullable required parameters
1515

1616

@@ -20,7 +20,7 @@ To test nullable required parameters
2020

2121
Name | Type | Description | Required | Notes
2222
------------- | ------------- | ------------- | ------------- | -------------
23-
**username** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] |
23+
**user_name** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] |
2424
**dummy_required_nullable_param** | Option<**String**> | To test nullable required parameters | [required] |
2525
**uppercase** | Option<**String**> | To test parameter names in upper case | |
2626

samples/client/petstore/rust/reqwest-trait/petstore/src/apis/fake_api.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use super::{Error, configuration};
2121
#[cfg_attr(feature = "mockall", automock)]
2222
#[async_trait]
2323
pub trait FakeApi: Send + Sync {
24-
async fn test_nullable_required_param<'username, 'dummy_required_nullable_param, 'uppercase>(&self, username: &'username str, dummy_required_nullable_param: Option<&'dummy_required_nullable_param str>, uppercase: Option<&'uppercase str>) -> Result<(), Error<TestNullableRequiredParamError>>;
24+
async fn test_nullable_required_param<'user_name, 'dummy_required_nullable_param, 'uppercase>(&self, user_name: &'user_name str, dummy_required_nullable_param: Option<&'dummy_required_nullable_param str>, uppercase: Option<&'uppercase str>) -> Result<(), Error<TestNullableRequiredParamError>>;
2525
}
2626

2727
pub struct FakeApiClient {
@@ -39,12 +39,12 @@ impl FakeApiClient {
3939
#[async_trait]
4040
impl FakeApi for FakeApiClient {
4141
///
42-
async fn test_nullable_required_param<'username, 'dummy_required_nullable_param, 'uppercase>(&self, username: &'username str, dummy_required_nullable_param: Option<&'dummy_required_nullable_param str>, uppercase: Option<&'uppercase str>) -> Result<(), Error<TestNullableRequiredParamError>> {
42+
async fn test_nullable_required_param<'user_name, 'dummy_required_nullable_param, 'uppercase>(&self, user_name: &'user_name str, dummy_required_nullable_param: Option<&'dummy_required_nullable_param str>, uppercase: Option<&'uppercase str>) -> Result<(), Error<TestNullableRequiredParamError>> {
4343
let local_var_configuration = &self.configuration;
4444

4545
let local_var_client = &local_var_configuration.client;
4646

47-
let local_var_uri_str = format!("{}/fake/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username));
47+
let local_var_uri_str = format!("{}/fake/user/{user_name}", local_var_configuration.base_path, user_name=crate::apis::urlencode(user_name));
4848
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
4949

5050
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {

0 commit comments

Comments
 (0)