Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !10383

[rust-server] fix bug that requires binary string to be encoded as base64.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/x7c1/issue-3189-accept-binary-string into master Sep 12, 2021
  • Overview 0
  • Commits 8
  • Pipelines 1
  • Changes 3

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), not baseName (additionalMetadata).
  • B) had decoded primitive values (on multipart form data) as JSON. (for example, it had only accepted foo="asdf" format string, not foo=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:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    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 ./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.
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/x7c1/issue-3189-accept-binary-string