Skip to content

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

@dirkschneemann

Description

@dirkschneemann

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

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