Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text format used instead of file for binary fields in form-data #795

Closed
dvacca-onfido opened this issue Jun 11, 2024 · 4 comments
Closed
Labels
bug Something isn't working good-first-issue Good first issues that can be picked up by beginner contributors. request-body

Comments

@dvacca-onfido
Copy link

dvacca-onfido commented Jun 11, 2024

Whenever a binary field is included in a request-body ("type": "string", "format": "binary"), e.g.:

  "requestBody": {
    "required": true,
    "content": {
      "multipart/form-data": {
        "schema": {
          "properties": {
            "inputfile": {
              "type": "string",
              "format": "binary",
              "description": "The file to be uploaded."
            }
          }
        }
      }
    }
  },

That's is wrongly converted into a text field ("type": "text" instead of "type": "file"), with an value field ("value": "<string>") which should perhaps be dropped:

  "method": "POST",
  "body": {
      "mode": "formdata",
      "formdata": [
          {
              "description": {
                  "content": "The file to be uploaded.",
                  "type": "text/plain"
              },
              "key": "inputfile",
              "value": "<string>",
              "type": "text"
          }
      ]
  }

This seems to be a regression of interface v2 compared with v1; for v1 fix below (not present in v2) has been found:
c338289

Version: 4.21.0

To reproduce:

npx openapi2postmanv2 -s minimal-openapi.json -o minimal-collection-v2.json -i v2 -p
npx openapi2postmanv2 -s minimal-openapi.json -o minimal-collection-v1.json -i v1 -p

minimal-collection-v1.json
minimal-collection-v2.json
minimal-openapi.json

@VShingala
Copy link
Member

@dvacca-onfido Thanks for reporting the issue! We'll work on the fix for this soon and inform here once this is fixed.

@VShingala VShingala added bug Something isn't working request-body good-first-issue Good first issues that can be picked up by beginner contributors. labels Jul 11, 2024
@thim81
Copy link
Contributor

thim81 commented Jul 16, 2024

@VShingala & @dvacca-onfido
I created PR, which should solve the reported issue.
I used your provided openapi as input for a test.

@dvacca-onfido
Copy link
Author

@VShingala & @dvacca-onfido I created PR, which should solve the reported issue. I used your provided openapi as input for a test.

LGTM, thanks @thim81

@dvacca-onfido
Copy link
Author

Issue is solved after #805

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good-first-issue Good first issues that can be picked up by beginner contributors. request-body
Projects
None yet
Development

No branches or pull requests

3 participants