Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,8 @@ impl {{classname}} for {{classname}}Client {
{{/isModel}}
{{#isMap}}
if let Some(ref param_value) = {{{paramName}}} {
let mut query_params = Vec::with_capacity(param_value.len());
for (key, value) in param_value.iter() {
query_params.push((key.to_string(), serde_json::to_string(value)?));
}
local_var_req_builder = local_var_req_builder.query(&query_params);
let params = crate::apis::parse_deep_object("{{{baseName}}}", &serde_json::to_value(param_value)?);
local_var_req_builder = local_var_req_builder.query(&params);
}
{{/isMap}}
{{/isExplode}}
Expand Down Expand Up @@ -256,11 +253,8 @@ impl {{classname}} for {{classname}}Client {
local_var_req_builder = local_var_req_builder.query(&param_value);
{{/isModel}}
{{#isMap}}
let mut query_params = Vec::with_capacity(param_value.len());
for (key, value) in param_value.iter() {
query_params.push((key.to_string(), serde_json::to_string(value)?));
}
local_var_req_builder = local_var_req_builder.query(&query_params);
let params = crate::apis::parse_deep_object("{{{baseName}}}", &serde_json::to_value(param_value)?);
local_var_req_builder = local_var_req_builder.query(&params);
{{/isMap}}
{{/isExplode}}
{{/isDeepObject}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,8 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
req_builder = req_builder.query(&param_value);
{{/isModel}}
{{#isMap}}
let mut query_params = Vec::with_capacity(param_value.len());
for (key, value) in param_value.iter() {
query_params.push((key.to_string(), serde_json::to_string(value)?));
}
req_builder = req_builder.query(&query_params);
let params = crate::apis::parse_deep_object("{{{baseName}}}", &serde_json::to_value(param_value)?);
req_builder = req_builder.query(&params);
{{/isMap}}
{{/isExplode}}
};
Expand Down Expand Up @@ -251,11 +248,8 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
req_builder = req_builder.query(&param_value);
{{/isModel}}
{{#isMap}}
let mut query_params = Vec::with_capacity(param_value.len());
for (key, value) in param_value.iter() {
query_params.push((key.to_string(), serde_json::to_string(value)?));
}
req_builder = req_builder.query(&query_params);
let params = crate::apis::parse_deep_object("{{{baseName}}}", &serde_json::to_value(param_value)?);
req_builder = req_builder.query(&params);
{{/isMap}}
{{/isExplode}}
{{/isDeepObject}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,31 @@ public void testIntegerPropertyEnum() throws IOException {
TestUtils.assertFileNotContains(outputPath, linearize("#[serde(rename = \"0\")]"));
}

@Test
public void testExplodedDeepObjectMapQueryParams() throws IOException {
// exploded deepObject maps (typed or free-form) go through parse_deep_object like the non-explode branch
for (String library : new String[] {"reqwest", "reqwest-trait"}) {
Path target = Files.createTempDirectory("test");
target.toFile().deleteOnExit();
final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("rust")
.setLibrary(library)
.setInputSpec("src/test/resources/3_0/rust/deep-object-free-form-query-param.yaml")
.setSkipOverwrite(false)
.setOutputDir(target.toAbsolutePath().toString().replace("\\", "/"));
List<File> files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate();
files.forEach(File::deleteOnExit);
Path outputPath = Path.of(target.toString(), "/src/apis/default_api.rs");
TestUtils.assertFileExists(outputPath);
// optional typed map, optional free-form object, required-nullable typed map
TestUtils.assertFileContains(outputPath, "crate::apis::parse_deep_object(\"filter\"");
TestUtils.assertFileContains(outputPath, "crate::apis::parse_deep_object(\"extra\"");
TestUtils.assertFileContains(outputPath, "crate::apis::parse_deep_object(\"scope\"");
TestUtils.assertFileNotContains(outputPath, "param_value.len()");
TestUtils.assertFileNotContains(outputPath, "param_value.iter()");
}
}

@Test
public void testArrayWithObjectEnumValues() throws IOException {
Path target = Files.createTempDirectory("test");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
openapi: 3.0.3
info:
title: deep object params
version: 1.0.0
paths:
/items:
get:
operationId: listItems
parameters:
- name: filter
in: query
style: deepObject
explode: true
schema:
type: object
additionalProperties:
type: string
- name: extra
in: query
style: deepObject
explode: true
schema:
type: object
- name: scope
in: query
required: true
style: deepObject
explode: true
schema:
type: object
nullable: true
additionalProperties:
type: string
responses:
'200':
description: ok
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,39 @@ paths:
type: array
items:
$ref: '#/components/schemas/ModelWithInlineEnum'

'/tests/deep-object-free-form-query-param':
get:
tags:
- testing
parameters:
- name: filter
in: query
style: deepObject
explode: true
schema:
type: object
additionalProperties:
type: string
- name: extra
in: query
style: deepObject
explode: true
schema:
type: object
- name: scope
in: query
required: true
style: deepObject
explode: true
schema:
type: object
nullable: true
additionalProperties:
type: string
responses:
'200':
description: ok
externalDocs:
description: Find out more about Swagger
url: 'http://swagger.io'
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/rust/hyper/petstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Class | Method | HTTP request | Description
*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **Get** /store/order/{orderId} | Find purchase order by ID
*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **Post** /store/order | Place an order for a pet
*TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **Get** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500)
*TestingApi* | [**tests_deep_object_free_form_query_param_get**](docs/TestingApi.md#tests_deep_object_free_form_query_param_get) | **Get** /tests/deep-object-free-form-query-param |
*TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **Get** /tests/fileResponse | Returns an image file
*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **Get** /tests/inlineEnumBoxing | Get model with inline enums
*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **Post** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors
Expand Down
31 changes: 31 additions & 0 deletions samples/client/petstore/rust/hyper/petstore/docs/TestingApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All URIs are relative to *http://localhost/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **Get** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500)
[**tests_deep_object_free_form_query_param_get**](TestingApi.md#tests_deep_object_free_form_query_param_get) | **Get** /tests/deep-object-free-form-query-param |
[**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **Get** /tests/fileResponse | Returns an image file
[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **Get** /tests/inlineEnumBoxing | Get model with inline enums
[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **Post** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors
Expand Down Expand Up @@ -40,6 +41,36 @@ No authorization required
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)


## tests_deep_object_free_form_query_param_get

> tests_deep_object_free_form_query_param_get(scope, filter, extra)


### Parameters


Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**scope** | Option<[**std::collections::HashMap<String, String>**](String.md)> | | [required] |
**filter** | Option<[**std::collections::HashMap<String, String>**](String.md)> | | |
**extra** | Option<[**serde_json::Value**](SerdeJson__Value.md)> | | |

### Return type

(empty response body)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: Not defined

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)


## tests_file_response_get

> std::path::PathBuf tests_file_response_get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ impl<C: Connect> TestingApiClient<C>

pub trait TestingApi: Send + Sync {
fn tests_all_of_with_one_model_get(&self, person: models::Person) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send>>;
fn tests_deep_object_free_form_query_param_get(&self, scope: Option<std::collections::HashMap<String, String>>, filter: Option<std::collections::HashMap<String, String>>, extra: Option<models::serde_json::Value>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
fn tests_file_response_get(&self, ) -> Pin<Box<dyn Future<Output = Result<std::path::PathBuf, Error>> + Send>>;
fn tests_inline_enum_boxing_get(&self, status: Option<&str>) -> Pin<Box<dyn Future<Output = Result<Vec<models::ModelWithInlineEnum>, Error>> + Send>>;
fn tests_inline_enum_boxing_post(&self, model_with_inline_enum: models::ModelWithInlineEnum) -> Pin<Box<dyn Future<Output = Result<models::ModelWithInlineEnum, Error>> + Send>>;
Expand All @@ -55,6 +56,33 @@ impl<C: Connect>TestingApi for TestingApiClient<C>
req.execute(self.configuration.borrow())
}

#[allow(unused_mut)]
fn tests_deep_object_free_form_query_param_get(&self, scope: Option<std::collections::HashMap<String, String>>, filter: Option<std::collections::HashMap<String, String>>, extra: Option<models::serde_json::Value>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/deep-object-free-form-query-param".to_string())
;
if let Some(ref s) = filter {
let query_value = match serde_json::to_string(s) {
Ok(value) => value,
Err(e) => return Box::pin(futures::future::err(Error::Serde(e))),
};
req = req.with_query_param("filter".to_string(), query_value);
}
if let Some(ref s) = extra {
let query_value = match serde_json::to_string(s) {
Ok(value) => value,
Err(e) => return Box::pin(futures::future::err(Error::Serde(e))),
};
req = req.with_query_param("extra".to_string(), query_value);
}
match scope {
Some(param_value) => { req = req.with_query_param("scope".to_string(), param_value.to_string()); },
None => { req = req.with_query_param("scope".to_string(), "".to_string()); },
}
req = req.returns_nothing();

req.execute(self.configuration.borrow())
}

#[allow(unused_mut)]
fn tests_file_response_get(&self, ) -> Pin<Box<dyn Future<Output = Result<std::path::PathBuf, Error>> + Send>> {
let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/fileResponse".to_string())
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/rust/hyper0x/petstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Class | Method | HTTP request | Description
*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID
*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet
*TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500)
*TestingApi* | [**tests_deep_object_free_form_query_param_get**](docs/TestingApi.md#tests_deep_object_free_form_query_param_get) | **GET** /tests/deep-object-free-form-query-param |
*TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file
*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums
*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors
Expand Down
31 changes: 31 additions & 0 deletions samples/client/petstore/rust/hyper0x/petstore/docs/TestingApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All URIs are relative to *http://localhost/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500)
[**tests_deep_object_free_form_query_param_get**](TestingApi.md#tests_deep_object_free_form_query_param_get) | **GET** /tests/deep-object-free-form-query-param |
[**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file
[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums
[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors
Expand Down Expand Up @@ -40,6 +41,36 @@ No authorization required
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)


## tests_deep_object_free_form_query_param_get

> tests_deep_object_free_form_query_param_get(scope, filter, extra)


### Parameters


Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**scope** | Option<[**std::collections::HashMap<String, String>**](String.md)> | | [required] |
**filter** | Option<[**std::collections::HashMap<String, String>**](String.md)> | | |
**extra** | Option<[**serde_json::Value**](SerdeJson__Value.md)> | | |

### Return type

(empty response body)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: Not defined

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)


## tests_file_response_get

> std::path::PathBuf tests_file_response_get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ impl<C: hyper::client::connect::Connect> TestingApiClient<C>

pub trait TestingApi {
fn tests_all_of_with_one_model_get(&self, person: models::Person) -> Pin<Box<dyn Future<Output = Result<String, Error>>>>;
fn tests_deep_object_free_form_query_param_get(&self, scope: Option<std::collections::HashMap<String, String>>, filter: Option<std::collections::HashMap<String, String>>, extra: Option<models::serde_json::Value>) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
fn tests_file_response_get(&self, ) -> Pin<Box<dyn Future<Output = Result<std::path::PathBuf, Error>>>>;
fn tests_inline_enum_boxing_get(&self, status: Option<&str>) -> Pin<Box<dyn Future<Output = Result<Vec<models::ModelWithInlineEnum>, Error>>>>;
fn tests_inline_enum_boxing_post(&self, model_with_inline_enum: models::ModelWithInlineEnum) -> Pin<Box<dyn Future<Output = Result<models::ModelWithInlineEnum, Error>>>>;
Expand All @@ -54,6 +55,33 @@ impl<C: hyper::client::connect::Connect>TestingApi for TestingApiClient<C>
req.execute(self.configuration.borrow())
}

#[allow(unused_mut)]
fn tests_deep_object_free_form_query_param_get(&self, scope: Option<std::collections::HashMap<String, String>>, filter: Option<std::collections::HashMap<String, String>>, extra: Option<models::serde_json::Value>) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/deep-object-free-form-query-param".to_string())
;
if let Some(ref s) = filter {
let query_value = match serde_json::to_string(s) {
Ok(value) => value,
Err(e) => return Box::pin(futures::future::err(Error::Serde(e))),
};
req = req.with_query_param("filter".to_string(), query_value);
}
if let Some(ref s) = extra {
let query_value = match serde_json::to_string(s) {
Ok(value) => value,
Err(e) => return Box::pin(futures::future::err(Error::Serde(e))),
};
req = req.with_query_param("extra".to_string(), query_value);
}
match scope {
Some(param_value) => { req = req.with_query_param("scope".to_string(), param_value.to_string()); },
None => { req = req.with_query_param("scope".to_string(), "".to_string()); },
}
req = req.returns_nothing();

req.execute(self.configuration.borrow())
}

#[allow(unused_mut)]
fn tests_file_response_get(&self, ) -> Pin<Box<dyn Future<Output = Result<std::path::PathBuf, Error>>>> {
let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/fileResponse".to_string())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Class | Method | HTTP request | Description
*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID
*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet
*TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500)
*TestingApi* | [**tests_deep_object_free_form_query_param_get**](docs/TestingApi.md#tests_deep_object_free_form_query_param_get) | **GET** /tests/deep-object-free-form-query-param |
*TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file
*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums
*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors
Expand Down
Loading
Loading