Skip to content

Commit 0d7744b

Browse files
committed
Update rust-server examples to have namespaces by API name. Preventing warnings about clashing example names
1 parent 82ad061 commit 0d7744b

17 files changed

Lines changed: 179 additions & 157 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
@@ -68,4 +73,5 @@ jobs:
6873
cargo test
6974
cargo clippy
7075
cargo doc
76+
popd
7177
done

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

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

175175
[[example]]
176-
name = "client"
176+
name = "{{{packageName}}}-client"
177+
path = "examples/client/main.rs"
177178
required-features = ["client"]
178179

179180
[[example]]
180-
name = "server"
181+
name = "{{{packageName}}}-server"
182+
path = "examples/server/main.rs"
181183
required-features = ["server"]
182184

183185
[[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/output/multipart-v3/Cargo.toml

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

107107
[[example]]
108-
name = "client"
108+
name = "multipart-v3-client"
109+
path = "examples/client/main.rs"
109110
required-features = ["client"]
110111

111112
[[example]]
112-
name = "server"
113+
name = "multipart-v3-server"
114+
path = "examples/server/main.rs"
113115
required-features = ["server"]
114116

115117
[[bin]]

samples/server/petstore/rust-server/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/output/no-example-v3/Cargo.toml

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

101101
[[example]]
102-
name = "client"
102+
name = "no-example-v3-client"
103+
path = "examples/client/main.rs"
103104
required-features = ["client"]
104105

105106
[[example]]
106-
name = "server"
107+
name = "no-example-v3-server"
108+
path = "examples/server/main.rs"
107109
required-features = ["server"]
108110

109111
[[bin]]

samples/server/petstore/rust-server/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/output/openapi-v3/Cargo.toml

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

107107
[[example]]
108-
name = "client"
108+
name = "openapi-v3-client"
109+
path = "examples/client/main.rs"
109110
required-features = ["client"]
110111

111112
[[example]]
112-
name = "server"
113+
name = "openapi-v3-server"
114+
path = "examples/server/main.rs"
113115
required-features = ["server"]
114116

115117
[[bin]]

samples/server/petstore/rust-server/output/openapi-v3/README.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -66,64 +66,64 @@ 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 openapi-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 openapi-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 openapi-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 AnyOfGet
90-
cargo run --example client CallbackWithHeaderPost
91-
cargo run --example client ComplexQueryParamGet
92-
cargo run --example client ExamplesTest
93-
cargo run --example client FormTest
94-
cargo run --example client GetWithBooleanParameter
95-
cargo run --example client JsonComplexQueryParamGet
96-
cargo run --example client MandatoryRequestHeaderGet
97-
cargo run --example client MergePatchJsonGet
98-
cargo run --example client MultigetGet
99-
cargo run --example client MultipleAuthSchemeGet
100-
cargo run --example client OneOfGet
101-
cargo run --example client OverrideServerGet
102-
cargo run --example client ParamgetGet
103-
cargo run --example client ReadonlyAuthSchemeGet
104-
cargo run --example client RegisterCallbackPost
105-
cargo run --example client RequiredOctetStreamPut
106-
cargo run --example client ResponsesWithHeadersGet
107-
cargo run --example client Rfc7807Get
108-
cargo run --example client TwoFirstLetterHeaders
109-
cargo run --example client UntypedPropertyGet
110-
cargo run --example client UuidGet
111-
cargo run --example client XmlExtraPost
112-
cargo run --example client XmlOtherPost
113-
cargo run --example client XmlOtherPut
114-
cargo run --example client XmlPost
115-
cargo run --example client XmlPut
116-
cargo run --example client EnumInPathPathParamGet
117-
cargo run --example client MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGet
118-
cargo run --example client CreateRepo
119-
cargo run --example client GetRepoInfo
89+
cargo run --example openapi-v3-client AnyOfGet
90+
cargo run --example openapi-v3-client CallbackWithHeaderPost
91+
cargo run --example openapi-v3-client ComplexQueryParamGet
92+
cargo run --example openapi-v3-client ExamplesTest
93+
cargo run --example openapi-v3-client FormTest
94+
cargo run --example openapi-v3-client GetWithBooleanParameter
95+
cargo run --example openapi-v3-client JsonComplexQueryParamGet
96+
cargo run --example openapi-v3-client MandatoryRequestHeaderGet
97+
cargo run --example openapi-v3-client MergePatchJsonGet
98+
cargo run --example openapi-v3-client MultigetGet
99+
cargo run --example openapi-v3-client MultipleAuthSchemeGet
100+
cargo run --example openapi-v3-client OneOfGet
101+
cargo run --example openapi-v3-client OverrideServerGet
102+
cargo run --example openapi-v3-client ParamgetGet
103+
cargo run --example openapi-v3-client ReadonlyAuthSchemeGet
104+
cargo run --example openapi-v3-client RegisterCallbackPost
105+
cargo run --example openapi-v3-client RequiredOctetStreamPut
106+
cargo run --example openapi-v3-client ResponsesWithHeadersGet
107+
cargo run --example openapi-v3-client Rfc7807Get
108+
cargo run --example openapi-v3-client TwoFirstLetterHeaders
109+
cargo run --example openapi-v3-client UntypedPropertyGet
110+
cargo run --example openapi-v3-client UuidGet
111+
cargo run --example openapi-v3-client XmlExtraPost
112+
cargo run --example openapi-v3-client XmlOtherPost
113+
cargo run --example openapi-v3-client XmlOtherPut
114+
cargo run --example openapi-v3-client XmlPost
115+
cargo run --example openapi-v3-client XmlPut
116+
cargo run --example openapi-v3-client EnumInPathPathParamGet
117+
cargo run --example openapi-v3-client MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGet
118+
cargo run --example openapi-v3-client CreateRepo
119+
cargo run --example openapi-v3-client GetRepoInfo
120120
```
121121

122122
### HTTPS
123123
The examples can be run in HTTPS mode by passing in the flag `--https`, for example:
124124

125125
```
126-
cargo run --example server -- --https
126+
cargo run --example openapi-v3-server -- --https
127127
```
128128

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

samples/server/petstore/rust-server/output/ops-v3/Cargo.toml

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

101101
[[example]]
102-
name = "client"
102+
name = "ops-v3-client"
103+
path = "examples/client/main.rs"
103104
required-features = ["client"]
104105

105106
[[example]]
106-
name = "server"
107+
name = "ops-v3-server"
108+
path = "examples/server/main.rs"
107109
required-features = ["server"]
108110

109111
[[bin]]

0 commit comments

Comments
 (0)