Created by: x7c1
fix #3189 (and some minor bugs described below.)
Steps to reproduce
# generate petstore examples
$ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml \
-g rust-server \
-o /var/tmp/rust-server
# launch rust-server
$ cd /var/tmp/rust-server
$ RUST_LOG=debug cargo run --example server
Finished dev [unoptimized + debuginfo] target(s) in 0.06s
Running `target/debug/examples/server`
# upload any file
$ curl -v -F 'file=@README.md' localhost:8080/v2/pet/1/uploadImage
* Trying 127.0.0.1:8080...
...
file data does not match API definition : expected value at line 1 column 1%
This is because format: binary is decoded as base64 (#3189).
I've confirmed this PR can remove this error :
$ curl -F 'file=@README.md' localhost:8080/v2/pet/1/uploadImage
# server outputs (fixed)
[2021-09-12T04:04:35Z INFO server::server] upload_file(1, None, Some(ByteArray([...]]))) - X-Span-ID: "14d8e6f4-1c84-4319-9f42-5e15ee70e673"
This PR can remove another error which rejects the form fields like additionalMetadata=asdf.
$ curl -F 'file=@README.md' -F 'additionalMetadata=asdf' localhost:8080/v2/pet/1/uploadImage
# server outputs (fixed)
[2021-09-12T10:31:47Z INFO server::server] upload_file(1, Some("asdf"), Some(ByteArray([...]]))) - X-Span-ID: "1b3e1089-fe74-4e61-b69b-3984654a4d0f"
This error had been caused by following two server bugs which
- A) had accepted
paramName(additional_metadata), notbaseName(additionalMetadata). - B) had decoded primitive values (on multipart form data) as JSON. (for example, it had only accepted
foo="asdf"format string, notfoo=asdf.)
Rust Technical Committee
@frol @farcaller @richardwhiuk @paladinzh
PR checklist
-
Read the contribution guidelines. -
Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community. -
Run the following to build the project and update samples: Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH. -
File the PR against the correct branch: master(5.3.0),6.0.x -
If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.