Skip to content

Commit 0509909

Browse files
committed
[rust] add tests for rust deep objects
1 parent c8bb57f commit 0509909

File tree

112 files changed

+2922
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+2922
-5
lines changed

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

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,49 @@ tags:
1818
- name: user
1919
description: Operations about user
2020
paths:
21+
/pets:
22+
post:
23+
tags:
24+
- pet
25+
summary: List all pets
26+
description: Returns a list of pets
27+
parameters:
28+
- name: page
29+
in: query
30+
description: The page number
31+
required: false
32+
schema:
33+
$ref: '#/components/schemas/Page'
34+
responses:
35+
'200':
36+
description: A list of pets
37+
content:
38+
application/json:
39+
schema:
40+
type: array
41+
items:
42+
$ref: '#/components/schemas/Pet'
43+
'400':
44+
description: Invalid page number
45+
/pets/explode:
46+
post:
47+
tags:
48+
- pet
49+
summary: List all pets
50+
description: Returns a list of pets
51+
parameters:
52+
- $ref: '#/components/parameters/PageExplode'
53+
responses:
54+
'200':
55+
description: A list of pets
56+
content:
57+
application/json:
58+
schema:
59+
type: array
60+
items:
61+
$ref: '#/components/schemas/Pet'
62+
'400':
63+
description: Invalid page number
2164
/pet:
2265
post:
2366
tags:
@@ -1120,3 +1163,22 @@ components:
11201163
oneOf:
11211164
- $ref: '#/components/schemas/Order'
11221165
- $ref: '#/components/schemas/Order'
1166+
Page:
1167+
type: object
1168+
properties:
1169+
page:
1170+
type: integer
1171+
format: int32
1172+
perPage:
1173+
type: integer
1174+
format: int32
1175+
parameters:
1176+
PageExplode:
1177+
name: pageExplode
1178+
in: query
1179+
description: Object containing page `size` and page `number`.
1180+
required: false
1181+
style: deepObject
1182+
explode: true
1183+
schema:
1184+
$ref: '#/components/schemas/Page'

samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ docs/NullableArray.md
1616
docs/NumericEnumTesting.md
1717
docs/OptionalTesting.md
1818
docs/Order.md
19+
docs/Page.md
1920
docs/Person.md
2021
docs/Pet.md
2122
docs/PetApi.md
@@ -61,6 +62,7 @@ src/models/nullable_array.rs
6162
src/models/numeric_enum_testing.rs
6263
src/models/optional_testing.rs
6364
src/models/order.rs
65+
src/models/page.rs
6466
src/models/person.rs
6567
src/models/pet.rs
6668
src/models/property_test.rs

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Class | Method | HTTP request | Description
3232
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **Get** /pet/findByStatus | Finds Pets by status
3333
*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **Get** /pet/findByTags | Finds Pets by tags
3434
*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **Get** /pet/{petId} | Find pet by ID
35+
*PetApi* | [**pets_explode_post**](docs/PetApi.md#pets_explode_post) | **Post** /pets/explode | List all pets
36+
*PetApi* | [**pets_post**](docs/PetApi.md#pets_post) | **Post** /pets | List all pets
3537
*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **Put** /pet | Update an existing pet
3638
*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **Post** /pet/{petId} | Updates a pet in the store with form data
3739
*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **Post** /pet/{petId}/uploadImage | uploads an image
@@ -68,6 +70,7 @@ Class | Method | HTTP request | Description
6870
- [NumericEnumTesting](docs/NumericEnumTesting.md)
6971
- [OptionalTesting](docs/OptionalTesting.md)
7072
- [Order](docs/Order.md)
73+
- [Page](docs/Page.md)
7174
- [Person](docs/Person.md)
7275
- [Pet](docs/Pet.md)
7376
- [PropertyTest](docs/PropertyTest.md)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Page
2+
3+
## Properties
4+
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**page** | Option<**i32**> | | [optional]
8+
**per_page** | Option<**i32**> | | [optional]
9+
10+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
11+
12+

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

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Method | HTTP request | Description
99
[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **Get** /pet/findByStatus | Finds Pets by status
1010
[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **Get** /pet/findByTags | Finds Pets by tags
1111
[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **Get** /pet/{petId} | Find pet by ID
12+
[**pets_explode_post**](PetApi.md#pets_explode_post) | **Post** /pets/explode | List all pets
13+
[**pets_post**](PetApi.md#pets_post) | **Post** /pets | List all pets
1214
[**update_pet**](PetApi.md#update_pet) | **Put** /pet | Update an existing pet
1315
[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **Post** /pet/{petId} | Updates a pet in the store with form data
1416
[**upload_file**](PetApi.md#upload_file) | **Post** /pet/{petId}/uploadImage | uploads an image
@@ -167,6 +169,66 @@ Name | Type | Description | Required | Notes
167169
[[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)
168170

169171

172+
## pets_explode_post
173+
174+
> Vec<models::Pet> pets_explode_post(page_explode)
175+
List all pets
176+
177+
Returns a list of pets
178+
179+
### Parameters
180+
181+
182+
Name | Type | Description | Required | Notes
183+
------------- | ------------- | ------------- | ------------- | -------------
184+
**page_explode** | Option<[**Page**](.md)> | Object containing page `size` and page `number`. | |
185+
186+
### Return type
187+
188+
[**Vec<models::Pet>**](Pet.md)
189+
190+
### Authorization
191+
192+
No authorization required
193+
194+
### HTTP request headers
195+
196+
- **Content-Type**: Not defined
197+
- **Accept**: application/json
198+
199+
[[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)
200+
201+
202+
## pets_post
203+
204+
> Vec<models::Pet> pets_post(page)
205+
List all pets
206+
207+
Returns a list of pets
208+
209+
### Parameters
210+
211+
212+
Name | Type | Description | Required | Notes
213+
------------- | ------------- | ------------- | ------------- | -------------
214+
**page** | Option<[**Page**](.md)> | The page number | |
215+
216+
### Return type
217+
218+
[**Vec<models::Pet>**](Pet.md)
219+
220+
### Authorization
221+
222+
No authorization required
223+
224+
### HTTP request headers
225+
226+
- **Content-Type**: Not defined
227+
- **Accept**: application/json
228+
229+
[[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)
230+
231+
170232
## update_pet
171233

172234
> models::Pet update_pet(pet)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# PetsExplodePostPageExplodeParameter
2+
3+
## Properties
4+
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**size** | Option<**i64**> | The page size. | [optional][default to 10]
8+
**number** | Option<**i64**> | The page number. | [optional][default to 1]
9+
10+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
11+
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# PetsExplodePostPageParameter
2+
3+
## Properties
4+
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**size** | Option<**i64**> | The page size. | [optional][default to 10]
8+
**number** | Option<**i64**> | The page number. | [optional][default to 1]
9+
10+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
11+
12+

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ pub trait PetApi: Send + Sync {
4242
fn find_pets_by_status(&self, status: Vec<String>, r#type: Option<Vec<String>>) -> Pin<Box<dyn Future<Output = Result<Vec<models::Pet>, Error>> + Send>>;
4343
fn find_pets_by_tags(&self, tags: Vec<String>) -> Pin<Box<dyn Future<Output = Result<Vec<models::Pet>, Error>> + Send>>;
4444
fn get_pet_by_id(&self, pet_id: i64) -> Pin<Box<dyn Future<Output = Result<models::Pet, Error>> + Send>>;
45+
fn pets_explode_post(&self, page_explode: Option<models::Page>) -> Pin<Box<dyn Future<Output = Result<Vec<models::Pet>, Error>> + Send>>;
46+
fn pets_post(&self, page: Option<models::Page>) -> Pin<Box<dyn Future<Output = Result<Vec<models::Pet>, Error>> + Send>>;
4547
fn update_pet(&self, pet: models::Pet) -> Pin<Box<dyn Future<Output = Result<models::Pet, Error>> + Send>>;
4648
fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
4749
fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option<std::path::PathBuf>) -> Pin<Box<dyn Future<Output = Result<models::ApiResponse, Error>> + Send>>;
@@ -111,6 +113,30 @@ impl<C: Connect>PetApi for PetApiClient<C>
111113
req.execute(self.configuration.borrow())
112114
}
113115

116+
#[allow(unused_mut)]
117+
fn pets_explode_post(&self, page_explode: Option<models::Page>) -> Pin<Box<dyn Future<Output = Result<Vec<models::Pet>, Error>> + Send>> {
118+
let mut req = __internal_request::Request::new(hyper::Method::POST, "/pets/explode".to_string())
119+
;
120+
if let Some(ref s) = page_explode {
121+
let query_value = s.to_string();
122+
req = req.with_query_param("pageExplode".to_string(), query_value);
123+
}
124+
125+
req.execute(self.configuration.borrow())
126+
}
127+
128+
#[allow(unused_mut)]
129+
fn pets_post(&self, page: Option<models::Page>) -> Pin<Box<dyn Future<Output = Result<Vec<models::Pet>, Error>> + Send>> {
130+
let mut req = __internal_request::Request::new(hyper::Method::POST, "/pets".to_string())
131+
;
132+
if let Some(ref s) = page {
133+
let query_value = s.to_string();
134+
req = req.with_query_param("page".to_string(), query_value);
135+
}
136+
137+
req.execute(self.configuration.borrow())
138+
}
139+
114140
#[allow(unused_mut)]
115141
fn update_pet(&self, pet: models::Pet) -> Pin<Box<dyn Future<Output = Result<models::Pet, Error>> + Send>> {
116142
let mut req = __internal_request::Request::new(hyper::Method::PUT, "/pet".to_string())
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* OpenAPI Petstore
3+
*
4+
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
5+
*
6+
* The version of the OpenAPI document: 1.0.0
7+
*
8+
* Generated by: https://openapi-generator.tech
9+
*/
10+
11+
use crate::models;
12+
use serde::{Deserialize, Serialize};
13+
14+
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15+
pub struct PetsExplodePostPageExplodeParameter {
16+
/// The page size.
17+
#[serde(rename = "size", skip_serializing_if = "Option::is_none")]
18+
pub size: Option<i64>,
19+
/// The page number.
20+
#[serde(rename = "number", skip_serializing_if = "Option::is_none")]
21+
pub number: Option<i64>,
22+
}
23+
24+
impl PetsExplodePostPageExplodeParameter {
25+
pub fn new() -> PetsExplodePostPageExplodeParameter {
26+
PetsExplodePostPageExplodeParameter {
27+
size: None,
28+
number: None,
29+
}
30+
}
31+
}
32+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* OpenAPI Petstore
3+
*
4+
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
5+
*
6+
* The version of the OpenAPI document: 1.0.0
7+
*
8+
* Generated by: https://openapi-generator.tech
9+
*/
10+
11+
use crate::models;
12+
use serde::{Deserialize, Serialize};
13+
14+
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15+
pub struct PetsExplodePostPageParameter {
16+
/// The page size.
17+
#[serde(rename = "size", skip_serializing_if = "Option::is_none")]
18+
pub size: Option<i64>,
19+
/// The page number.
20+
#[serde(rename = "number", skip_serializing_if = "Option::is_none")]
21+
pub number: Option<i64>,
22+
}
23+
24+
impl PetsExplodePostPageParameter {
25+
pub fn new() -> PetsExplodePostPageParameter {
26+
PetsExplodePostPageParameter {
27+
size: None,
28+
number: None,
29+
}
30+
}
31+
}
32+

samples/client/petstore/rust/hyper/petstore/src/models/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub mod optional_testing;
2424
pub use self::optional_testing::OptionalTesting;
2525
pub mod order;
2626
pub use self::order::Order;
27+
pub mod page;
28+
pub use self::page::Page;
2729
pub mod person;
2830
pub use self::person::Person;
2931
pub mod pet;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* OpenAPI Petstore
3+
*
4+
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
5+
*
6+
* The version of the OpenAPI document: 1.0.0
7+
*
8+
* Generated by: https://openapi-generator.tech
9+
*/
10+
11+
use crate::models;
12+
use serde::{Deserialize, Serialize};
13+
14+
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15+
pub struct Page {
16+
#[serde(rename = "page", skip_serializing_if = "Option::is_none")]
17+
pub page: Option<i32>,
18+
#[serde(rename = "perPage", skip_serializing_if = "Option::is_none")]
19+
pub per_page: Option<i32>,
20+
}
21+
22+
impl Page {
23+
pub fn new() -> Page {
24+
Page {
25+
page: None,
26+
per_page: None,
27+
}
28+
}
29+
}
30+

samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/FILES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ docs/NullableArray.md
1616
docs/NumericEnumTesting.md
1717
docs/OptionalTesting.md
1818
docs/Order.md
19+
docs/Page.md
1920
docs/Person.md
2021
docs/Pet.md
2122
docs/PetApi.md
@@ -59,6 +60,7 @@ src/models/nullable_array.rs
5960
src/models/numeric_enum_testing.rs
6061
src/models/optional_testing.rs
6162
src/models/order.rs
63+
src/models/page.rs
6264
src/models/person.rs
6365
src/models/pet.rs
6466
src/models/property_test.rs

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Class | Method | HTTP request | Description
3232
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
3333
*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags
3434
*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID
35+
*PetApi* | [**pets_explode_post**](docs/PetApi.md#pets_explode_post) | **POST** /pets/explode | List all pets
36+
*PetApi* | [**pets_post**](docs/PetApi.md#pets_post) | **POST** /pets | List all pets
3537
*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
3638
*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
3739
*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image
@@ -68,6 +70,7 @@ Class | Method | HTTP request | Description
6870
- [NumericEnumTesting](docs/NumericEnumTesting.md)
6971
- [OptionalTesting](docs/OptionalTesting.md)
7072
- [Order](docs/Order.md)
73+
- [Page](docs/Page.md)
7174
- [Person](docs/Person.md)
7275
- [Pet](docs/Pet.md)
7376
- [PropertyTest](docs/PropertyTest.md)

0 commit comments

Comments
 (0)