Skip to content

Commit 3d05d5a

Browse files
authored
Rust-server no clashing example names (#22880)
* Update rust-server examples to have namespaces by API name. Preventing warnings about clashing example names * Update rust-server-deprecated examples to have namespaces by API name. Preventing warnings about clashing example names * Fixup compilation errors * fix: Resolve bug in header parsing when parsing multi-item headers
1 parent 73dcdd6 commit 3d05d5a

33 files changed

Lines changed: 348 additions & 310 deletions

File tree

.github/workflows/samples-rust-server.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,22 @@ jobs:
4848
run: |
4949
set -e
5050
51-
# Iterate through each example and test various features
52-
for package in $(find . -maxdepth 1 -mindepth 1 -type d)
51+
# Iterate through each package and test various features
52+
for package in $(find output -maxdepth 1 -mindepth 1 -type d)
5353
do
54+
pushd $package
5455
# Not all versions have a server example
5556
if test -f examples/server/main.rs; then
56-
cargo build --example server --features="server"
57+
cargo build --example ${package##*/}-server --features="server"
58+
fi
59+
# Not all versions have a client example
60+
if test -f examples/client/main.rs; then
61+
cargo build --example ${package##*/}-client --features="client"
5762
fi
5863
# Test the CLI works if present
5964
if test -f bin/cli.rs; then
6065
cargo build --bin ${package##*/} --features cli
61-
target/debug/${package##*/} --help
66+
../../target/debug/${package##*/} --help
6267
fi
6368
# Test the validate feature if it exists
6469
if cargo read-manifest | grep -q '"validate"'; then
@@ -77,4 +82,5 @@ jobs:
7782
cargo test
7883
cargo clippy
7984
cargo doc
85+
popd
8086
done

modules/openapi-generator/src/main/resources/rust-server-deprecated/Cargo.mustache

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,13 @@ tokio-openssl = "0.6"
167167
openssl = "0.10"
168168

169169
[[example]]
170-
name = "client"
170+
name = "{{{packageName}}}-client"
171+
path = "examples/client/main.rs"
171172
required-features = ["client"]
172173

173174
[[example]]
174-
name = "server"
175+
name = "{{{packageName}}}-server"
176+
path = "examples/server/main.rs"
175177
required-features = ["server"]
176178

177179
[[bin]]

modules/openapi-generator/src/main/resources/rust-server-deprecated/README.mustache

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,20 @@ You'll find the binary at `target/release/cli`.
7171
Run examples with:
7272

7373
```
74-
cargo run --example <example-name>
74+
cargo run --example {{{packageName}}}-<client|server>
7575
```
7676

7777
To pass in arguments to the examples, put them after `--`, for example:
7878

7979
```
80-
cargo run --example client -- --help
80+
cargo run --example {{{packageName}}}-client -- --help
8181
```
8282

8383
### Running the example server
8484
To run the server, follow these simple steps:
8585

8686
```
87-
cargo run --example server
87+
cargo run --example {{{packageName}}}-server
8888
```
8989

9090
### Running the example client
@@ -97,7 +97,7 @@ To run a client, follow one of the following simple steps:
9797
{{#operation}}
9898
{{#vendorExtensions}}
9999
{{^x-no-client-example}}
100-
cargo run --example client {{{operationId}}}
100+
cargo run --example {{{packageName}}}-client {{{operationId}}}
101101
{{/x-no-client-example}}
102102
{{/vendorExtensions}}
103103
{{/operation}}
@@ -110,7 +110,7 @@ cargo run --example client {{{operationId}}}
110110
The examples can be run in HTTPS mode by passing in the flag `--https`, for example:
111111

112112
```
113-
cargo run --example server -- --https
113+
cargo run --example {{{packageName}}}-server -- --https
114114
```
115115

116116
This will use the keys/certificates from the examples directory. Note that the

modules/openapi-generator/src/main/resources/rust-server/Cargo.mustache

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,13 @@ openssl = "0.10"
191191
tokio-openssl = "0.6"
192192

193193
[[example]]
194-
name = "client"
194+
name = "{{{packageName}}}-client"
195+
path = "examples/client/main.rs"
195196
required-features = ["client"]
196197

197198
[[example]]
198-
name = "server"
199+
name = "{{{packageName}}}-server"
200+
path = "examples/server/main.rs"
199201
required-features = ["server"]
200202

201203
[[bin]]

modules/openapi-generator/src/main/resources/rust-server/README.mustache

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,20 @@ You'll find the binary at `target/release/cli`.
7171
Run examples with:
7272

7373
```
74-
cargo run --example <example-name>
74+
cargo run --example {{{packageName}}}-<client|server>
7575
```
7676

7777
To pass in arguments to the examples, put them after `--`, for example:
7878

7979
```
80-
cargo run --example client -- --help
80+
cargo run --example {{{packageName}}}-client -- --help
8181
```
8282

8383
### Running the example server
8484
To run the server, follow these simple steps:
8585

8686
```
87-
cargo run --example server
87+
cargo run --example {{{packageName}}}-server
8888
```
8989

9090
### Running the example client
@@ -97,7 +97,7 @@ To run a client, follow one of the following simple steps:
9797
{{#operation}}
9898
{{#exts}}
9999
{{^x-no-client-example}}
100-
cargo run --example client {{{operationId}}}
100+
cargo run --example {{{packageName}}}-client {{{operationId}}}
101101
{{/x-no-client-example}}
102102
{{/exts}}
103103
{{/operation}}
@@ -110,7 +110,7 @@ cargo run --example client {{{operationId}}}
110110
The examples can be run in HTTPS mode by passing in the flag `--https`, for example:
111111

112112
```
113-
cargo run --example server -- --https
113+
cargo run --example {{{packageName}}}-server -- --https
114114
```
115115

116116
This will use the keys/certificates from the examples directory. Note that the

samples/server/petstore/rust-server-deprecated/output/multipart-v3/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,13 @@ tokio-openssl = "0.6"
9393
openssl = "0.10"
9494

9595
[[example]]
96-
name = "client"
96+
name = "multipart-v3-client"
97+
path = "examples/client/main.rs"
9798
required-features = ["client"]
9899

99100
[[example]]
100-
name = "server"
101+
name = "multipart-v3-server"
102+
path = "examples/server/main.rs"
101103
required-features = ["server"]
102104

103105
[[bin]]

samples/server/petstore/rust-server-deprecated/output/multipart-v3/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,36 +66,36 @@ You'll find the binary at `target/release/cli`.
6666
Run examples with:
6767

6868
```
69-
cargo run --example <example-name>
69+
cargo run --example multipart-v3-<client|server>
7070
```
7171

7272
To pass in arguments to the examples, put them after `--`, for example:
7373

7474
```
75-
cargo run --example client -- --help
75+
cargo run --example multipart-v3-client -- --help
7676
```
7777

7878
### Running the example server
7979
To run the server, follow these simple steps:
8080

8181
```
82-
cargo run --example server
82+
cargo run --example multipart-v3-server
8383
```
8484

8585
### Running the example client
8686
To run a client, follow one of the following simple steps:
8787

8888
```
89-
cargo run --example client MultipartRelatedRequestPost
90-
cargo run --example client MultipartRequestPost
91-
cargo run --example client MultipleIdenticalMimeTypesPost
89+
cargo run --example multipart-v3-client MultipartRelatedRequestPost
90+
cargo run --example multipart-v3-client MultipartRequestPost
91+
cargo run --example multipart-v3-client MultipleIdenticalMimeTypesPost
9292
```
9393

9494
### HTTPS
9595
The examples can be run in HTTPS mode by passing in the flag `--https`, for example:
9696

9797
```
98-
cargo run --example server -- --https
98+
cargo run --example multipart-v3-server -- --https
9999
```
100100

101101
This will use the keys/certificates from the examples directory. Note that the

samples/server/petstore/rust-server-deprecated/output/no-example-v3/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ tokio-openssl = "0.6"
8383
openssl = "0.10"
8484

8585
[[example]]
86-
name = "client"
86+
name = "no-example-v3-client"
87+
path = "examples/client/main.rs"
8788
required-features = ["client"]
8889

8990
[[example]]
90-
name = "server"
91+
name = "no-example-v3-server"
92+
path = "examples/server/main.rs"
9193
required-features = ["server"]
9294

9395
[[bin]]

samples/server/petstore/rust-server-deprecated/output/no-example-v3/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,20 @@ You'll find the binary at `target/release/cli`.
6666
Run examples with:
6767

6868
```
69-
cargo run --example <example-name>
69+
cargo run --example no-example-v3-<client|server>
7070
```
7171

7272
To pass in arguments to the examples, put them after `--`, for example:
7373

7474
```
75-
cargo run --example client -- --help
75+
cargo run --example no-example-v3-client -- --help
7676
```
7777

7878
### Running the example server
7979
To run the server, follow these simple steps:
8080

8181
```
82-
cargo run --example server
82+
cargo run --example no-example-v3-server
8383
```
8484

8585
### Running the example client
@@ -92,7 +92,7 @@ To run a client, follow one of the following simple steps:
9292
The examples can be run in HTTPS mode by passing in the flag `--https`, for example:
9393

9494
```
95-
cargo run --example server -- --https
95+
cargo run --example no-example-v3-server -- --https
9696
```
9797

9898
This will use the keys/certificates from the examples directory. Note that the

samples/server/petstore/rust-server-deprecated/output/openapi-v3/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,13 @@ tokio-openssl = "0.6"
8989
openssl = "0.10"
9090

9191
[[example]]
92-
name = "client"
92+
name = "openapi-v3-client"
93+
path = "examples/client/main.rs"
9394
required-features = ["client"]
9495

9596
[[example]]
96-
name = "server"
97+
name = "openapi-v3-server"
98+
path = "examples/server/main.rs"
9799
required-features = ["server"]
98100

99101
[[bin]]

0 commit comments

Comments
 (0)