elements icon indicating copy to clipboard operation
elements copied to clipboard

Uploading a file is no longer possible with multipart/form-data

Open pepawel opened this issue 2 years ago • 3 comments

If I set field type to string and format to binary in requestBody, then Elements should render it as a field with file selector button. However, currently it renders it as a normal text field.

screenshot-localhost_3000-2022 10 11-21_06_08

There is a feature implemented by this PR, I saw screenshots of it (at least partly) working in this issue. So it seems the feature stopped working.

Context

Developers using API documentation are unable to test endpoints requiring file upload.

Current Behavior

The file field renders as a normal text field.

Expected Behavior

The file field should present file selector button.

Possible Workaround/Solution

I don't see any.

Steps to Reproduce

  1. Use following API spec:
openapi: 3.1.0
info:
  title: Example
  version: 0.1
servers:
  - url: http://example.com
paths:
  /api:
    post:
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                text_field:
                  type: string
                file:
                  type: string
                  format: binary
  1. Open it with Elements.
  2. Observe lack of upload button for field named file.

Environment

  • Version used: 7.7.2 (from https://www.npmjs.com/package/@stoplight/elements)
  • Environment name and version: Node v16.17.1, React 17.0.2, Nextjs 12.
  • Operating System and version: Pop!_OS 22.04 LTS

pepawel avatar Oct 11 '22 19:10 pepawel

Any update on this?

kaperont avatar Feb 05 '24 14:02 kaperont

Is there a work-around in the meantime?

kaperont avatar Feb 05 '24 17:02 kaperont

Looking for a workaround too.

This is important for our app.

arno-fukuda avatar Jul 13 '24 06:07 arno-fukuda