[rust] Add tests for path parameters (#20325)

* add tests for path parameter in rust client

* add tests and update samples
This commit is contained in:
William Cheng
2024-12-14 13:50:11 +08:00
committed by GitHub
parent 3a09ebbb7b
commit 2f03c70403
31 changed files with 71 additions and 71 deletions

View File

@@ -26,7 +26,7 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **Get** /fake/user/{username} | To test nullable required parameters
*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **Get** /fake/user/{user_name} | To test nullable required parameters
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **Post** /pet | Add a new pet to the store
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **Delete** /pet/{petId} | Deletes a pet
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **Get** /pet/findByStatus | Finds Pets by status

View File

@@ -4,13 +4,13 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **Get** /fake/user/{username} | To test nullable required parameters
[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **Get** /fake/user/{user_name} | To test nullable required parameters
## test_nullable_required_param
> test_nullable_required_param(username, dummy_required_nullable_param, uppercase)
> test_nullable_required_param(user_name, dummy_required_nullable_param, uppercase)
To test nullable required parameters
@@ -20,7 +20,7 @@ To test nullable required parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**username** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] |
**user_name** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] |
**dummy_required_nullable_param** | Option<**String**> | To test nullable required parameters | [required] |
**uppercase** | Option<**String**> | To test parameter names in upper case | |

View File

@@ -37,16 +37,16 @@ impl<C: Connect> FakeApiClient<C>
}
pub trait FakeApi: Send + Sync {
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>>;
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>>;
}
impl<C: Connect>FakeApi for FakeApiClient<C>
where C: Clone + std::marker::Send + Sync {
#[allow(unused_mut)]
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>> {
let mut req = __internal_request::Request::new(hyper::Method::GET, "/fake/user/{username}".to_string())
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>> {
let mut req = __internal_request::Request::new(hyper::Method::GET, "/fake/user/{user_name}".to_string())
;
req = req.with_path_param("username".to_string(), username.to_string());
req = req.with_path_param("user_name".to_string(), user_name.to_string());
match dummy_required_nullable_param {
Some(param_value) => { req = req.with_header_param("dummy_required_nullable_param".to_string(), param_value.to_string()); },
None => { req = req.with_header_param("dummy_required_nullable_param".to_string(), "".to_string()); },