Skip to content

Commit eb793ae

Browse files
authored
[rust] Make it easier to test rust client generator (#3543)
As we discovered in #3463, there are various bits of the rust client generator that are currently untested. This PR adds tests for various generator-specific types, and also files. Follows the example of the rust-server generator for making it easy to add new test specs. This should make it easier for future contributors to make sure that their contributions are tested
1 parent 5f6e53f commit eb793ae

File tree

134 files changed

+2064
-174
lines changed

Some content is hidden

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

134 files changed

+2064
-174
lines changed

bin/rust-petstore.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate -t modules/openapi-generator/src/main/resources/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust --additional-properties packageName=petstore_client --library=hyper $@"
3130

32-
java ${JAVA_OPTS} -jar ${executable} ${ags}
31+
for spec_path in \
32+
modules/openapi-generator/src/test/resources/2_0/petstore.yaml \
33+
modules/openapi-generator/src/test/resources/3_0/rust/rust-test.yaml \
34+
modules/openapi-generator/src/test/resources/2_0/fileResponseTest.json\
35+
; do
36+
spec=$(basename "$spec_path" | sed 's/.yaml//' | sed 's/.json//' )
37+
38+
for library in hyper reqwest; do
39+
args="generate --template-dir modules/openapi-generator/src/main/resources/rust
40+
--input-spec $spec_path
41+
--generator-name rust
42+
--output samples/client/petstore/rust/$library/$spec
43+
--additional-properties packageName=${spec}-${library}
44+
--library=$library $@"
45+
java ${JAVA_OPTS} -jar ${executable} ${args} || exit 1
46+
done
47+
done

bin/rust-reqwest-petstore.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
openapi: 3.0.1
2+
info:
3+
title: Rust client test spec
4+
description: Special testing for the Rust client generator
5+
version: 1.0.7
6+
paths:
7+
/dummy:
8+
get:
9+
summary: A dummy endpoint to make the spec valid.
10+
responses:
11+
'200':
12+
description: Success
13+
components:
14+
schemas:
15+
TypeTesting:
16+
description: Test handling of differing types (see \#3463)
17+
type: object
18+
properties:
19+
integer:
20+
type: integer
21+
long:
22+
type: long
23+
number:
24+
type: number
25+
float:
26+
type: float
27+
double:
28+
type: double
29+
uuid:
30+
type: string
31+
format: uuid

pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,6 @@
10391039
<!-- <module>samples/client/petstore/cpp-qt5</module> -->
10401040
<module>samples/client/petstore/elm-0.18</module>
10411041
<module>samples/client/petstore/rust</module>
1042-
<module>samples/client/petstore/rust-reqwest</module>
10431042
<!--<module>samples/client/petstore/perl</module>-->
10441043
<module>samples/client/petstore/php/OpenAPIClient-php</module>
10451044
<module>samples/openapi3/client/petstore/php/OpenAPIClient-php</module>

samples/client/petstore/rust-reqwest/.openapi-generator/VERSION.orig

Lines changed: 0 additions & 1 deletion
This file was deleted.

samples/client/petstore/rust-reqwest/pom.xml

Lines changed: 0 additions & 46 deletions
This file was deleted.

samples/client/petstore/rust-reqwest/src/apis/client.rs.orig

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
/target/
2-
**/*.rs.bk
1+
target
32
Cargo.lock

samples/client/petstore/rust/.openapi-generator/VERSION.orig

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,2 @@
1-
[package]
2-
name = "petstore_client"
3-
version = "1.0.0"
4-
authors = ["OpenAPI Generator team and contributors"]
5-
6-
[dependencies]
7-
serde = "^1.0"
8-
serde_derive = "^1.0"
9-
serde_json = "^1.0"
10-
url = "1.5"
11-
hyper = "~0.11"
12-
serde_yaml = "0.7"
13-
base64 = "~0.7.0"
14-
futures = "0.1.23"
15-
16-
[dev-dependencies]
17-
tokio-core = "*"
1+
[workspace]
2+
members = ["hyper/*", "reqwest/*"]

0 commit comments

Comments
 (0)