question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing file browser in "Try it out" for multipart/form file uploads

See original GitHub issue

Previously (in OpenAPI 2.0), when creating an endpoint which takes a file upload via a multipart/form POST request, the Try it out section in Swagger UI showed a Choose File button to select a file from my harddisk which then got uploaded when clicking the execute button.

Following the docs on how to do such uploads in OpenAPI 3.0.0, however, I am missing that button in Swagger UI and see a textbox instead with a JSON representation of the schema.

Is that expected behaviour (as in not yet implemented for OpenAPI 3.0.0) or is the file upload in my API definition incorrectly written?

Q A
Bug or feature request? Could be both, depending on if this is expected behaviour
Which Swagger/OpenAPI version? OpenAPI 3.0.0
Which Swagger-UI version? 3.3.2
How did you install Swagger-UI? https://editor.swagger.io and self-hosted dist folder on nginx
Which browser & version? Chrome 62.0 & Opera 48.0
Which operating system? Ubuntu 14.04

Demonstration API definition

Working example in OpenAPI 2.0:

swagger: '2.0'
info:
  title: Some API
  version: '1'
paths:
  /conversion/nmea/geojson:
    post:
      consumes:
        - multipart/form-data
      parameters:
        - in: formData
          name: file
          type: file
      produces:
        - text/plain
      responses:
        '200':
          description: OK
          schema:
            type: string
            example: "File upload successful"

Non-working example in OpenAPI 3.0.0:

openapi: 3.0.0
info:
  title: Some API
  version: "1"

paths:
  /upload:
    post:
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
      responses:
        '200':
          description: OK
          content:
            text/plain:
              schema:
                type: string
                example: "File upload successful"

Expected Behavior

openapi_2 0

Current Behavior

openapi_3 0 0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jonbcamposcommented, Jul 12, 2018

I can say that the update worked for me

On Thu, Jul 12, 2018, 8:43 AM Ron notifications@github.com wrote:

@here https://github.com/here - this has been implemented and is supposed to work (just tested it myself). If you encounter an issue, please file a new ticket with steps and details to help us investigate.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/swagger-api/swagger-ui/issues/3784#issuecomment-404557161, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIgzVrZHv4eu_5WtTe4fBU6bPh6lV6mks5uF26IgaJpZM4P_DSW .

2reactions
webroncommented, Jul 12, 2018

@here - this has been implemented and is supposed to work (just tested it myself). If you encounter an issue, please file a new ticket with steps and details to help us investigate.

Read more comments on GitHub >

github_iconTop Results From Across the Web

File upload on Swagger Editor OpenAPI 3 not showing the file ...
I need to document a route which consists of uploading an image. When attempting to "Try it out", I don't get the file...
Read more >
File Upload - Swagger
Swagger 2.0 supports file uploads sent with Content-Type: multipart/form-data . That is, your API server must consume multipart/form-data for this operation:.
Read more >
File Upload via Swagger - codeburst
The problem is not in the Swashbuckle.AspNetCore library but an issue in an upstream library, swagger-ui (issue #4600).) UPDATE 06/19/2020: Now multi files...
Read more >
Handling file uploads - Manual - PHP
Sure if uploading a file is optional for a form then a user who uploads larger file will get no error and still...
Read more >
How to Handle File Uploads from Node.js to Express - Twilio
Learn how to upload files by posting multipart/form-data from ... Node.js installed on your machine, along with a package manager like npm ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found