Skip to content

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

Open
@lelongg

Description

@lelongg

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions