postman-to-openapi
postman-to-openapi copied to clipboard
Wrong type when binary file in the request
Hello,
If we send a file in binary form from Postman, p2o threats it as text/plain. Here is the example Postman and p2o result:
{
"info": {
"_postman_id": "daeaed7e-5dee-4aa8-8828-3280afb2b11a",
"name": "Raw Body",
"description": "Mi super test collection from postman",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Test Raw Body - File",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "file",
"file": {
"src": "AuthBasic.json"
}
},
"url": {
"raw": "https://api.io/file",
"protocol": "https",
"host": [
"api",
"io"
],
"path": [
"file"
]
}
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
]
}
result:
openapi: 3.0.0
info:
title: Raw Body
description: Mi super test collection from postman
version: 1.0.0
servers:
- url: https://api.io
paths:
/file:
post:
tags:
- default
summary: Test Raw Body - File
requestBody:
content:
text/plain: {}
responses:
'200':
description: Successful response
content:
application/json: {}
I believe this behavior due to this line: https://github.com/joolfe/postman-to-openapi/blob/master/lib/index.js#L180
case 'file':
content = {
'text/plain': {}
}
break
And also, postman and OpenAPI support this:
https://spec.openapis.org/oas/v3.0.3.html#considerations-for-file-uploads
Thanks in advance.