简体   繁体   中英

How to upload a csv file using Swagger Open API 3.0?

I have given the following specification for csv file upload:-

requestBody:
        description: .csv file 
        content:
          application/csv:
            schema:
              type: string
              format: base64

I have also tried different types instead of application/csv, like multipart/form-data, text/csv etc. but none of them show a file upload option on the Swagger UI(also tried changing format to byte, binary, but no luck). The documentation mentions file upload only for images(which works fine).

Is there any way we can get the file upload option for csv or pdf files?

As of April 2020, Swagger UI shows the upload button only for application/octet-stream and image/ media types. There's an open issue to support file upload for other media types as well:
https://github.com/swagger-api/swagger-ui/issues/5636

As a workaround, you can try using application/octet-stream instead of application/csv .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM