File tree Expand file tree Collapse file tree 3 files changed +81
-0
lines changed
samples/client/petstore/rust/reqwest/petstore Expand file tree Collapse file tree 3 files changed +81
-0
lines changed Original file line number Diff line number Diff line change 1206
1206
<module >samples/client/petstore/c</module >
1207
1207
<module >samples/client/petstore/cpp-qt5</module >
1208
1208
<module >samples/client/petstore/rust</module >
1209
+ <module >samples/client/petstore/rust/reqwest/petstore</module >
1209
1210
<!-- <module>samples/client/petstore/perl</module>-->
1210
1211
<module >samples/client/petstore/php/OpenAPIClient-php</module >
1211
1212
<module >samples/openapi3/client/petstore/php/OpenAPIClient-php</module >
Original file line number Diff line number Diff line change
1
+ <project >
2
+ <modelVersion >4.0.0</modelVersion >
3
+ <groupId >org.openapitools</groupId >
4
+ <artifactId >RustReqwestClientTests</artifactId >
5
+ <packaging >pom</packaging >
6
+ <version >1.0-SNAPSHOT</version >
7
+ <name >Rust Reqwest Petstore Client</name >
8
+ <build >
9
+ <plugins >
10
+ <plugin >
11
+ <artifactId >maven-dependency-plugin</artifactId >
12
+ <executions >
13
+ <execution >
14
+ <phase >package</phase >
15
+ <goals >
16
+ <goal >copy-dependencies</goal >
17
+ </goals >
18
+ <configuration >
19
+ <outputDirectory >${project.build.directory} </outputDirectory >
20
+ </configuration >
21
+ </execution >
22
+ </executions >
23
+ </plugin >
24
+ <plugin >
25
+ <groupId >org.codehaus.mojo</groupId >
26
+ <artifactId >exec-maven-plugin</artifactId >
27
+ <version >1.2.1</version >
28
+ <executions >
29
+ <execution >
30
+ <id >bundle-test</id >
31
+ <phase >integration-test</phase >
32
+ <goals >
33
+ <goal >exec</goal >
34
+ </goals >
35
+ <configuration >
36
+ <executable >cargo</executable >
37
+ <arguments >
38
+ <argument >test</argument >
39
+ </arguments >
40
+ </configuration >
41
+ </execution >
42
+ </executions >
43
+ </plugin >
44
+ </plugins >
45
+ </build >
46
+ </project >
Original file line number Diff line number Diff line change
1
+ extern crate petstore_reqwest;
2
+ use petstore_reqwest:: apis:: PetApi ;
3
+ use petstore_reqwest:: apis:: PetApiClient ;
4
+ use petstore_reqwest:: apis:: configuration;
5
+ //use petstore_reqwest::apis::PetApiUpdatePetWithFormParams;
6
+ use petstore_reqwest:: models:: { Pet } ;
7
+ use std:: option:: Option ;
8
+ use std:: rc:: Rc ;
9
+
10
+ #[ test]
11
+ fn test_pet ( ) {
12
+ let config = configuration:: Configuration :: new ( ) ;
13
+ let pet_api_client = PetApiClient :: new ( Rc :: new ( config) ) ;
14
+
15
+ // create pet object
16
+ let photo_urls = vec ! [ "https://11" . to_string( ) , "https://22" . to_string( ) ] ;
17
+ let mut new_pet = Pet :: new ( "Rust Pet" . to_string ( ) , photo_urls) ;
18
+ new_pet. id = Option :: Some ( 8787 ) ;
19
+
20
+ // add pet
21
+ let _add_result = pet_api_client. add_pet ( new_pet) ;
22
+
23
+ // get pet
24
+ let pet_result = pet_api_client. get_pet_by_id ( 8787 ) ;
25
+
26
+ let _pet_result = match pet_result {
27
+ Ok ( pet) => {
28
+ assert_eq ! ( pet. id, Option :: Some ( 8787 ) ) ;
29
+ assert_eq ! ( pet. name, "Rust Pet" ) ;
30
+ assert_eq ! ( pet. photo_urls, vec![ "https://11" . to_string( ) , "https://22" . to_string( ) ] ) ;
31
+ } ,
32
+ Err ( error) => println ! ( "error: {:?}" , error) ,
33
+ } ;
34
+ }
You can’t perform that action at this time.
0 commit comments