swagger-api / swagger-api/swagger-ui

Help to add example attribute for a file upload using multipart/form-data

Open
#8,494 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A
  • OS: macOS
  • Browser: Chrome
  • Version: latest
  • Method of installation: yarn
  • Swagger-UI version: 4.0.0
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

Swagger/OpenAPI definition:

openapi: 3.0.0
info:
  title: CSV Upload API
  description: API for uploading a CSV file with name, age, and grade columns
  version: 1.0.0
servers:
  - url: https://example.com/api
paths:
  /upload:
    post:
      summary: Upload CSV file
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                csv_file:
                  type: string
                  format: binary
                  description: The CSV file to upload
              required:
                - csv_file
            encoding:
              csv_file:
                contentType: text/csv
                example: |
                  name,age,grade
                  John Doe,30,85
                  Jane Smith,25,90
      responses:
        '200':
          description: Successfully uploaded CSV file
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: A success message
                  data:
                    type: object
                    description: Uploaded file metadata
                    properties:
                      filename:
                        type: string
                        description: The name of the uploaded file
                      mimetype:
                        type: string
                        description: The MIME type of the uploaded file
                      size:
                        type: integer
                        description: The size of the uploaded file in bytes

Screenshots

Swagger Editor:
Captura de Tela 2023-03-20 às 21 17 51

Request parameters:
Captura de Tela 2023-03-20 às 21 34 23

How can we help?

Hey team, I'm trying to add an "example" attribute showing the file content of a multipart/form-data request (the csv format), example:

name,age,grade
John Doe,30,85
Jane Smith,25,90

I failed several times until now. I tried to use the Swagger Editor to find a way to do that, but didn't work out.

Can you please show an example of how to do it?

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

The issue names no repository file, test, or entry point. Start by checking how Swagger UI 4.0.0 handles the OpenAPI 3.0 multipart/form-data example; done means documenting a supported example or clearly explaining the limitation.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.