swagger-api / swagger-api/swagger-codegen

Base64 parameters code generation

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

Nobody has claimed this yet.

General: Suggestion
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

When generating PHP code that will utilize base64 encoded data, no code is generated to provide base64 encoding/decoding.

Example:
https://github.com/swagger-api/swagger-codegen/blob/4d19da41dd8a3462f88c2be57174aace45101064/modules/swagger-codegen/src/test/resources/2_0/binaryDataTest.json

Furthermore a search on base64 in this github repository does not bring up a base64 encoding system for ANY existing language. base64 seems to only be supported for HTTP authentication.

Swagger-codegen version

unknown, there does not seem to be a --version command.

Swagger declaration file content or url

https://github.com/swagger-api/swagger-codegen/blob/4d19da41dd8a3462f88c2be57174aace45101064/modules/swagger-codegen/src/test/resources/2_0/binaryDataTest.json

Command line used for generation

java -jar swagger-codegen-cli.jar generate -l php -i ./lti.schema.mod.json -c ./sheroapi.json

Suggest a Fix

Review documentation and determine if base64 encoded data should be created for definitions such as:

    "parameters": [
      {
        "name": "InputBinaryData",
        "in": "body",
        "required": true,
        "schema": {
          "type": "string",
          "format": "binary"
        }
      }
    ],

In addition, determine if this is limited to the body or if it can be included in the url and/or query parameters. From what I can tell, this is supported by the current specification but rarely implemented.

If base64 encoding should be supported, test various framework generation to confirm if it works for any existing language.

Document languages supporting base64 encoding in generated code and languages not supporting it. Add documentation to Wiki so interested parties can implement.

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

Use the referenced binaryDataTest.json fixture and the documented java -jar generate -l php command as starting points. Compare handling of base64-encoded body, URL, and query parameters across generated languages, then document which languages support the behavior and which do not in the Wiki.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.