OpenAPITools / OpenAPITools/openapi-generator

[BUG][RUST-SERVER] binary strings should not be base64 encoded

Open
#3,189 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug Server: Rust
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

The rust-server code generator handles binary and byte string format the same way. Both are base64 encoded automatically while binary strings should not perform this transformation as stated in OAS3.2.

Description

The formats defined by the OAS are:

type format Comments
string byte base64 encoded characters
string binary any sequence of octets
openapi-generator version

Tested with docker image openapitools/openapi-generator-cli with version 4.0.1-SNAPSHOT.

OpenAPI declaration file content or url
responses:
    "200":
      description: "OK"
      content:
        image/png:
          schema:
            type: string
            format: binary
Command line used for generation
docker run --rm -u $(id -u ${USER}):$(id -g ${USER}) -v ${PWD}:/local -w /local openapitools/openapi-generator-cli generate \
    --enable-post-process-file \
    --generate-alias-as-model \
    -i /local/openapi/openapi.yaml \
    -g rust-server \
    -o /local/packages/rust-server \
    -DpackageName=server
Related issues/PRs

Issue #538 mentions binary and byte string but doesn't mention how they should be handled differently.

Suggest a fix

Vec<u8> should be used for binary string instead of swagger::ByteArray.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the rust-server generator output produced from the provided OpenAPI declaration and trace how string formats binary and byte are mapped. Verify the generated response handling against the OAS 3.2 distinction; done means binary uses Vec while byte retains base64 encoding.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, rust
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.