Skip to content

Commit

Permalink
add tests for path parameter in rust client
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Dec 14, 2024
1 parent 8aa8e38 commit 394bd7d
Show file tree
Hide file tree
Showing 31 changed files with 71 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -566,15 +566,15 @@ paths:
description: User not found
security:
- api_key: []
'/fake/user/{username}':
'/fake/user/{user-name}':
get:
tags:
- fake
summary: To test nullable required parameters
description: ''
operationId: test_nullable_required_param
parameters:
- name: username
- name: user-name
in: path
description: The name that needs to be fetched. Use user1 for testing.
required: true
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/rust/hyper/petstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions samples/client/petstore/rust/hyper/petstore/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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 | |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()); },
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/rust/hyper0x/petstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions samples/client/petstore/rust/hyper0x/petstore/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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 | |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ impl<C: hyper::client::connect::Connect> FakeApiClient<C>
}

pub trait FakeApi {
fn test_nullable_required_param(&self, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
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>>>>;
}

impl<C: hyper::client::connect::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>>>> {
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>>>> {
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()); },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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 | |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::{Error, configuration};
#[cfg_attr(feature = "mockall", automock)]
#[async_trait]
pub trait FakeApi: Send + Sync {
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>>;
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>>;
}

pub struct FakeApiClient {
Expand All @@ -39,12 +39,12 @@ impl FakeApiClient {
#[async_trait]
impl FakeApi for FakeApiClient {
///
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>> {
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>> {
let local_var_configuration = &self.configuration;

let local_var_client = &local_var_configuration.client;

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

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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 | |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::{Error, configuration};
#[derive(Clone, Debug)]
pub struct TestNullableRequiredParamParams {
/// The name that needs to be fetched. Use user1 for testing.
pub username: String,
pub user_name: String,
/// To test nullable required parameters
pub dummy_required_nullable_param: Option<String>,
/// To test parameter names in upper case
Expand Down Expand Up @@ -49,14 +49,14 @@ pub async fn test_nullable_required_param(configuration: &configuration::Configu
let local_var_configuration = configuration;

// unbox the parameters
let username = params.username;
let user_name = params.user_name;
let dummy_required_nullable_param = params.dummy_required_nullable_param;
let uppercase = params.uppercase;


let local_var_client = &local_var_configuration.client;

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

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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 | |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::{Error, configuration};
#[derive(Clone, Debug)]
pub struct TestNullableRequiredParamParams {
/// The name that needs to be fetched. Use user1 for testing.
pub username: String,
pub user_name: String,
/// To test nullable required parameters
pub dummy_required_nullable_param: Option<String>,
/// To test parameter names in upper case
Expand Down Expand Up @@ -49,14 +49,14 @@ pub async fn test_nullable_required_param(configuration: &configuration::Configu
let local_var_configuration = configuration;

// unbox the parameters
let username = params.username;
let user_name = params.user_name;
let dummy_required_nullable_param = params.dummy_required_nullable_param;
let uppercase = params.uppercase;


let local_var_client = &local_var_configuration.client;

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

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 394bd7d

Please sign in to comment.